#! /bin/bash # description: Mount glustefs volumes at boot. ### BEGIN INIT INFO # Provides: glusterfs-mount # Required-Start: $network fuse # Required-Stop: # Default-Start: 2 3 4 5 S # Default-Stop: # Short-Description: Mount glusterfs volumes at boot. # Description: Mount glusterfs volumes at boot. ### END INIT INFO . /lib/lsb/init-functions glusterfsmounts() { LC_ALL=C awk '$3 == "fuse.glusterfs" { print $2 }' /proc/mounts } glusterfsfstab() { LC_ALL=C awk '!/^#/ && $3 == "glusterfs" && $4 !~ /noauto/ { print $2 }' /etc/fstab } case "$1" in start|reload) if [ -n "`glusterfsfstab`" ] ; then log_action_begin_msg "Mounting glusterfs partitions" mount -at glusterfs if [ $? = 0 ] then log_action_end_msg 0 else echo "Error : Unable to mount glusterfs filesystems" log_action_end_msg 1 fi fi ;; stop) log_action_begin_msg "Unmounting glusterfs partitions" remaining="`glusterfsmounts`" sig= retry=3 while [ -n "remaining" -a "$retry" -gt 0 ]; do for i in $remaining; do umount $i done sleep 1 remaining="`glusterfsmounts`" [ -z "$remaining" ] && break echo " Error :Unable to unmount glusterfs attempt : $retry/3" sleep 5 retry=$(($retry - 1)) sig=-9 done [ -z "$remaining" ] && log_action_end_msg 0 || log_action_end_msg 1 ;; restart) $0 stop $0 start ;; status) if [ -f /proc/mounts ] ; then [ -n "`glusterfsfstab`" ] && { echo "Configured glusterfs mountpoints: " `glusterfsfstab` } [ -n "`glusterfsmounts`" ] && { echo "Active glusterfs mountpoints: " `glusterfsmounts` } else echo -n "Checking glusterfs mountpoints: " echo -n "FAILED" fi ;; *) echo "Usage: $0 {start|stop|status|reload|restart}" exit 1 esac