3 # Copyright Matthias Hentges (c) 2005
5 # License: GPL (see http://www.gnu.org/licenses/gpl.txt for a copy of the GPL)
7 M_TITLE="Boot from NFS"
10 echo "ERROR: $1" >/dev/tty0
11 exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
14 # This function is activated by init.altboot by calling this script with the "run" option
17 test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!"
23 /etc/init.d/portmap start >/dev/tty1 2>&1 || die "/etc/init.d/portmap start failed!"
25 # For some reason NFS mounts hang if /e/i/networking is not run.
26 # For the time beeing I'm too lazy to investigate ;)
27 /etc/init.d/networking start || die "/etc/init.d/networking start failed!"
31 # After the PCMCIA service is started, an inserted WLAN card should automatically
33 /etc/init.d/pcmcia start >/dev/null 2>&1 || die "/etc/init.d/pcmcia/start failed!"
35 nfs_host="`cat /etc/fstab | grep -v ^# | grep nfs | awk '{print $1}'|sed -n "s/\(.*\)\:\(.*\)/\1/p" `"
36 nfs_mounts="`cat /etc/fstab | grep -v ^# | grep nfs | awk '{print $1}'`"
37 nfs_mountpoints="`cat /etc/fstab | grep -v ^# | grep nfs | awk '{print $2}'`"
39 if test -z "$nfs_host"
41 die "${C_RED}No configured NFS drives found in /etc/fstab$C_RESET"
45 # WLAN with DHCP needs some time to get a lease, set up the routing, etc.
46 echo -n "Waiting for WLAN"
50 if (ping -c 1 $nfs_host) >/dev/null 2>&1
55 if test "$cnt" = 30 -o "$cnt" = 60
58 echo "WARNING: WLAN didn't activate in $cnt seconds!"
62 echo "Restarting udhcpc"
64 udhcpc -i wlan0 -H `cat /etc/hostname` >/dev/null 2>&1
66 die "Failed to activate WLAN!"
77 if test "` echo "$nfs_mountpoints" |wc -l | tr -d " "`" -gt 1
79 echo -e "Please select your NFS root:\n"
82 for nfs_mount in $nfs_mountpoints
84 echo -e "\t[$cnt] $nfs_mount"
90 while test -z "$selection"
93 echo -n "Boot NFS root: "
97 for nfs_mount in $nfs_mounts
99 if test "$junk" = "$cnt"
101 selection="$nfs_mount"
108 test -z "$nfs_mounts" && die "No NFS mounts configured in /etc/fstab!"
109 selection="$nfs_mounts"
112 mkdir -p /media/nfsroot || die "mkdir -p /media/nfsroot failed!"
114 echo -n "Mounting NFS root..."
115 mount -t nfs "$selection" /media/nfsroot && echo ok || die "mount -t nfs "$selection" /media/nfsroot failed!"
117 # Use configured resolv.conf in the pivoted rootfs
118 echo -n "Copying resolv.conf..."
119 #cp /etc/resolv.conf /media/nfsroot/etc && echo ok || echo "FAILED"
121 check_target "/media/nfsroot"
126 title) echo "$M_TITLE";;
127 run) run_module "$2";;