X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=pxe-server;h=8b3399ea806f6147cb6608bfdcb5fd8305bf6c0d;hb=d29d21017de635db1d05769144db56f44addd055;hp=6b6a5765e2571c2550cc64b53ffbbed24bdba2ea;hpb=bf19e9969f50a637c8fabf724eb9e292da472e01;p=automated-distro-installer diff --git a/pxe-server b/pxe-server index 6b6a576..8b3399e 100755 --- a/pxe-server +++ b/pxe-server @@ -22,27 +22,42 @@ # default distro is the base debian/fedora type. others are fai & arch. # for no pxe server, use a no-op like : or true. -set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR + +x="$(readlink -f "$BASH_SOURCE")"; source "${x%/*}/bash-trace" usage() { cat < tftpboot + + Note: Uses GNU getopt options parsing style EOF exit $1 @@ -50,30 +65,35 @@ EOF ##### begin command line parsing ######## -args=() redep=true acks=2 wait=false -temp=$(getopt -l help hra "$@") || usage 1 +temp=$(getopt -l help harSw "$@") || usage 1 eval set -- "$temp" while true; do case $1 in - -h|--help) usage ;; + -a) wait=true; set=false; shift ;; -r) redep=false; shift ;; - -a) wait=true; shift ;; + -S) chboot_arg=-S; shift ;; + -w) wait=true; set=true; shift ;; + -h|--help) usage ;; --) shift; break ;; *) echo "$0: Internal error!" ; exit 1 ;; esac done -read type host <<<"$@" +read -r host type <<<"$@" -if [[ ! $type ]]; then - echo "$0: error: exptected 1 argument of type" - usage 1 -fi +case $# in + 0|2);; + *) + echo "$0: error: expected 0 or 2 arguments" + echo + usage 1 + ;; +esac -if [[ $host ]]; then +if [[ $host && $host != default ]]; then host_tag="tag:$host," fi @@ -102,8 +122,7 @@ EOF fai() { cat </dev/null ||: fi fi @@ -147,7 +169,8 @@ if $wait; then # bleh. echo "waiting for $acks dhcp acks then disabling pxe" ack-wait $acks - set-pxe : + type= + set-pxe # previously tried waiting for one more ack then disabling faiserver, # since it can contain sensitive info, so turn it off when not in use,