]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/nslu2-binary-only/unslung-rootfs-2.3r63/linuxrc
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / nslu2-binary-only / unslung-rootfs-2.3r63 / linuxrc
1 #!/bin/sh
2
3 # ****  DO NOT EVEN THINK OF EDITING OR REMOVING THIS FILE  ****
4 # **** UNLESS YOU REALLY KNOW *EXACTLY* WHAT YOU ARE DOING. ****
5
6
7 # Perform prepatory tasks, and determine whether an alternate rootfs is viable.
8
9 /bin/mount -t proc proc /proc
10
11 echo "1" > /proc/sys/kernel/panic
12
13 /bin/echo "Sleeping while waiting for disk..."
14 cnt=20
15 while [ $cnt -gt 0 ] ; do
16   echo -ne "\r$cnt "
17   sleep 1
18   [ -f /proc/hdd_sdb ] && cnt=0
19   [ -f /proc/hdd_sda ] && cnt=0
20   cnt=`expr $cnt - 1`
21 done
22 echo
23
24 sleep 5
25
26 mounted=
27
28 for prefroot in sdb1 sda1 ; do
29   if [ -z "$mounted" ] ; then
30     if /bin/mount -rt ext3 /dev/$prefroot /mnt ; then
31       if [ -x /mnt/bin/init ] ; then
32         /bin/echo "Root filesystem will be mounted from /dev/$prefroot ..."
33         mounted=/mnt
34       else
35         /bin/umount /mnt
36         /bin/echo "Can't find valid rootfs on /dev/$prefroot ..."
37       fi
38     fi
39   fi
40 done
41
42 if [ -z "$mounted" ] ; then
43   /bin/echo "Can't find valid rootfs, using ramdisk ..."
44   mounted=
45 fi
46
47 /bin/umount /proc
48
49 # Pivot to the desired rootfs and run the initial executable.
50
51 if [ -n "$mounted" ] ; then
52
53     cd $mounted
54
55     /bin/echo "Pivoting to external rootfs ..."
56     /sbin/pivot_root . initrd
57
58     exec /usr/sbin/chroot . /bin/init < /dev/console 1> /dev/console 2> /dev/console
59
60 else
61
62     exec /bin/init
63
64 fi
65
66 /bin/echo "Can't pivot to external rootfs, using ramdisk ..."
67 exec /bin/init
68
69 # Last-resort fall-back - this should never be reached.
70 /bin/sh