summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSimon Rettberg2018-06-04 13:00:08 +0200
committerSimon Rettberg2018-06-04 13:00:08 +0200
commitba1feecd02229474125f82b582b69383b4d45806 (patch)
tree74124c408ed5f3b463d4ba9b25bc9f80bf72243b /scripts
parent[scripts/system-restore] Print proper messages when restoring databases (diff)
downloadtmlite-bwlp-ba1feecd02229474125f82b582b69383b4d45806.tar.gz
tmlite-bwlp-ba1feecd02229474125f82b582b69383b4d45806.tar.xz
tmlite-bwlp-ba1feecd02229474125f82b582b69383b4d45806.zip
[mount-store] Conditionally enable nfs server
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/mount-store29
1 files changed, 28 insertions, 1 deletions
diff --git a/scripts/mount-store b/scripts/mount-store
index cc6766d..ff628a9 100755
--- a/scripts/mount-store
+++ b/scripts/mount-store
@@ -71,8 +71,11 @@ systemctl stop dnbd3-server.service
# Already mounted?
TRIES=0
+NFS_WAS_RUNNING=false
+systemctl is-active -q nfs-kernel-server.service && NFS_WAS_RUNNING=true
while awk '{print $2}' "/proc/mounts" | grep -Fxq "${DEST}"; do
echo "Trying to unmount '$DEST'..."
+ systemctl stop nfs-kernel-server.service
if [ "$TRIES" -gt 5 ]; then
cat >&2 <<-HEREDOC
Error: Cannot unmount '$DEST'!
@@ -114,11 +117,35 @@ fi
# Unmount and not requested to mount (local mode)
if [[ "${SOURCE}" == "null" ]]; then
rm -f -- "${FLAG}"
- echo "Success. Now using internal storage."
systemctl --no-block start dnbd3-server.service
+ # Enable nfs server
+ systemctl enable nfs-kernel-server.service
+ # Enable our export
+ sed -r -i 's,^\s*#\s*(/srv/openslx/nfs),\1,' "/etc/exports"
+ # Line was not present? add!
+ grep -Eq '^\s*/srv/openslx/nfs' "/etc/exports" \
+ || echo '/srv/openslx/nfs *(ro,async,insecure,no_root_squash,no_subtree_check)' >> "/etc/exports"
+ # Restart
+ systemctl --no-block restart nfs-kernel-server.service
+ echo "Success. Now using internal storage."
exit 0
fi
+# Using external storage, via NFS or CIFS
+
+# Disable our export
+sed -r -i 's,^\s*(/srv/openslx/nfs),#\1,' "/etc/exports"
+# See if there are any foreign exports and nfs-server was running and if so, keep nfs server running
+if grep -Eq '^\s*/' /etc/exports; then
+ if "$NFS_WAS_RUNNING"; then
+ systemctl --no-block restart nfs-kernel-server.service
+ fi
+else
+ # No valid exports left, disable and stop NFS server
+ systemctl disable nfs-kernel-server.service
+ systemctl --no-block stop nfs-kernel-server.service
+fi
+
touch "${FLAG}"
if [[ "${SOURCE}" == "unknown" ]]; then