| 1 |
#!/bin/mksh |
| 2 |
export PATH=/bin:/sbin:/usr/bin:/usr/sbin |
| 3 |
|
| 4 |
mount -nt proc proc /proc |
| 5 |
if [[ ! -e /dev/null ]]; then |
| 6 |
# this is linux 2.6 only anyway, we have devfs in 2.4 |
| 7 |
mount -t tmpfs mdev /dev |
| 8 |
# values hard-coded for Linux |
| 9 |
mknod -m 0666 /dev/null c 1 3 |
| 10 |
mknod -m 0666 /dev/tty c 5 0 |
| 11 |
mknod -m 0622 /dev/console c 5 1 |
| 12 |
# switch to the real console (if possible) |
| 13 |
exec 0<>/dev/console >&0 2>&0 |
| 14 |
print Notice: opened initial console now. |
| 15 |
# do the deed |
| 16 |
[[ -e /dev/MAKEDEV ]] && mksh /dev/MAKEDEV all |
| 17 |
fi |
| 18 |
|
| 19 |
function failsafe { |
| 20 |
netmsg 192.168.1.255 "Entering Failsafe!" |
| 21 |
telnetd |
| 22 |
sh |
| 23 |
} |
| 24 |
|
| 25 |
[ -f /etc/preinit.arch ] && . /etc/preinit.arch |
| 26 |
[ -f /proc/diag/led/power ] && echo f >/proc/diag/led/power |
| 27 |
|
| 28 |
# failsafe via hotplug |
| 29 |
trap 'FAILSAFE=true' USR1 |
| 30 |
echo /sbin/hotplug.failsafe >/proc/sys/kernel/hotplug |
| 31 |
ip link set up dev eth0 |
| 32 |
ip addr add 192.168.1.1/24 broadcast 192.168.1.255 dev eth0 |
| 33 |
netmsg 192.168.1.255 "Press reset now to enter Failsafe!" |
| 34 |
echo "Press reset now to enter Failsafe!" |
| 35 |
sleep 2 |
| 36 |
eval ${FAILSAFE:+failsafe} |
| 37 |
trap - USR1 |
| 38 |
|
| 39 |
# reset to normal mode |
| 40 |
echo /sbin/hotplug >/proc/sys/kernel/hotplug |
| 41 |
mount_root |
| 42 |
cat /etc/.rnd >/dev/urandom 2>&1 |
| 43 |
true >/tmp/.booting |
| 44 |
[ -x /sbin/fwcf ] && fwcf setup 2>&1 | while IFS= read -r line; do |
| 45 |
netmsg 192.168.1.255 "fwcf diag: $line" |
| 46 |
done |
| 47 |
ip addr delete 192.168.1.1/24 broadcast 192.168.1.255 dev eth0 |
| 48 |
reset_switch # shell function, defined in preinit.arch |
| 49 |
|
| 50 |
# ensure busybox is suid root and resume booting |
| 51 |
if [[ -e /bin/busybox && ! -u /bin/busybox ]]; then |
| 52 |
chown 0:0 /bin/busybox |
| 53 |
chmod 4111 /bin/busybox |
| 54 |
fi |
| 55 |
exec /sbin/init |