X-Git-Url: https://hackdaworld.org/gitweb/?p=hdw-linux%2Fhdw-linux.git;a=blobdiff_plain;f=scripts%2FCreate-FAI;h=b013db46e54d9e952b2aa289b43727e2e1b259e4;hp=cc3e6e6b71c5d64181d8fd1203600bf6c556a126;hb=4dfe4bc90c6670e31d52449b3294467e879eda28;hpb=5ec575d2b0a8b430079f5dd375565fd99876db19 diff --git a/scripts/Create-FAI b/scripts/Create-FAI index cc3e6e6..b013db4 100755 --- a/scripts/Create-FAI +++ b/scripts/Create-FAI @@ -5,18 +5,153 @@ # script creating a minimal system nfsroot for automated installation of hdw # +home_dir=$PWD fairoot="$1" +iface="eth0" + +[ "$2" ] && iface="$2" + +myip="`ifconfig $iface | grep inet\ addr | awk '{ print $2 }' | awk -F: '{ print $2 }'`" + +if [ -z $myip ] ; then + echo "unable to figure out your ip addr." + echo "pls specify the network interface." + echo + echo "example: $0 $1 br0" + echo + exit +fi usage() { echo echo "usage:" - echo "$1 " + echo "$0 []" echo exit } -if [ ! -d $fairoot -o ] ; then - usage +[ "$#" -lt "1" ] && usage +[ ! -d $fairoot ] && usage + +echo "reading config ..." +if [ ! -f ./Config ] ; then + echo "config file not found, aborting" + exit fi +. ./Config + +if [ ! -f ./fai/nfsroot-packages ] ; then + echo "storing $hdw_target as original target" + hdw_orig_target=$hdw_target + + echo "pretending default target for nfsroot install now" + export hdw_target=default + echo "hdw_target=default # FAI_WAS_HERE" >> Config # dirty! + + ./scripts/Helper -create_dist_files + + export hdw_target=$hdw_orig_target + grep -v '# FAI_WAS_HERE' Config > tmp~ + mv tmp~ Config + echo "orig target restored to $hdw_target" + + cp ./distro/default ./fai/nfsroot-packages + + echo "deleting some packages from list now" + del="linux-libc-headers man-pages binutils gcc m4 autoconf automake" + del="$del man make patch bin86 nasm lilo cvs devfsd" + del="$del bootdisk" # just by now - may contain kernel image later + for package in $del; do + grep -v ^$package ./fai/nfsroot-packages > ./fai/tmp~ + mv ./fai/tmp~ ./fai/nfsroot-packages + done + echo "adding needed packages to list now" + echo "portmap" >> ./fai/nfsroot-packages + echo "tcp_wrappers" >> ./fai/nfsroot-packages + [ "$hdw_arch" = "ia32" ] && echo "lilo" >> ./fai/nfsroot-packages +fi + +if [ ! -f $fairoot/packages_installed ] ; then + echo "creating nfsroot..." + chmod 755 ./misc/hdw-tools/hdw-get + ./misc/hdw-tools/hdw-get dist-install $fairoot ./fai/nfsroot-packages + touch $fairoot/packages_installed + echo "done" +else + echo "nfsroot seems to be available already" + echo "(del $fairoot/packages_installed to recreate it)" +fi + +if [ ! -f $fairoot/prepared_nfsroot ] ; then + echo "preparing nfsroot for automated install routine ..." + cd $fairoot + # special files (null & console) + [ ! -c dev/null ] && mknod -m 0666 dev/null c 1 3 + [ ! -c dev/console ] && mknod -m 0600 dev/console c 5 1 + # fstab + cp $home_dir/misc/sysfiles/etc/fstab ./etc + # the target directory + mkdir -p ./trg + # dir for mounting fai config + mkdir -p fai + # removing some services + for i in sysklogd network inetd nscd; do + rm -f etc/init.d/rc2.d/*${i} + done + # modified inittab, rc and bootscript + sed "s%| /sbin/btee .*%%g" $home_dir/packages/base/sysvinit/inittab > \ + etc/inittab + cp $home_dir/misc/fai/fai_boot ./etc/init.d/boot + sed "s%^FAI_MOUNT_LINE%mount -tnfs $myip:/$home_dir/fai /fai%" \ + $home_dir/misc/fai/fai_rc > etc/init.d/rc + chmod 755 etc/init.d/rc + # modify hdw-get.conf + sed "s%hdw_arch_opt=.*%hdw_arch_opt=$hdw_arch_opt%" etc/hdw-get.conf > \ + tmp~ + mv tmp~ etc/hdw-get.conf + # get to home_dir again + cd $home_dir + echo "done" + touch $fairoot/prepared_nfsroot +else + echo "nfsroot seems to be prepared already" + echo "(del $fairoot/prepared_nfsroot to recreate it)" +fi + +echo "checking pxe/nfs environment ..." +mkdir -p /tftpboot +cp $fairoot/boot/vmlinuz_hdw /tftpboot +if [ ! -f /tftpboot/pxelinux.0 ] ; then + if [ ! -f /usr/lib/syslinux/pxelinux.0 ] ; then + echo "pxelinux (syslinux) not found, fix this manually now :p" + fi + cp /usr/lib/syslinux/pxelinux.0 /tftpboot +fi +mkdir -p /tftpboot/pxelinux.cfg +cat > /tftpboot/pxelinux.cfg/fai << EOF +PROMPT 1 +DEFAULT disk +TIMEOUT 200 + +LABEL fai + KERNEL vmlinuz_hdw + APPEND root=/dev/nfs nfsroot=$myip:$fairoot ip=dhcp + +LABEL disk + LOCALBOOT 0 +EOF +echo -e "$fairoot\tfoobar(async,ro,no_root_squash)" >> /etc/exports +echo -e "$home_dir/fai\tfoobar(async,ro,no_root_squash)" >> /etc/exports + +echo "everything should work now. now do the following:" +echo "1) edit /etc/exports to allow your clients to mount the nfsroot" +echo "2) link the ipaddr in hex of the client to fai in pxe config dir" +echo "3) tell your dhcpd (see syslinux docs for more help)" +echo "4) make sure inetd/nfs/dhcpd are up running" +echo "5) do the configuration stuff (see doc/FAI)" +echo "6) adapt the hdw-get.conf file in the fai nfsroot tree" +echo +echo "note: tftp must support tsize option (use e.g. tftp-hpa package)" +echo -echo "preparing +echo "done"