Sophie

Sophie

distrib > CentOS > 5 > i386 > by-pkgid > 72dc2cb8307d5ac541d29e8a9a7641f1 > files > 1

gfs-utils-0.1.20-14.el5.i386.rpm

#!/bin/bash
#
# 
#
# chkconfig: - 26 74
# description: mount/unmount gfs filesystems configured in /etc/fstab
#
#	       
### BEGIN INIT INFO
# Provides: 
### END INIT INFO

. /etc/init.d/functions
[ -f /etc/sysconfig/cluster ] && . /etc/sysconfig/cluster

#
# This script's behavior is modeled closely after the netfs script.  
#
GFSFSTAB=$(LC_ALL=C awk '!/^#/ && $3 == "gfs" && $4 !~ /noauto/ { print $2 }' /etc/fstab)
GFSMTAB=$(LC_ALL=C awk '!/^#/ && $3 == "gfs" && $2 != "/" { print $2 }' /proc/mounts)

# See how we were called.
case "$1" in
  start)
        if [ -n "$GFSFSTAB" ] 
	then
		action $"Mounting GFS filesystems: " mount -a -t gfs
	fi
	touch /var/lock/subsys/gfs
	;;

  stop)
  	if [ -n "$GFSMTAB" ] 
	then
		sig=
		retry=6
		remaining=`LC_ALL=C awk '!/^#/ && $3 == "gfs" && $2 != "/" {print $2}' /proc/mounts`
		while [ -n "$remaining" -a "$retry" -gt 0 ]
		do
			action $"Unmounting GFS filesystems: " umount -a -t gfs
			
			if [ $retry -eq 0 ] 
			then
				action $"Unmounting GFS filesystems (lazy): " umount -l -a -t gfs
				break
			fi

			sleep 2
			remaining=`LC_ALL=C awk '!/^#/ && $3 == "gfs" && $2 != "/" {print $2}' /proc/mounts`
			[ -z "$remaining" ] && break
			/sbin/fuser -k -m $sig $remaining >/dev/null
			sleep 10
			retry=$(($retry - 1))
			sig=-9
		done
	fi

	modprobe -r gfs
	rm -f /var/lock/subsys/gfs
	;;

  status)
	if [ -f /proc/mounts ]
	then
	        [ -n "$GFSFSTAB" ] && {
		     echo $"Configured GFS mountpoints: "
		     for fs in $GFSFSTAB; do echo $fs ; done
		}
		[ -n "$GFSMTAB" ] && {
                      echo $"Active GFS mountpoints: "
		      for fs in $GFSMTAB; do echo $fs ; done
		}
	else
		echo "/proc filesystem unavailable"
	fi
	;;

  restart)
	$0 stop
	$0 start
	;;

  reload)
        $0 start
	;;
  *)
	echo $"Usage: $0 {start|stop|restart|reload|status}"
	exit 1
esac

exit 0