2 # Copyright (C) 2006 OpenWrt.org
3 export PATH=/bin:/sbin:/usr/bin:/usr/sbin
7 ifconfig $ifname 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255 up
12 [ -n "$ifname" ] && grep "$ifname" /proc/net/dev >/dev/null && {
14 netmsg 192.168.1.255 "Entering Failsafe!"
15 telnetd -l /bin/login.sh <> /dev/null 2>&1
21 mount proc /proc -t proc
22 mount sysfs /sys -t sysfs
24 size=$(awk '/MemTotal:/ {l=5242880;mt=($2*1024);print((s=mt/2)<l)&&(mt>l)?mt-l:s}' /proc/meminfo)
25 mount tmpfs /tmp -t tmpfs -o size=$size,nosuid,nodev,mode=1777
27 if grep devfs /proc/filesystems > /dev/null; then
28 mount devfs /dev -t devfs
31 HOTPLUG=/sbin/hotplug-call
33 elif [ -x /sbin/hotplug2 ]; then
34 mount -t tmpfs tmpfs /dev -o size=512K
35 mknod /dev/console c 5 1
36 /sbin/hotplug2 --set-worker /lib/hotplug2/worker_fork.so --set-rules-file /etc/hotplug2-init.rules --no-persistent --set-coldplug-cmd /sbin/udevtrigger
37 /sbin/hotplug2 --set-worker /lib/hotplug2/worker_fork.so --set-rules-file /etc/hotplug2-init.rules --persistent &
42 elif [ -x /sbin/udevd ]; then
43 mount -n -t tmpfs -o mode=0755 udev /dev
44 [ -d /lib/udev/devices ] && cp -af /lib/udev/devices/* /dev/
45 [ -c /dev/console ] || mknod -m 0600 /dev/console c 5 1
46 [ -c /dev/null ] || mknod -m 0666 /dev/null c 1 3
47 /sbin/udevd --daemon --resolve-names=never
55 [ -d /dev/pts ] || mkdir -p /dev/pts
56 [ -d /dev/shm ] || mkdir -p /dev/shm
57 mount devpts /dev/pts -t devpts
59 # the shell really doesn't like having stdin/out closed
60 # that's why we use /dev/pty/m0 and m1 as replacement
61 # for /dev/console if there's no serial console available
62 dd if=/dev/console of=/dev/null bs=1 count=0 >/dev/null 2>/dev/null && {
71 echo "Press CTRL-C for failsafe"
72 trap 'FAILSAFE=true' INT
73 trap 'FAILSAFE=true' USR1
74 if [ -e /etc/preinit.arch ]; then
79 echo "$HOTPLUG" > /proc/sys/kernel/hotplug
81 eval ${FAILSAFE:+failsafe}
82 lock -w /tmp/.failsafe
84 if [ -z "$INITRAMFS" ]; then
86 [ -f /sysupgrade.tgz ] && {
87 echo "- config restore -"
89 mv sysupgrade.tgz /tmp
90 tar xzf /tmp/sysupgrade.tgz
91 rm -f /tmp/sysupgrade.tgz