fix some minor bugs
[automated-distro-installer] / myfai-chboot-local
index c990fdf39456b179549bab45ebe0d8e28f1f31f3..58babc14c750e088c4fd25cf0cd7bc08a81898be 100755 (executable)
@@ -1,6 +1,9 @@
 #!/bin/bash
 
-x="$(readlink -f "$BASH_SOURCE")"; source "${x%/*}/bash-trace"
+# note, this script gets piped to bash, so cant cd to current dir
+set -eE -o pipefail
+trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+
 
 fai_action_arg=I
 fai_reboot_arg=,reboot
@@ -18,7 +21,13 @@ esac
 
 [[ $EUID == 0 ]] || exec sudo "${BASH_SOURCE}" "$@"
 
-e() { echo "$@"; "$@"; }
+e() {
+    echo "$*"
+    if ! "$@"; then
+        echo "$0: error: exit code $? from: $*"
+        exit 1
+    fi
+}
 
 host=$1
 
@@ -38,6 +47,8 @@ fi
 my_ip=${network%/*}
 if [[ $host == default ]]; then
     ip=$network
+elif [[ $host == [0-9]*.[0-9]*.[0-9]*.[0-9]* ]]; then
+    ip=$host
 else
     ip=$(host $host | sed -rn 's/^\S+ has address //p;T;q')/32
 fi