3 # author: hackbard@hackdaworld.dyndns.org
5 # script creating a minimal system nfsroot for automated installation of hdw
9 myip="`ifconfig eth0 | grep inet\ addr | awk '{ print $2 }' | awk -F: '{ print $2 }'`"
20 [ "$#" != "1" ] && usage
21 [ ! -d $fairoot ] && usage
23 echo "reading config ..."
24 if [ ! -f ./Config ] ; then
25 echo "config file not found, aborting"
30 if [ ! -f ./fai/nfsroot-packages ] ; then
31 echo "storing $hdw_target as original target"
32 hdw_orig_target=$hdw_target
34 echo "pretending default target for nfsroot install now"
35 export hdw_target=default
37 ./scripts/Helper -create_dist_files
39 export hdw_target=$hdw_orig_target
40 echo "orig target restored to $hdw_target"
42 cp ./distro/default ./fai/nfsroot-packages
45 echo "deleting some packages from list now"
46 del="linux-libc-headers man-pages binutils gcc m4 autoconf automake"
47 del="$del man make patch bin86 nasm lilo cvs"
48 del="$del bootdisk" # just by now - may contain kernel image later
49 for package in $del; do
50 grep -v ^$package ./fai/nfsroot-packages > ./fai/tmp~
51 mv ./fai/tmp~ ./fai/nfsroot-packages
54 if [ ! -f $fairoot/packages_installed ] ; then
55 echo "creating nfsroot..."
56 chmod 755 ./misc/hdw-tools/hdw-get
57 ./misc/hdw-tools/hdw-get dist-install $fairoot ./fai/nfsroot-packages
58 touch $fairoot/packages_installed
61 echo "nfsroot seems to be available already"
62 echo "(del $fairoot/packages_installed to recreate it)"
65 if [ ! -f $fairoot/prepared_nfsroot ] ; then
66 echo "preparing nfsroot for automated install routine ..."
68 mknod -m 0666 dev/null c 1 3
69 mknod -m 0600 dev/console c 5 1
70 grep -v swap etc/fstab > tmp~
73 for i in sysklogd network inetd nscd; do
74 rm -f etc/init.d/rc2.d/*${i}
76 sed "s%^exit\ 0%mount -tnfs $myip:/$home_dir/fai /fai%" \
79 chmod 755 etc/init.d/rc
80 echo "/fai/scripts/rc_fai.sh" >> etc/init.d/rc
81 echo "shutdown -r now" >> etc/init.d/rc
84 touch $fairoot/prepared_nfsroot
87 echo "checking pxe/nfs environment ..."
89 cp $fairoot/boot/vmlinuz_hdw /tftpboot
90 if [ ! -f /tftpboot/pxelinux.0 ] ; then
91 if [ ! -f /usr/lib/syslinux/pxelinux.0 ] ; then
92 echo "pxelinux (syslinux) not found, fix this manually now :p"
94 cp /usr/lib/syslinux/pxelinux.0 /tftpboot
96 mkdir -p /tftpboot/pxelinux.cfg
97 echo -e "LABEL fai" > /tftpboot/pxelinux.cfg/fai
98 echo -e "\tKERNEL vmlinuz_hdw" >> /tftpboot/pxelinux.cfg/fai
99 echo -e "\tAPPEND root=/dev/nfs nfsroot=$myip:$fairoot ip=dhcp" >> \
100 /tftpboot/pxelinux.cfg/fai
101 echo -e "\tPROMPT 1" >> /tftpboot/pxelinux.cfg/fai
102 echo -e "$fairoot\tfoobar(async,ro,no_root_squash)" >> /etc/exports
103 echo -e "$home_dir/fai\tfoobar(async,ro,no_root_squash)" >> /etc/exports
105 echo "everything should work now. now do the following:"
106 echo "1) edit /etc/exports to allow your clients to mount the nfsroot"
107 echo "2) link the ipaddr in hex of the client to fai in pxe config dir"
108 echo "3) tell your dhcpd (see syslinux docs for more help)"
109 echo "4) make sure inetd/nfs/dhcpd are up running"
110 echo "5) do the configuration stuff (see doc/FAI)"
112 echo "note: tftp must support tsize option (use e.g. tftp-hpa package)"