X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=dsfull;h=814300e02c523eabe38d5f0b4997a0538040a748;hb=bf19e9969f50a637c8fabf724eb9e292da472e01;hp=5d50eab67da525f951d40f227c051d9a1c9d7baf;hpb=23bf2f3666becf9d3c219af1eaea08b4cf843492;p=automated-distro-installer diff --git a/dsfull b/dsfull index 5d50eab..814300e 100755 --- a/dsfull +++ b/dsfull @@ -1,10 +1,14 @@ #!/bin/bash -l # Copyright (C) 2016 Ian Kelling -# distro setup full. (assuming we already synced data files to the host) +# 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 -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR +cleanup() { :; } +trap 'cleanup; echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR reboot=true if [[ $1 == -r ]]; then @@ -20,13 +24,29 @@ if [[ ! $host || $host == -h ]]; then fi set -x + +cleanup() { pxe-server :; } +pxe-server fai $host + + if $reboot; then # untested, this caused hang using here doc. - ssh $host "touch /tmp/keyscript-off; sudo reboot" ||: + ssh $host "touch /tmp/keyscript-off; sudo reboot" ||: & fi -pxe-server fai $host -while ! ssh $host :; do +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