summaryrefslogtreecommitdiffstats
path: root/extras/mount-shared-storage.sh
diff options
context:
space:
mode:
authorHendrik Visage <hvjunk@gmail.com>2017-05-19 12:21:37 +0530
committerKaleb KEITHLEY <kkeithle@redhat.com>2017-06-20 12:42:01 +0000
commit3183ca1bdee9cb0af22c017e3c610add8ff2b405 (patch)
tree7fc3036b96154701853ce8826bf129a71ca42af3 /extras/mount-shared-storage.sh
parenta052b413242783f39cb3312a6a02bdd025b10f0c (diff)
scripts/shared_storage : systemd helper scripts to mount shared storage post reboot
Reported-by: Hendrik Visage <hvjunk@gmail.com> Change-Id: Ibcff56b00f45c8af54c1ae04974267c2180f5f63 BUG: 1452527 Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com> Reviewed-on: https://review.gluster.org/17339 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'extras/mount-shared-storage.sh')
-rwxr-xr-xextras/mount-shared-storage.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/extras/mount-shared-storage.sh b/extras/mount-shared-storage.sh
new file mode 100755
index 00000000000..038a59aaabf
--- /dev/null
+++ b/extras/mount-shared-storage.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+#Post reboot there is a chance in which mounting of shared storage will fail
+#This will impact starting of features like NFS-Ganesha. So this script will
+#try to mount the shared storage if it fails
+#TODO : Do it for other glusterfs clients in /etc/fstab
+
+ms="var-run-gluster-shared_storage.mount"
+volume="gluster_shared_storage"
+failed=$(systemctl --failed | grep -c $ms)
+if [ $failed -eq 1 ]
+then
+ if systemctl restart $ms
+ then
+ #Restart worked just wait for sometime to make it reflect
+ sleep 5
+ else
+ #Restart failed, no point in further continuing
+ exit 1
+ fi
+fi
+
+# If we've reached this point, there wasn't a failed mountpoint
+# BUT we need to check for whether this haven't been called before the attempts
+# to the filesystem mounts, thus we need to check whether there is a glusterfs
+# in fstab and aren't mountedmount
+
+#In the logs I've seen ~4-5secs between the initial mount/start and the unmount
+
+gfc=$(sed -e 's/#.$//' </etc/fstab | grep -c $volume)
+gfm=$(grep -i $volume /proc/mounts | wc -l)
+
+if [ $gfm -lt $gfc ]
+then
+ exit 1
+fi
+
+exit 0