#!/bin/bash # # author: hackbard@hackdaworld.dyndns.org # # script creating a minimal system nfsroot for automated installation of hdw # fairoot="$1" myip="`ifconfig eth0 | grep inet\ addr | awk '{ print $3 }' | awk -F: '{ print $2 }'`" home_dir=$PWD usage() { echo echo "usage:" echo "$0 " echo exit } [ "$#" != "1" ] && usage [ ! -d $fairoot ] && usage echo "reading config ..." if [ ! -f ./Config ] ; then echo "config file not found, aborting" exit fi . ./Config if [ ! -d ./fai ] ; then echo "creating fai directory" mkdir ./fai fi 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 ./scripts/Helper -create_dist_files export hdw_target=$hdw_orig_target echo "orig target restored to $hdw_target" cp ./distro/default ./fai/nfsroot-packages fi 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" 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 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 echo "preparing nfsroot for automated install routine ..." cd $fairoot mknod -m 0666 dev/null c 1 3 mknod -m 0600 dev/console c 5 1 grep -v swap etc/fstab > tmp~ mv tmp~ etc/fstab for i in sysklogd network inetd nscd; do rm -f etc/init.d/rc2.d/*${i} done cd $home_dir echo "done" 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 echo -e "LABEL fai" > /tftpboot/pxelinux.cfg/fai echo -e "\tKERNEL vmlinuz_hdw" >> /tftpboot/pxelinux.cfg/fai echo -e "\tAPPEND root=/dev/nfs nfsroot=$myip:$fairoot \\" >> \ /tftpboot/pxelinux.cfg/fai echo -e "\tip=dhcp" >> /tftpboot/pxelinux.cfg/fai echo -e "\tPROMPT 1" >> /tftpboot/pxelinux.cfg/fai echo -e "$fairoot\tfoobar(async,ro,no_root_squash)" >> /etc/exports echo "mounting configuration dir to nfsroot export ..." mkdir -p $fairoot/fai-config mount --bind $PWD/fai $fairoot/fai-config 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 echo "note: tftp must support tsize option (use e.g. tftp-hpa package) echo echo "done"