static usb ethnet addresses
[automated-distro-installer] / faiserver-disable
index 3cb6da22ea45120a4ffb99410b98a94e35750d03..65e2aa844b6e861b32b3f07ac6c5c91a465e525e 100755 (executable)
@@ -1,26 +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) bash <<'EOF'
-if modprobe nfsd &>/dev/null; then
-  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
-  rm -f /etc/apache2/sites-enabled/faiserver.conf
-  systemctl reload apache2
+  echo "$0: sshing to $(chost faiserver) to disable fai nfs exports or apache site"
+  ssh root@$(chost faiserver) bash <faiserver-disable-local
 fi
-EOF