Blame gfs2/init.d/gfs2

Packit 6ef888
#!/bin/bash
Packit 6ef888
#
Packit 6ef888
# gfs2 mount/unmount helper
Packit 6ef888
#
Packit 6ef888
# chkconfig: - 26 74
Packit 6ef888
# description: mount/unmount gfs2 filesystems configured in /etc/fstab
Packit 6ef888
Packit 6ef888
### BEGIN INIT INFO
Packit 6ef888
# Provides:		gfs2
Packit 6ef888
# Required-Start:	$network cman gfs_controld
Packit 6ef888
# Required-Stop:	$network cman gfs_controld
Packit 6ef888
# Default-Start:
Packit 6ef888
# Default-Stop:
Packit 6ef888
# Short-Description:	mount/unmount gfs2 filesystems configured in /etc/fstab
Packit 6ef888
# Description:		mount/unmount gfs2 filesystems configured in /etc/fstab
Packit 6ef888
### END INIT INFO
Packit 6ef888
Packit 6ef888
# set secure PATH
Packit 6ef888
PATH="/bin:/sbin:/usr/sbin:/usr/bin"
Packit 6ef888
Packit 6ef888
### generic wrapper functions
Packit 6ef888
Packit 6ef888
success()
Packit 6ef888
{
Packit 6ef888
	echo -ne "[  OK  ]\r"
Packit 6ef888
}
Packit 6ef888
Packit 6ef888
failure()
Packit 6ef888
{
Packit 6ef888
	echo -ne "[FAILED]\r"
Packit 6ef888
}
Packit 6ef888
Packit 6ef888
ok() {
Packit 6ef888
	success
Packit 6ef888
	echo
Packit 6ef888
}
Packit 6ef888
Packit 6ef888
nok() {
Packit 6ef888
	echo -e "$errmsg"
Packit 6ef888
	failure
Packit 6ef888
	echo
Packit 6ef888
	exit 1
Packit 6ef888
}
Packit 6ef888
Packit 6ef888
# rpm based distros
Packit 6ef888
if [ -d /etc/sysconfig ]; then
Packit 6ef888
	[ -f /etc/init.d/functions ] && . /etc/init.d/functions
Packit 6ef888
	[ -f /etc/sysconfig/cluster ] && . /etc/sysconfig/cluster
Packit 6ef888
	[ -f /etc/sysconfig/gfs2 ] && . /etc/sysconfig/gfs2
Packit 6ef888
	[ -z "$LOCK_FILE" ] && LOCK_FILE="/var/lock/subsys/gfs2"
Packit 6ef888
fi
Packit 6ef888
Packit 6ef888
# deb based distros
Packit 6ef888
if [ -d /etc/default ]; then
Packit 6ef888
	[ -f /etc/default/cluster ] && . /etc/default/cluster
Packit 6ef888
	[ -f /etc/default/gfs2 ] && . /etc/default/gfs2
Packit 6ef888
	[ -z "$LOCK_FILE" ] && LOCK_FILE="/var/lock/gfs2"
Packit 6ef888
fi
Packit 6ef888
Packit 6ef888
# proc is required for both status and stop.
Packit 6ef888
# start could live without, but better be consistent with the behavior
Packit 6ef888
if [ ! -f /proc/mounts ]; then
Packit 6ef888
	echo "GFS2: /proc is not available, unable to proceed"
Packit 6ef888
	exit 1
Packit 6ef888
fi
Packit 6ef888
Packit 6ef888
#
Packit 6ef888
# This script's behavior is modeled closely after the netfs script.  
Packit 6ef888
#
Packit 6ef888
GFS2FSTAB=$(LC_ALL=C awk '!/^#/ && $3 == "gfs2" && $4 !~ /noauto/ { print $2 }' /etc/fstab)
Packit 6ef888
GFS2MTAB=$(LC_ALL=C awk '!/^#/ && $3 == "gfs2" && $2 != "/" { print $2 }' /proc/mounts | sort -r)
Packit 6ef888
Packit 6ef888
if [ -z "$GFS2FSTAB" ]; then
Packit 6ef888
	echo "GFS2: no entries found in /etc/fstab"
Packit 6ef888
	exit 6
Packit 6ef888
fi
Packit 6ef888
Packit 6ef888
# See how we were called.
Packit 6ef888
case "$1" in
Packit 6ef888
start)
Packit 6ef888
	[ -z "$GFS2FSTAB" ] && exit 0
Packit 6ef888
	echo -n "Mounting GFS2 filesystems: "
Packit 6ef888
	errmsg="$(mount -a -t gfs2 2>&1)" || nok
Packit 6ef888
	touch $LOCK_FILE
Packit 6ef888
	ok
Packit 6ef888
;;
Packit 6ef888
stop)
Packit 6ef888
	[ -z "$GFS2MTAB" ] && exit 0
Packit 6ef888
	echo -n "Unmounting GFS2 filesystems: "
Packit 6ef888
	errmsg="$(umount -a -t gfs2 2>&1)" || nok
Packit 6ef888
	modprobe -r gfs2 > /dev/null 2>&1 || true
Packit 6ef888
	rm -f $LOCK_FILE
Packit 6ef888
	ok
Packit 6ef888
	;;
Packit 6ef888
Packit 6ef888
status)
Packit 6ef888
	if [ -z "$GFS2MTAB" ] && [ -f $LOCK_FILE ]; then
Packit 6ef888
		echo "GFS2: Found stale lock file $LOCK_FILE"
Packit 6ef888
		exit 2
Packit 6ef888
	fi
Packit 6ef888
Packit 6ef888
	if [ -n "$GFS2FSTAB" ] && [ -z "$GFS2MTAB" ]; then
Packit 6ef888
		echo "GFS2: service is not running"
Packit 6ef888
		exit 3
Packit 6ef888
	fi
Packit 6ef888
Packit 6ef888
	echo "Configured GFS2 mountpoints: "
Packit 6ef888
	for fs in $GFS2FSTAB; do
Packit 6ef888
		echo $fs;
Packit 6ef888
	done
Packit 6ef888
Packit 6ef888
	echo "Active GFS2 mountpoints: "
Packit 6ef888
	for fs in $GFS2MTAB; do
Packit 6ef888
		echo $fs;
Packit 6ef888
	done
Packit 6ef888
;;
Packit 6ef888
condrestart|try-restart)
Packit 6ef888
	$0 status >/dev/null 2>&1 || exit 0
Packit 6ef888
	$0 restart
Packit 6ef888
;;
Packit 6ef888
restart|reload|force-reload)
Packit 6ef888
	$0 stop
Packit 6ef888
	$0 start
Packit 6ef888
;;
Packit 6ef888
*)
Packit 6ef888
	echo "Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}"
Packit 6ef888
	exit 2
Packit 6ef888
;;
Packit 6ef888
esac
Packit 6ef888
Packit 6ef888
exit 0