static usb ethnet addresses
[automated-distro-installer] / faiserver-disable
index 8f920d8b7b386f1e81adf28835bd30600932c73a..65e2aa844b6e861b32b3f07ac6c5c91a465e525e 100755 (executable)
@@ -1,18 +1,32 @@
 #!/bin/bash
 
-set -eE -o pipefail
-trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+readonly this_file="$(readlink -f -- "${BASH_SOURCE[0]}")"
+script_dir="${this_file%/*}"
+# shellcheck source=./bash-trace
+source "${script_dir}/bash-trace"
+cd $script_dir
+source "${script_dir}/bash-trace"
+
 
 usage() {
-    cat <<EOF
+  cat <<EOF
 Usage: ${0##*/}
-Disable the fai nfs server.
+Disable the fai nfs server exports
 EOF
-    exit $1
+  exit $1
 }
 
 if [[ $1 ]]; then
-    usage 1
+  usage 1
 fi
 
-ssh root@$(chost faiserver) "sed -ri --follow-symlinks 's,^/srv/fai/,#\0,' /etc/exports; exportfs -ra"
+
+
+faiserver_addr=$(host faiserver | 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
+  echo "$0: sshing to $(chost faiserver) to disable fai nfs exports or apache site"
+  ssh root@$(chost faiserver) bash <faiserver-disable-local
+fi