add host
[automated-distro-installer] / pxe-server
index e59854a85e466be75cbad22733ded83cae6c077e..a3df1a5953846368397e9b335be844970b132771 100755 (executable)
@@ -45,12 +45,14 @@ ln -s <arch/debian iso dir> tftpboot
 
 -r         Don't redeploy fai config. For example, if there is a different host
            that is mid-install.
--a         Wait for 2 dhcp acks, then disable the pxe server after a delay.
-           First ack is for pxe boot, 2nd ack is for os boot. Sometimes
-           on debian, there is a 3rd one shortly after the 2nd. I can't remember
-           exactly why this caused a problem, but I'm hoping the sleep
-           will take care of it.
--w         Initially setup pxe, then wait like -a.
+
+-a         Don't setup pxe, just Wait for 2 dhcp acks, then disable the pxe
+           server after a delay.  First ack is for pxe boot, 2nd ack is
+           for os boot. Sometimes on debian, there is a 3rd one shortly
+           after the 2nd. I can't remember exactly why this caused a
+           problem, but I'm hoping the sleep will take care of it.
+
+-w         Setup pxe, then wait like -a.
 -h|--help  Print help and exit
 
 
@@ -61,7 +63,6 @@ EOF
 
 ##### begin command line parsing ########
 
-args=()
 redep=true
 acks=2
 wait=false
@@ -78,7 +79,7 @@ while true; do
     esac
 done
 
-read host type <<<"$@"
+read -r host type <<<"$@"
 
 case $# in
     0|2);;
@@ -118,7 +119,6 @@ EOF
 
 fai() {
     cat <<EOF
-$set_host_tag
 dhcp-boot=${host_tag}pxelinux.0,faiserver.lan,faiserver.lan
 EOF
 }
@@ -130,8 +130,7 @@ ack-wait() {
     fi
     regex=".*DHCPACK.*$host_regex$"
     i=0
-    tmp=$(mktemp)
-    while (( i != wait_count )) && read line; do
+    while (( i != wait_count )) && read -r line; do
         if [[ $line =~ $regex ]]; then
             i=$((i+1))
             echo $line
@@ -154,7 +153,9 @@ if $set; then
             e fai-redep
         fi
     else
-        e myfai-chboot
+        # This will fail if faiserver is not setup, so ignore any
+        # failure and don't bother us about it.
+        myfai-chboot &>/dev/null ||:
     fi
 fi