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 $3 }' | 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 [ ! -d ./fai ] ; then
31 echo "creating fai directory"
35 if [ ! -f ./fai/nfsroot-packages ] ; then
36 echo "storing $hdw_target as original target"
37 hdw_orig_target=$hdw_target
39 echo "pretending default target for nfsroot install now"
40 export hdw_target=default
42 ./scripts/Helper -create_dist_files
44 export hdw_target=$hdw_orig_target
45 echo "orig target restored to $hdw_target"
47 cp ./distro/default ./fai/nfsroot-packages
50 echo "deleting some packages from list now"
51 del="linux-libc-headers man-pages binutils gcc m4 autoconf automake"
52 del="$del man make patch bin86 nasm lilo cvs"
53 del="$del bootdisk" # just by now - may contain kernel image later
54 for package in $del; do
55 grep -v ^$package ./fai/nfsroot-packages > ./fai/tmp~
56 mv ./fai/tmp~ ./fai/nfsroot-packages
59 if [ ! -f $fairoot/packages_installed ] ; then
60 echo "creating nfsroot..."
61 chmod 755 ./misc/hdw-tools/hdw-get
62 ./misc/hdw-tools/hdw-get dist-install $fairoot ./fai/nfsroot-packages
63 touch $fairoot/packages_installed
66 echo "nfsroot seems to be available already"
67 echo "(del $fairoot/packages_installed to recreate it)"
71 echo "preparing nfsroot for automated install routine ..."
75 mknod -m 0666 dev/null c 1 3
76 mknod -m 0600 dev/console c 5 1
78 grep -v swap etc/fstab > tmp~
81 for i in sysklogd network inetd nscd; do
82 rm -f etc/init.d/rc2.d/*${i}
89 echo "checking pxe/nfs environment ..."
91 cp $fairoot/boot/vmlinuz_hdw /tftpboot
92 if [ ! -f /tftpboot/pxelinux.0 ] ; then
93 if [ ! -f /usr/lib/syslinux/pxelinux.0 ] ; then
94 echo "pxelinux (syslinux) not found, fix this manually now :p"
96 cp /usr/lib/syslinux/pxelinux.0 /tftpboot
98 mkdir -p /tftpboot/pxelinux.cfg
99 echo -e "LABEL fai" > /tftpboot/pxelinux.cfg/fai
100 echo -e "\tKERNEL vmlinuz_hdw" >> /tftpboot/pxelinux.cfg/fai
101 echo -e "\tAPPEND root=/dev/nfs nfsroot=$myip:$fairoot \\" >> \
102 /tftpboot/pxelinux.cfg/fai
103 echo -e "\tip=dhcp" >> /tftpboot/pxelinux.cfg/fai
104 echo -e "\tPROMPT 1" >> /tftpboot/pxelinux.cfg/fai
105 echo -e "$fairoot\tfoobar(async,ro,no_root_squash)" >> /etc/exports
107 echo "mounting configuration dir to nfsroot export ..."
108 mkdir -p $fairoot/fai-config
109 mount --bind $PWD/fai $fairoot/fai-config
111 echo "everything should work now. now do the following:"
112 echo "1) edit /etc/exports to allow your clients to mount the nfsroot"
113 echo "2) link the ipaddr in hex of the client to fai in pxe config dir"
114 echo "3) tell your dhcpd (see syslinux docs for more help)"
115 echo "4) make sure inetd/nfs/dhcpd are up running"
116 echo "5) do the configuration stuff (see doc/FAI)"
118 echo "note: tftp must support tsize option (use e.g. tftp-hpa package)