3 # author: hackbard@hackdaworld.dyndns.org
5 # script creating a minimal system nfsroot for automated installation of hdw
12 [ "$2" ] && iface="$2"
14 myip="`ifconfig $iface | grep inet\ addr | awk '{ print $2 }' | awk -F: '{ print $2 }'`"
16 if [ -z $myip ] ; then
17 echo "unable to figure out your ip addr."
18 echo "pls specify the network interface."
20 echo "example: $0 $1 br0"
28 echo "$0 <fai-root> [<network interface>]"
33 [ "$#" -lt "1" ] && usage
34 [ ! -d $fairoot ] && usage
36 echo "reading config ..."
37 if [ ! -f ./Config ] ; then
38 echo "config file not found, aborting"
43 if [ ! -f ./fai/nfsroot-packages ] ; then
44 echo "storing $hdw_target as original target"
45 hdw_orig_target=$hdw_target
47 echo "pretending default target for nfsroot install now"
48 export hdw_target=default
49 echo "hdw_target=default # FAI_WAS_HERE" >> Config # dirty!
51 ./scripts/Helper -create_dist_files
53 export hdw_target=$hdw_orig_target
54 grep -v '# FAI_WAS_HERE' Config > tmp~
56 echo "orig target restored to $hdw_target"
58 cp ./distro/default ./fai/nfsroot-packages
60 echo "deleting some packages from list now"
61 del="linux-libc-headers man-pages binutils gcc m4 autoconf automake"
62 del="$del man make patch bin86 nasm lilo cvs devfsd"
63 del="$del bootdisk" # just by now - may contain kernel image later
64 for package in $del; do
65 grep -v ^$package ./fai/nfsroot-packages > ./fai/tmp~
66 mv ./fai/tmp~ ./fai/nfsroot-packages
68 echo "adding needed packages to list now"
69 echo "portmap" >> ./fai/nfsroot-packages
70 [ "$hdw_arch" = "ia32" ] && echo "lilo" >> ./fai/nfsroot-packages
73 if [ ! -f $fairoot/packages_installed ] ; then
74 echo "creating nfsroot..."
75 chmod 755 ./misc/hdw-tools/hdw-get
76 ./misc/hdw-tools/hdw-get dist-install $fairoot ./fai/nfsroot-packages
77 touch $fairoot/packages_installed
80 echo "nfsroot seems to be available already"
81 echo "(del $fairoot/packages_installed to recreate it)"
84 if [ ! -f $fairoot/prepared_nfsroot ] ; then
85 echo "preparing nfsroot for automated install routine ..."
87 # special files (null & console)
88 [ ! -c dev/null ] && mknod -m 0666 dev/null c 1 3
89 [ ! -c dev/console ] && mknod -m 0600 dev/console c 5 1
91 cp $home_dir/misc/sysfiles/etc/fstab ./etc
92 # the target directory
94 # dir for mounting fai config
96 # removing some services
97 for i in sysklogd network inetd nscd; do
98 rm -f etc/init.d/rc2.d/*${i}
100 # modified inittab, rc and bootscript
101 sed "s%| /sbin/btee .*%%g" $home_dir/packages/base/sysvinit/inittab > \
103 cp $home_dir/misc/fai/fai_boot ./etc/init.d/boot
104 sed "s%^FAI_MOUNT_LINE%mount -tnfs $myip:/$home_dir/fai /fai%" \
105 $home_dir/misc/fai/fai_rc > etc/init.d/rc
106 chmod 755 etc/init.d/rc
107 # modify hdw-get.conf
108 sed "s%hdw_arch_opt=.*%hdw_arch_opt=$hdw_arch_opt%" etc/hdw-get.conf > \
110 mv tmp~ etc/hdw-get.conf
111 # get to home_dir again
114 touch $fairoot/prepared_nfsroot
116 echo "nfsroot seems to be prepared already"
117 echo "(del $fairoot/prepared_nfsroot to recreate it)"
120 echo "checking pxe/nfs environment ..."
122 cp $fairoot/boot/vmlinuz_hdw /tftpboot
123 if [ ! -f /tftpboot/pxelinux.0 ] ; then
124 if [ ! -f /usr/lib/syslinux/pxelinux.0 ] ; then
125 echo "pxelinux (syslinux) not found, fix this manually now :p"
127 cp /usr/lib/syslinux/pxelinux.0 /tftpboot
129 mkdir -p /tftpboot/pxelinux.cfg
130 cat > /tftpboot/pxelinux.cfg/fai << EOF
137 APPEND root=/dev/nfs nfsroot=$myip:$fairoot ip=dhcp
142 echo -e "$fairoot\tfoobar(async,ro,no_root_squash)" >> /etc/exports
143 echo -e "$home_dir/fai\tfoobar(async,ro,no_root_squash)" >> /etc/exports
145 echo "everything should work now. now do the following:"
146 echo "1) edit /etc/exports to allow your clients to mount the nfsroot"
147 echo "2) link the ipaddr in hex of the client to fai in pxe config dir"
148 echo "3) tell your dhcpd (see syslinux docs for more help)"
149 echo "4) make sure inetd/nfs/dhcpd are up running"
150 echo "5) do the configuration stuff (see doc/FAI)"
152 echo "note: tftp must support tsize option (use e.g. tftp-hpa package)"