#!/bin/bash -l # Copyright (C) 2016 Ian Kelling # distro setup full using fai. (assuming we already synced data files to the host) # Usage: dsfull [-r] HOST # -r for no reboot. set -eE -o pipefail cleanup() { :; } trap 'cleanup; 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 echo "$0: error: expected 1 arg of hostname" exit 1 fi set -x cleanup() { pxe-server; } pxe-server $host fai if $reboot; then # untested, this caused hang using here doc. ssh $host "touch /tmp/keyscript-off; sudo reboot" ||: & fi pxe-server -a cleanup() { :; } error=true for ((i=0; i<240; i++)); do if timeout -s 9 10 ssh $host :; then error=false break fi sleep 5 done if $error; then echo "$0: error: timeout" exit 1 fi dsremote $host