#!/bin/bash #hosts="cluster1 cluster2 cluster3 cluster4 lic sanchoplan stereovideowall stereovideofloor video loadingapp" hosts="testmachine" pxeconfdir="/var/lib/tftpboot/pxelinux.cfg" scriptpath="/srv/scripts" # check for configfile if [ -d $pxeconfdir ]; then if [ -r $pxeconfdir/default ]; then echo "default pxe config exists and is readable" else echo "default pxe config does not exist" # create default pxe config echo "creating config" cp $scriptpath/tftpboot_default $pxeconfdir/default fi else echo "there is no $pxeconfdir" echo "are you sure you're running this script on your pxe server" echo "exiting" exit 1 fi # cleaning up any previous mac address config files in pxeconfdir echo "cleaning up previous mac address configurations in $pxeconfdir" rm $pxeconfdir/00-* &> /dev/null # starting actual backup process set -- $hosts for var in "$@"; do echo "starting backup of $var" # get mac for pxe config macstring=$(cat $scriptpath/mac2hostname.lst | grep $var) mac=${macstring:0:17} correctmac="${mac//:/-}" echo "mac of $var is $correctmac" # create pxc config for $var cp $scriptpath/tftpboot_mac $pxeconfdir/01-$correctmac # remote reboot echo "making the actual reboot of $var" ssh -l Administrator $var shutdown -f -r -t 05 # sleep for 15 minutes echo "sleeping for 10 minutes" sleep 600 # remove temp pxe config for $var echo "removing mac address configurations in $pxeconfdir" rm $pxeconfdir/01-$correctmac done # end of script echo "end of script, exiting" exit 0