cluster: RHEL6 - gfs2 init: make the init script LSB compliant
Fabio M. Di Nitto
fabbione at fedoraproject.org
Mon Jul 12 17:31:39 UTC 2010
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=9404fdcebc1b879f1c0898824611f7658a11fa08
Commit: 9404fdcebc1b879f1c0898824611f7658a11fa08
Parent: c81bfa93b925788edfbb9fa42fe6112f78826011
Author: Fabio M. Di Nitto <fdinitto at redhat.com>
AuthorDate: Fri Jul 9 15:36:35 2010 +0200
Committer: Fabio M. Di Nitto <fdinitto at redhat.com>
CommitterDate: Fri Jul 9 15:39:13 2010 +0200
gfs2 init: make the init script LSB compliant
At the same time improve output for mount/umount operation to get
errors per operation instead of global.
Resolves: rhbz#553383
Signed-off-by: Fabio M. Di Nitto <fdinitto at redhat.com>
---
gfs2/init.d/gfs2.in | 63 ++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 52 insertions(+), 11 deletions(-)
diff --git a/gfs2/init.d/gfs2.in b/gfs2/init.d/gfs2.in
index e957a36..0f0f009 100644
--- a/gfs2/init.d/gfs2.in
+++ b/gfs2/init.d/gfs2.in
@@ -75,22 +75,62 @@ if [ -z "$GFS2FSTAB" ]; then
exit 6
fi
+if [ "$EUID" != "0" ]; then
+ echo "Only root can execute $0 script"
+ exit 4
+fi
+
+is_mounted()
+{
+ for i in $GFS2MTAB; do
+ if [ "$1" = "$i" ]; then
+ return 0
+ fi
+ done
+ return 1
+}
+
# See how we were called.
case "$1" in
start)
- [ -z "$GFS2FSTAB" ] && exit 0
- echo -n "Mounting GFS2 filesystems: "
- errmsg="$(mount -a -t gfs2 2>&1)" || nok
- touch $LOCK_FILE
- ok
+ mounted=0
+ for fs in $GFS2FSTAB; do
+ echo -n "Mounting GFS2 filesystem ($fs): "
+ if is_mounted $fs; then
+ echo -n "already mounted"
+ ok
+ mounted=$((mounted + 1))
+ continue
+ fi
+ errmsg="$(mount $fs 2>&1)"
+ if [ "$?" != 0 ]; then
+ echo -e "$errmsg"
+ failure
+ echo
+ continue
+ fi
+ ok
+ mounted=$((mounted + 1))
+ done
+ [ $mounted -gt 0 ] && touch $LOCK_FILE
;;
stop)
[ -z "$GFS2MTAB" ] && exit 0
- echo -n "Unmounting GFS2 filesystems: "
- errmsg="$(umount -a -t gfs2 2>&1)" || nok
+ umount_failed=0
+ for fs in $GFS2MTAB; do
+ echo -n "Unmounting GFS2 filesystem ($fs): "
+ errmsg="$(umount $fs 2>&1)"
+ if [ "$?" != 0 ]; then
+ echo -e "$errmsg"
+ failure
+ echo
+ umount_failed=1
+ continue
+ fi
+ ok
+ done
modprobe -r gfs2 > /dev/null 2>&1 || true
- rm -f $LOCK_FILE
- ok
+ [ $umount_failed = 0 ] && rm -f $LOCK_FILE
;;
status)
@@ -117,10 +157,11 @@ status)
condrestart|try-restart)
$0 status >/dev/null 2>&1 || exit 0
$0 restart
+ exit $?
;;
restart|reload|force-reload)
- $0 stop
- $0 start
+ $0 stop && $0 start
+ exit $?
;;
*)
echo "Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}"
More information about the cluster-commits
mailing list