wok-next view busybox/stuff/init @ rev 20014

Up leptonica (1.74.4). abiword, emacs: up bdeps. marble: fix build.
author Xander Ziiryanoff <psychomaniak@xakep.ru>
date Sat Oct 21 21:21:28 2017 +0200 (2017-10-21)
parents
children
line source
1 #!/bin/busybox sh
3 export PATH=/bin
4 export HOME=/
5 export TERM=vt100
7 if [ -d /etc ]; then
8 [ -n "$domain" ] && echo search $domain > /etc/resolv.conf
9 for i in $dns; do
10 echo nameserver $i
11 done >> /etc/resolv.conf
12 [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
13 [ -n "$subnet" ] && NETMASK="netmask $subnet"
14 if ifconfig $interface ${ip:-0.0.0.0} $BROADCAST $NETMASK; then
15 while route del default gw 0.0.0.0 dev $interface; do
16 :
17 done
18 for i in $router; do
19 route add default gw $i dev $interface
20 done
21 fi
22 exit
23 fi
25 mkdir /tmp /mnt /proc /etc
26 mount -t proc none /proc
27 mount -t devtmpfs none /dev
29 arg() {
30 root="$(sed "s/^/ /; s/$/ /; / $1=/!d; s/.* $1=\\([^ ]*\\).*/\\1/" </proc/cmdline)"
31 [ -n "$root" ]
32 }
34 arg init
35 init=${root:-/sbin/init}
36 [ -n "$(sed 's/$/ /; s/^/ /; / ro /!d' /proc/cmdline)" ] && ro="-o ro"
37 [ -n "$(sed 's/$/ /; s/^/ /; / rw /!d' /proc/cmdline)" ] && ro="-o rw"
39 arg root &&
40 root="$(echo $root | sed 's|/|\\\\/|g')" &&
41 root="$(blkid | sed "s/\"//g; /$root/!d; s/:.*//;q")" &&
42 [ -n "$root" ] &&
43 mount $ro $root /mnt
45 arg loopfs &&
46 losetup /dev/loop0 /mnt/$root &&
47 mount /dev/loop0 /mnt
49 arg subroot &&
50 cp /bin/busybox /mnt/$root/dev/shm &&
51 chroot="$root/dev/shm/busybox chroot $root"
53 [ -x /mnt/$root/$init ] &&
54 umount /dev &&
55 umount /proc &&
56 exec switch_root mnt $chroot $init
58 [ -d /proc/bus/usb ] &&
59 mount -t usbfs usbfs /proc/bus/usb
61 while read type dir; do
62 grep -qs $type /proc/filesystems || continue
63 [ -d "$dir" ] || mkdir $dir
64 mount -t $type none $dir
65 done <<EOM
66 sysfs /sys
67 devpts /dev/pts
68 EOM
70 TTY=$(tty 2>/dev/null)
71 TTY=${TTY:-/dev/tty1}
73 stty -F $TTY rows 30 2>/dev/null # for jslinux only
75 udhcpc -b -s /init
76 while true; do
77 busybox | sed '/Current/,$!d'
78 setsid sh -c "exec sh <$TTY >$TTY 2>&1"
79 done