3 # **** DO NOT EVEN THINK OF EDITING OR REMOVING THIS FILE ****
4 # **** UNLESS YOU REALLY KNOW *EXACTLY* WHAT YOU ARE DOING. ****
7 # Determine the desired rootfs based on user flag files.
9 if [ -f /.ramdisk ] ; then
10 /bin/echo "Preferred root device is /dev/ram0 (maintenence)"
13 elif [ -f /.sda1root ] ; then
14 /bin/echo "Preferred root device is /dev/sda1 (disk 1)"
17 elif [ -f /.sda2root ] ; then
18 /bin/echo "Preferred root device is /dev/sda2 (disk 1)"
21 elif [ -f /.sdb1root ] ; then
22 /bin/echo "Preferred root device is /dev/sdb1 (disk 2)"
25 elif [ -f /.sdb2root ] ; then
26 /bin/echo "Preferred root device is /dev/sdb2 (disk 2)"
29 elif [ -f /.nfsroot ] ; then
30 /bin/echo "Preferred root device is NFS"
34 /bin/echo "Preferred root device is jffs2"
40 # Perform prepatory tasks, and determine whether the desired rootfs is viable.
42 /bin/mount -t proc proc /proc
44 if [ $prefroot = "sda1" -o $prefroot = "sda2" -o $prefroot = "sdb1" -o $prefroot = "sdb2" ] ; then
45 /bin/echo "Sleeping 10sec while waiting for disk..."
47 /bin/mount -rt ext3 /dev/$prefroot /mnt
48 if [ -L /mnt/sbin/init -o -x /mnt/sbin/init -o \
49 -L /mnt/bin/init -o -x /mnt/bin/init ] ; then
50 /bin/echo "Root filesystem will be mounted from /dev/$prefroot ..."
53 /bin/echo "Can't find valid rootfs on /dev/$prefroot, using jffs2 ..."
59 if [ $prefroot = "maintenence" ] ; then
60 /bin/dd if=/dev/zero of=/dev/ram0 bs=1k count=12k 2>/dev/null
61 /usr/bin/mke2fs -m 0 /dev/ram0 12288
62 /bin/mount -t ext2 /dev/ram0 /mnt
63 ( /usr/bin/find . -print0 -mount | /usr/bin/cpio -p -0 -d -m -u /mnt )
64 /bin/rm -f /mnt/linuxrc
65 /bin/cp /mnt/home/httpd/html/Management/upgrade.cgi /mnt/home/httpd/html/Management/upgrade-real.cgi
66 /bin/echo "#!/bin/sh" > /mnt/home/httpd/html/Management/upgrade.cgi
67 /bin/echo >> /mnt/home/httpd/html/Management/upgrade.cgi
68 /bin/echo "/bin/mount -t ramfs none /upload -o size=8196 2>/dev/null" \
69 >> /mnt/home/httpd/html/Management/upgrade.cgi
70 /bin/echo "/bin/dd if=/dev/zero of=/upload/free-ram bs=1k count=8k 2>/dev/null" \
71 >> /mnt/home/httpd/html/Management/upgrade.cgi
72 /bin/echo "/bin/umount /upload 2>/dev/null" \
73 >> /mnt/home/httpd/html/Management/upgrade.cgi
74 /bin/echo "exec /home/httpd/html/Management/upgrade-real.cgi" \
75 >> /mnt/home/httpd/html/Management/upgrade.cgi
76 /bin/echo "Root filesystem will be mounted from /dev/ram0 (a copy of /dev/mtdblock4) ..."
79 if [ $prefroot = "nfsroot" ] ; then
81 sysconflen=`/bin/dd if=/dev/mtd1 bs=4 count=1 2>/dev/null | /usr/bin/hexdump -n 6 -e '"%02d"'`
82 ipaddr=`/bin/dd if=/dev/mtd1 bs=1 count=$sysconflen skip=4 2>/dev/null | grep ip_addr | sed -e s/ip_addr=//`
83 netmask=`/bin/dd if=/dev/mtd1 bs=1 count=$sysconflen skip=4 2>/dev/null | grep netmask | sed -e s/netmask=//`
84 gateway=`/bin/dd if=/dev/mtd1 bs=1 count=$sysconflen skip=4 2>/dev/null | grep gateway | sed -e s/gateway=//`
87 /sbin/insmod ixp425_eth
88 /sbin/ifconfig ixp0 up $ipaddr netmask $netmask
89 /sbin/route add default gw $gateway
91 /sbin/ifconfig lo up 127.0.0.1
93 # The nfsrootloc and nfsrootopts vars can be overridden here.
96 /bin/mount $nfsrootopts $nfsrootloc /mnt
98 if [ -L /mnt/sbin/init -o -x /mnt/sbin/init -o \
99 -L /mnt/bin/init -o -x /mnt/bin/init ] ; then
100 /bin/echo "Root filesystem will be mounted from an NFS root ..."
104 /bin/echo "Can't find valid NFS rootfs, using jffs2 ..."
110 if [ $prefroot = "jffs2" ] ; then
111 /bin/echo "Root filesystem will be mounted from /dev/mtdblock4 ..."
118 # Pivot to the desired rootfs and run the initial executable.
120 if [ -n "$mounted" ] ; then
124 if [ -x ./sbin/init -o -L ./sbin/init ] ; then
126 elif [ -x ./bin/init -o -L ./bin/init ] ; then
132 /sbin/pivot_root . initrd
134 exec /usr/sbin/chroot . $runboot < /dev/console 1> /dev/console 2> /dev/console
142 /bin/echo "Can't chroot to $prefroot, using jffs2 ..."
145 # Last-resort fall-back - this should never be reached.