#!/bin/bash # $HeadURL$ $LastChangedRevision$ # Properties MY_ID=system_boot_net_pxe PARENT_ID=system_boot_net MY_PRIVATE_ATTRIBUTES="uname status" MY_PUBLIC_ATTRIBUTES= MY_ATTRIBUTES="$MY_PRIVATE_ATTRIBUTES $MY_PUBLIC_ATTRIBUTES" MY_HELPER_IDS= for MY_ATTRIBUTE in ${MY_ATTRIBUTES^^}; do eval "$MY_ATTRIBUTE="; done # Defaults for the questions we ask (should only used here) # Hooks create_prologue() { # my attributes inherit MY_ATTRIBUTES ${MY_ATTRIBUTES^^} # those inherited attributes i will use inherit RELEASE ARCH KERNEL_COMMANDLINE MACADDR # real local local TFTP_ROOTDIR # make sure MODROOT is set inherit MODROOT # Sanity checks and derivations helper_sanity_checks_and_derivations # Guts info "creating PXE config file ..." { echo "default linux" echo "prompt 0" echo "timeout 30" echo echo "label linux" echo " kernel pxe-images/linux_$RELEASE-$ARCH" # Beware that these kernel command line arguments are also in vm-editor (where # they are only used for PVs, though the netcfg/dhcp_timeout is really only for # PVs which get to doing an DHCP request so much faster) echo " append ipv6.disable=1 initrd=pxe-images/initrd.gz_$RELEASE-$ARCH $KERNEL_COMMANDLINE" } > $TFTP_ROOTDIR/pxelinux.cfg/01-${MACADDR//:/-} # Update /srv/tftp/pxe-images (it will not accept a symlink to ~/opt/mdi/lib/pxe-images # and I'm always forgetting that, having updated an image in ~/opt/mdi/lib/pxe-images # that that's not enough). rsync -a --delete $MODROOT/lib/pxe-images/ $TFTP_ROOTDIR/pxe-images/ return 0 } delete_epilogue() { # my attributes inherit MY_ATTRIBUTES ${MY_ATTRIBUTES^^} # those inherited attributes i will use inherit MACADDR # real local local TFTP_ROOTDIR # Sanity checks and derivations helper_sanity_checks_and_derivations # Guts info "deleting PXE config file ..." # rememeber, delete functions are not allowed to fail; hence -f RM_OUTPUT=$(rm -f $TFTP_ROOTDIR/pxelinux.cfg/01-${MACADDR//:/-} 2>&1) || warning "rm: failed (output was: $RM_OUTPUT)" return 0 } list_prologue() { # list functions do not use attributes # real local local UNAMES TFTP_ROOTDIR # Sanity checks and derivations helper_sanity_checks_and_derivations # Fake guts - to be removed UNAMES=$($SQLITE_CMD $DB_FILE "select group_concat(uname,' ') from attribute_values where helper == '$MY_ID' and attribute == 'status' and value == 'installing';") debug 10 "list_prologue: the following hosts are marked installing: $UNAMES" # Guts echo "PXE config files" echo "================" echo ls -l $TFTP_ROOTDIR/pxelinux.cfg/01-* 2>/dev/null || true echo } # Support functions helper_sanity_checks_and_derivations() { # we will set this for the caller inherit TFTP_ROOTDIR # real local local TFTPSERVER_RELEASE # Sanity checks and derivations debug 10 "helper_sanity_checks_and_derivations: checking what TFTP root is ..." get_release_by_inspection TFTPSERVER_RELEASE || return $? # Guts case $TFTPSERVER_RELEASE in lenny) TFTP_ROOTDIR=/var/lib/tftpboot ;; squeeze) TFTP_ROOTDIR=/srv/tftp ;; wheezy) TFTP_ROOTDIR=/srv/tftp ;; *) internal "$TFTPSERVER_RELEASE: unhandled" ;; esac }