File: mount-shared-storage.sh

package info (click to toggle)
glusterfs 11.2-2
  • links: PTS
  • area: main
  • in suites: forky
  • size: 28,244 kB
  • sloc: ansic: 471,238; sh: 45,610; python: 16,893; perl: 3,328; makefile: 2,014; yacc: 487; ruby: 171; lisp: 124; xml: 75; lex: 61
file content (42 lines) | stat: -rwxr-xr-x 1,218 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/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

exitStatus=0

while IFS= read -r glm
do
	IFS=$' \t' read -r -a arr <<< "$glm"

	#Validate storage type is glusterfs
	if [ "${arr[2]}" == "glusterfs" ]
	then

		#Check whether shared storage is already mounted, systemd.automount will be ignored
		if grep -q -P '^(?!systemd).*'"${arr[1]}" /proc/mounts
		then
			echo "${arr[1]} is already mounted"
			continue
		fi

		#Wait for few seconds prior to mount command
		#This solves possible issues with systemd boot process
		#Allowing usage of glusterfssharedstorage.service from GlusterFS Debian package
		sleep 5
		mount -t glusterfs -o "${arr[3]}" "${arr[0]}" "${arr[1]}"
		#Also wait a few seconds after the mount command
		sleep 5

		#Re-check whether shared storage has been successfully mounted
		if grep -q -P '^(?!systemd).*'"${arr[1]}" /proc/mounts
		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