X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=dsfull;h=e24c549fdf70818e8ee02a448c3778fafaa32f56;hb=1a9e69876006d789df6fb5597419ef38f864903e;hp=f141bc508a2f7a7012f96aaa06ea96f99cee8296;hpb=7815dd8b158226f7186bf987d270b4f824902555;p=automated-distro-installer diff --git a/dsfull b/dsfull index f141bc5..e24c549 100755 --- a/dsfull +++ b/dsfull @@ -1,11 +1,20 @@ #!/bin/bash -l # Copyright (C) 2016 Ian Kelling -# This program is under GPL v. 3 or later, see -# 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 + reboot=false + shift +fi host=$1 @@ -15,14 +24,29 @@ if [[ ! $host || $host == -h ]]; then fi set -x -ssh $host sudo bash <<'EOF' -set -e -systemctl stop keyscriptoff.service -reboot ||: -EOF - -pxe-server fai $host -while ! ssh $host :; do - sleep 5 + +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