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 echo "tcp_wrappers" >> ./fai/nfsroot-packages
71 [ "$hdw_arch" = "ia32" ] && echo "lilo" >> ./fai/nfsroot-packages
74 if [ ! -f $fairoot/packages_installed ] ; then
75 echo "creating nfsroot..."
76 chmod 755 ./misc/hdw-tools/hdw-get
77 ./misc/hdw-tools/hdw-get dist-install $fairoot ./fai/nfsroot-packages
78 touch $fairoot/packages_installed
81 echo "nfsroot seems to be available already"
82 echo "(del $fairoot/packages_installed to recreate it)"
85 if [ ! -f $fairoot/prepared_nfsroot ] ; then
86 echo "preparing nfsroot for automated install routine ..."
88 # special files (null & console)
89 [ ! -c dev/null ] && mknod -m 0666 dev/null c 1 3
90 [ ! -c dev/console ] && mknod -m 0600 dev/console c 5 1
92 cp $home_dir/misc/sysfiles/etc/fstab ./etc
93 # the target directory
95 # dir for mounting fai config
97 # removing some services
98 for i in sysklogd network inetd nscd; do
99 rm -f etc/init.d/rc2.d/*${i}
101 # modified inittab, rc and bootscript
102 sed "s%| /sbin/btee .*%%g" $home_dir/packages/base/sysvinit/inittab > \
104 cp $home_dir/misc/fai/fai_boot ./etc/init.d/boot
105 sed "s%^FAI_MOUNT_LINE%mount -tnfs $myip:/$home_dir/fai /fai%" \
106 $home_dir/misc/fai/fai_rc > etc/init.d/rc
107 chmod 755 etc/init.d/rc
108 # modify hdw-get.conf
109 sed "s%hdw_arch_opt=.*%hdw_arch_opt=$hdw_arch_opt%" etc/hdw-get.conf > \
111 mv tmp~ etc/hdw-get.conf
112 # get to home_dir again
115 touch $fairoot/prepared_nfsroot
117 echo "nfsroot seems to be prepared already"
118 echo "(del $fairoot/prepared_nfsroot to recreate it)"
121 echo "checking pxe/nfs environment ..."
123 cp $fairoot/boot/vmlinuz_hdw /tftpboot
124 if [ ! -f /tftpboot/pxelinux.0 ] ; then
125 if [ ! -f /usr/lib/syslinux/pxelinux.0 ] ; then
126 echo "pxelinux (syslinux) not found, fix this manually now :p"
128 cp /usr/lib/syslinux/pxelinux.0 /tftpboot
130 mkdir -p /tftpboot/pxelinux.cfg
131 cat > /tftpboot/pxelinux.cfg/fai << EOF
138 APPEND root=/dev/nfs nfsroot=$myip:$fairoot ip=dhcp
143 echo -e "$fairoot\tfoobar(async,ro,no_root_squash)" >> /etc/exports
144 echo -e "$home_dir/fai\tfoobar(async,ro,no_root_squash)" >> /etc/exports
146 echo "everything should work now. now do the following:"
147 echo "1) edit /etc/exports to allow your clients to mount the nfsroot"
148 echo "2) link the ipaddr in hex of the client to fai in pxe config dir"
149 echo "3) tell your dhcpd (see syslinux docs for more help)"
150 echo "4) make sure inetd/nfs/dhcpd are up running"
151 echo "5) do the configuration stuff (see doc/FAI)"
152 echo "6) adapt the hdw-get.conf file in the fai nfsroot tree"
154 echo "note: tftp must support tsize option (use e.g. tftp-hpa package)"