Merge branch 'upstream'
[automated-distro-installer] / myfai-chboot-local
index f21a837dc5308790c45b263c3e69aaa3dd37006c..58babc14c750e088c4fd25cf0cd7bc08a81898be 100755 (executable)
@@ -1,8 +1,10 @@
 #!/bin/bash
 
+# 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
 case $1 in
@@ -19,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
 
@@ -39,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