blob: af694bc68d068e8f2734e37a2686fab20de82bf5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
#!/bin/sh
# **** DO NOT EVEN THINK OF EDITING OR REMOVING THIS FILE ****
# **** UNLESS YOU REALLY KNOW *EXACTLY* WHAT YOU ARE DOING. ****
# Determine the desired rootfs based on user flag files.
if [ -f /.sda1root ] ; then
/bin/echo "Preferred root device is /dev/sda1 (disk 1)"
mounted=/mnt
prefroot=sda1
elif [ -f /.sda2root ] ; then
/bin/echo "Preferred root device is /dev/sda2 (disk 1)"
mounted=/mnt
prefroot=sda2
elif [ -f /.sdb1root ] ; then
/bin/echo "Preferred root device is /dev/sdb1 (disk 2)"
mounted=/mnt
prefroot=sdb1
elif [ -f /.sdb2root ] ; then
/bin/echo "Preferred root device is /dev/sdb2 (disk 2)"
mounted=/mnt
prefroot=sdb2
elif [ -f /.nfsroot ] ; then
/bin/echo "Preferred root device is NFS"
mounted=/mnt
prefroot=nfsroot
else
/bin/echo "Preferred root device is jffs2"
mounted=
prefroot=jffs2
fi
# Perform prepatory tasks, and determine whether the desired rootfs is viable.
/bin/mount -t proc proc /proc
if [ $prefroot = "sda1" -o $prefroot = "sda2" -o $prefroot = "sdb1" -o $prefroot = "sdb2" ] ; then
/bin/echo "Sleeping while waiting for disk..."
cnt=20
while [ $cnt -gt 0 ] ; do
echo -ne "\r$cnt "
sleep 1
[ $prefroot = "sda1" ] && [ -f /proc/hd_conn ] && cnt=0
[ $prefroot = "sda2" ] && [ -f /proc/hd_conn ] && cnt=0
[ $prefroot = "sdb1" ] && [ -f /proc/hd2_conn ] && cnt=0
[ $prefroot = "sdb2" ] && [ -f /proc/hd2_conn ] && cnt=0
cnt=`expr $cnt - 1`
done
echo
/bin/mount -rt ext3 /dev/$prefroot /mnt
if [ -L /mnt/sbin/init -o -x /mnt/sbin/init -o \
-L /mnt/bin/init -o -x /mnt/bin/init ] ; then
/bin/echo "Root filesystem will be mounted from /dev/$prefroot ..."
else
/bin/umount /mnt
/bin/echo "Can't find valid rootfs on /dev/$prefroot, using jffs2 ..."
mounted=
prefroot=jffs2
fi
fi
if [ $prefroot = "nfsroot" ] ; then
sysconflen=`/bin/dd if=/dev/mtd1 bs=4 count=1 2>/dev/null | /usr/bin/hexdump -n 6 -e '"%02d"'`
ipaddr=`/bin/dd if=/dev/mtd1 bs=1 count=$sysconflen skip=4 2>/dev/null | grep ip_addr | sed -e s/ip_addr=//`
netmask=`/bin/dd if=/dev/mtd1 bs=1 count=$sysconflen skip=4 2>/dev/null | grep netmask | sed -e s/netmask=//`
gateway=`/bin/dd if=/dev/mtd1 bs=1 count=$sysconflen skip=4 2>/dev/null | grep gateway | sed -e s/gateway=//`
/sbin/insmod ixp400
/sbin/insmod ixp425_eth
/sbin/ifconfig ixp0 up $ipaddr netmask $netmask
/sbin/route add default gw $gateway
/sbin/ifconfig lo up 127.0.0.1
# The nfsrootloc and nfsrootopts vars can be overridden here.
. /.nfsroot
/bin/mount $nfsrootopts $nfsrootloc /mnt
if [ -L /mnt/sbin/init -o -x /mnt/sbin/init -o \
-L /mnt/bin/init -o -x /mnt/bin/init ] ; then
/bin/echo "Root filesystem will be mounted from an NFS root ..."
mounted=/mnt
else
/bin/umount /mnt
/bin/echo "Can't find valid NFS rootfs, using jffs2 ..."
mounted=
prefroot=jffs2
fi
fi
if [ $prefroot = "jffs2" ] ; then
/bin/echo "Root filesystem will be mounted from /dev/mtdblock4 ..."
mounted=
fi
/bin/umount /proc
# Pivot to the desired rootfs and run the initial executable.
if [ -n "$mounted" ] ; then
cd $mounted
if [ -x ./sbin/init -o -L ./sbin/init ] ; then
runboot=/sbin/init
elif [ -x ./bin/init -o -L ./bin/init ] ; then
runboot=/bin/init
else
runboot=/bin/sh
fi
/sbin/pivot_root . initrd
exec /usr/sbin/chroot . $runboot < /dev/console 1> /dev/console 2> /dev/console
else
exec /bin/init
fi
/bin/echo "Can't chroot to $prefroot, using jffs2 ..."
exec /bin/init
# Last-resort fall-back - this should never be reached.
/bin/sh
|