X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=faiserver-disable;h=65e2aa844b6e861b32b3f07ac6c5c91a465e525e;hb=HEAD;hp=3cb6da22ea45120a4ffb99410b98a94e35750d03;hpb=a027429011d313e0d9156fef9451f5a55a588163;p=automated-distro-installer diff --git a/faiserver-disable b/faiserver-disable index 3cb6da2..74aaef8 100755 --- a/faiserver-disable +++ b/faiserver-disable @@ -1,26 +1,33 @@ #!/bin/bash +if ! test "$BASH_VERSION"; then echo "error: shell is not bash" >&2; exit 1; fi +shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4 set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR + +this_file="$(readlink -f -- "${BASH_SOURCE[0]}")" +readonly this_file this_dir="${this_file%/*}" +cd "$this_dir" usage() { - cat </dev/null; then - sed -ri --follow-symlinks '\%^/srv/fai/d' /etc/exports - exportfs -ra + + +faiserver_addr=$(host faiserver.b8.nz | sed -rn 's/^\S+ has address //p;T;q' ||:) +if ip a | grep "^ *inet.\? $faiserver_addr" &>/dev/null; then + echo "$0: disabling fai nfs exports or apache site" + ./faiserver-disable-local else - rm -f /etc/apache2/sites-enabled/faiserver.conf - systemctl reload apache2 + echo "$0: sshing to $(chost faiserver.b8.nz) to disable fai nfs exports or apache site" + ssh root@$(chost faiserver.b8.nz) bash