X-Git-Url: https://iankelling.org/git/?p=automated-distro-installer;a=blobdiff_plain;f=myfai-chboot-local;h=58babc14c750e088c4fd25cf0cd7bc08a81898be;hp=c990fdf39456b179549bab45ebe0d8e28f1f31f3;hb=06d7ec6b13af05465b2d88998be2bfbe7c3c43d6;hpb=d29d21017de635db1d05769144db56f44addd055 diff --git a/myfai-chboot-local b/myfai-chboot-local index c990fdf..58babc1 100755 --- a/myfai-chboot-local +++ b/myfai-chboot-local @@ -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