static usb ethnet addresses
[automated-distro-installer] / faiserver-disable
old mode 100644 (file)
new mode 100755 (executable)
index a0328d7..65e2aa8
@@ -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 exports
 EOF
-    exit $1
+  exit $1
 }
 
 if [[ $1 ]]; then
-    usage 1
+  usage 1
 fi
 
-ssh root@$(chost faiserver) "sed -ri --follow-symlinks '\%^/srv/fai/d' /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