summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorJosiah <josiahp@gmail.com>2018-06-29 14:14:36 -0500
committerAmar Tumballi <amarts@redhat.com>2018-07-10 19:38:48 +0000
commitf4497ee445213650df3509f2d0b682a6455d7305 (patch)
treef4cf5080b2b57851c5e0319c2197625a7f6362c1 /extras
parent6dc5dfef819cad69d6d4b4c1c305efa74236ad84 (diff)
Update mount-shared-storage.sh to automatically include all enabled glusterfs mounts in fstab
Currently the mount-shared-storage.sh script requires manual entry of each volume and mount point. There is a TODO item from Bug 1452527 to automatically pull the list of glusterfs mounts from the /etc/fstab file, validate that they are mounted, or attempt to mount them. This is to complete that TODO item. The extras/mount-shared-storage.sh file has been updated to read only active glusterfs mounts from the /etc/fstab file, verify if they are mounted, and attemt to mount them if they are not. It will exit with a status 0 if successfully mounted or status 1 if any of the mounts fail. This method will allow the standard method of mounts in /etc/fstab to be utilized and will ensure they are monted following system reboots. This can be tested by creating a volume, mounting it using the /etc/fstab method, and rebooting the server. Output will be similar to this: Jun 29 19:09:38 localhost systemd[1]: Starting Mount glusterfs sharedstorage... Jun 29 19:09:43 localhost mount-shared-storage.sh[4096]: /mnt/mount1 has been mounted Jun 29 19:09:48 localhost mount-shared-storage.sh[4096]: /mnt/mount2 has been mounted Jun 29 19:09:48 localhost systemd[1]: Started Mount glusterfs sharedstorage. Multiple fixes based on code review suggestions and spellcheck Removed spaces in grep for glusterfs as tabs are valid as well Added tab as an IFS field separator for the lines read from /etc/fstab Increased sleep time to 10 seconds before mount validation Changed mount check to use “mountpoint -q” Change-Id: Ib90c99ced8f7aefc8dbe87340afc73a28f6195e7 fixes: bz#1596789 Signed-off-by: Josiah <josiahp@gmail.com>
Diffstat (limited to 'extras')
-rwxr-xr-xextras/mount-shared-storage.sh57
1 files changed, 30 insertions, 27 deletions
diff --git a/extras/mount-shared-storage.sh b/extras/mount-shared-storage.sh
index 3645a0f42fd..e99233f7e1e 100755
--- a/extras/mount-shared-storage.sh
+++ b/extras/mount-shared-storage.sh
@@ -2,35 +2,38 @@
#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
-volume="gluster_shared_storage"
-mp="/var/run/gluster/shared_storage"
-#check if there is fstab entry for shared storage
-gfc=$(sed -e 's/#.$//' </etc/fstab | grep -c $volume)
-if [ $gfc -eq 0 ]
-then
- exit 0
-fi
+exitStatus=0
-#check whether shared storage is mounted
-#if it is mounted then mount has inode value 1
-inode=$(ls -id $mp | awk '{print $1}')
+while IFS= read -r glm
+do
+ IFS=$' \t' read -r -a arr <<< "$glm"
-if [ $inode -eq 1 ]
-then
- exit 0
-fi
+ #Validate storage type is glusterfs
+ if [ "${arr[2]}" == "glusterfs" ]
+ then
-mount -t glusterfs localhost:/$volume $mp
-#wait for few seconds
-sleep 5
+ #check whether shared storage is mounted
+ #if it is mounted then mountpoint -q will return a 0 success code
+ if mountpoint -q "${arr[1]}"
+ then
+ echo "${arr[1]} is already mounted"
+ continue
+ fi
-#recheck mount got succeed
-inode=$(ls -id $mp | awk '{print $1}')
-if [ $inode -eq 1 ]
-then
- exit 0
-else
- exit 1
-fi
+ mount -t glusterfs "${arr[0]}" "${arr[1]}"
+ #wait for few seconds
+ sleep 10
+
+ #recheck mount got succeed
+ if mountpoint -q "${arr[1]}"
+ then
+ echo "${arr[1]} has been mounted"
+ continue
+ else
+ echo "${arr[1]} failed to mount"
+ exitStatus=1
+ fi
+ fi
+done <<< "$(sed '/^#/ d' </etc/fstab | grep 'glusterfs')"
+exit $exitStatus