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