]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/altboot/files/spitz/altboot-menu/Advanced/40-bootNFS
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / altboot / files / spitz / altboot-menu / Advanced / 40-bootNFS
1 # !/bin/sh
2 #
3 # Copyright Matthias Hentges (c) 2005
4 #
5 # License: GPL (see http://www.gnu.org/licenses/gpl.txt for a copy of the GPL)
6
7 # FIXME: Make this work
8
9 M_TITLE="Boot from NFS"
10
11 die() {
12         echo "ERROR: $1" >/dev/tty0
13         exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
14 }
15
16 # This function is activated by init.altboot by calling this script with the "run" option
17 run_module() {
18
19         test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!"
20
21         echo -n "Mounting rootfs rw..." >/dev/tty0
22         mount -o remount,rw / >/dev/tty0 2>&1 && echo ok  >/dev/tty0|| die "mount -o remount,rw / failed"
23
24         echo -n "Generating device files..." >/dev/tty0
25         /etc/init.d/devices start && echo ok  >/dev/tty0|| die "FAILED" 
26
27         echo -n "Mounting /proc..." >/dev/tty0
28         mount /proc >/dev/tty0 2>&1 && echo ok  >/dev/tty0 || echo failed
29
30         # Needed for NFS
31         /etc/init.d/portmap start >/dev/tty1 2>&1 || die "/etc/init.d/portmap start failed!"
32         
33         # For some reason NFS mounts hang if /e/i/networking is not run.
34         # For the time beeing I'm to lazy to investigate ;)
35         /etc/init.d/networking start || die "/etc/init.d/networking start failed!"
36         
37         sleep 2
38         
39         # After the PCMCIA service is started, an inserted WLAN card should automatically
40         # activate itself.
41         /etc/init.d/pcmcia start || die "/etc/init.d/pcmcia/start failed!"
42         
43         # Give WLAN time to login into the network
44         echo "Waiting for WLAN..."
45         sleep 8
46                  
47         nfs_mounts="`cat /etc/fstab | grep -v ^# | grep nfs | awk '{print $1}'`"
48         nfs_mountpoints="`cat /etc/fstab | grep -v ^# | grep nfs | awk '{print $2}'`"   
49         
50         if test "` echo "$nfs_mountpoints" |wc -l | tr -d " "`" -gt 1
51         then
52                 echo -e "Please select your NFS root:\n"
53
54                 cnt=1
55                 for nfs_mount in $nfs_mountpoints
56                 do
57                         echo -e "\t[$cnt] $nfs_mount"
58                         let cnt=$cnt+1
59                 done
60                 
61                 echo ""
62                 
63                 while test -z "$selection"
64                 do
65                         echo -n "Boot NFS root: "
66                         read junk < /dev/tty1
67                         
68                         cnt=1
69                         for nfs_mount in $nfs_mounts
70                         do
71                                 if test "$junk" = "$cnt"
72                                 then
73                                         selection="$nfs_mount"
74                                 fi
75                                 let cnt=$cnt+1
76                         done                    
77                         
78                 done
79         else
80                 test -z "$nfs_mounts" && die "No NFS mounts configured in /etc/fstab!"  
81                 selection="$nfs_mounts"
82         fi
83         
84         mkdir -p /media/nfsroot || die "mkdir -p /media/nfsroot failed!"
85         
86         echo -n "Mounting NFS root..."
87         mount -t nfs "$selection" /media/nfsroot && echo ok || die "mount -t nfs "$selection" /media/nfsroot failed!"
88         
89         check_target "/media/nfsroot"
90         
91 }       
92
93 case "$1" in
94 title)  echo "$M_TITLE";;
95 run)    run_module "$2";;
96 esac
97