set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+reboot=true
+if [[ $1 == -r ]]; then
+ reboot=false
+ shift
+fi
+
host=$1
if [[ ! $host || $host == -h ]]; then
fi
set -x
-ssh $host sudo bash <<'EOF'
-set -e
-systemctl stop keyscriptoff.service
+if $reboot; then
+ ssh $host sudo bash <<'EOF' || [[ $? == 255 ]]
+touch /tmp/keyscript-off
reboot ||:
EOF
+fi
pxe-server fai $host
while ! ssh $host :; do
- sleep 5
+ sleep 5
done
dsremote $host