new stack trace, linode fixes, minor improvements
[automated-distro-installer] / pxe-server
index 6137386a1188d9ab9c50e4bee783e7ee57dfc053..07262fca9a70a2cf3036def43eb76fb470794b64 100755 (executable)
@@ -61,6 +61,11 @@ EOF
   exit $1
 }
 
+pre="${0##*/}:"
+m() { printf "$pre %s\n"  "$*"; "$@"; }
+e() { printf "$pre %s\n"  "$*"; }
+err() { echo "[$(date +'%Y-%m-%d %H:%M:%S%z')]: $pre: $*" >&2; }
+
 ##### begin command line parsing ########
 
 dhcp=true
@@ -70,7 +75,7 @@ wait=false
 fsf=false
 
 case $HOSTNAME in
-  x2|x3|kw) fsf=true ;;
+  x2|kw) fsf=true ;;
 esac
 
 chboot_args=()
@@ -125,11 +130,6 @@ fi
 
 ##### end command line parsing ########
 
-e() {
-  echo "$@"
-  "$@"
-}
-
 archlike() {
   cat <<EOF
 dhcp-option-force=209,boot/syslinux/${type}iso.cfg
@@ -174,28 +174,28 @@ ack-wait() {
       echo $line
     fi
   done < <($wait_cmd ||:) # tail returns 2 it seems
-  e sleep 20
+  m sleep 20
 }
 
 set-pxe() {
   $dhcp || return 0
   if $fsf; then
     if [[ ! $cmd ]]; then
-      echo "$0: removing pxe for $host on tarantula"
+      e "removing pxe for $host on tarantula"
       ssh tarantula bash -e <<EOF
 sed -ri 's/^( *host +$host *\{).*/\1/' /etc/dhcp3/dhcpd.conf
 /etc/init.d/dhcp3-server restart
 EOF
     elif [[ $cmd == fai ]]; then
-      echo "$0: adding pxe for $host on tarantula"
+      e "adding pxe for $host on tarantula"
       ssh tarantula bash -e <<EOF
 sed -ri 's/^( *host +$host *\{).*/\1 next-server faiserver.office.fsf.org; filename "pxelinux.0";/' /etc/dhcp3/dhcpd.conf
 /etc/init.d/dhcp3-server restart
 EOF
     fi
   else
-    echo "$0: updating dnsmasq.conf:"
-    $cmd
+    e "updating dnsmasq.conf:"
+    $cmd
     ${cmd:-:}|ssh wrt "cedit pxe /etc/dnsmasq.conf || /etc/init.d/dnsmasq restart
 $([[ $type == arch || $type == parabola ]] && echo archlike-pxe-mount)"
   fi
@@ -205,9 +205,9 @@ $([[ $type == arch || $type == parabola ]] && echo archlike-pxe-mount)"
 if $set; then
   set-pxe
   if [[ $type == fai ]]; then
-    e myfai-chboot ${chboot_args[@]} $host
+    m myfai-chboot ${chboot_args[@]} $host
     if $redep; then
-      e fai-redep
+      m fai-redep
     fi
   else
     # This will fail if faiserver is not setup, so ignore any