Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 092588ffa07432b6c33710954e07a905 > files > 3

ocfs2-tools-1.4.1-2mdv2010.0.i586.rpm

#! /bin/bash
# Copyright (c) 2005 Oracle
# All rights reserved.
#
# chkconfig: 2345 25 19
# description: Mount OCFS2 volumes at boot.
#
### BEGIN INIT INFO
# Provides: ocfs2
# Required-Start: $network o2cb
# Required-Stop: 
# X-UnitedLinux-Should-Start:
# X-UnitedLinux-Should-Stop:
# Default-Start:  2 3 5
# Default-Stop:
# Short-Description: Mount OCFS2 volumes at boot.
# Description:  Mount OCFS2 volumes at boot.
### END INIT INFO

if [ -f /etc/redhat-release ]
then
. /etc/init.d/functions

init_status()
{
    return 0
}

success_status()
{
    success
    echo
}

failure_status()
{
    failure $1
    echo
}

exit_status()
{
    exit $?
}
elif [ -f /etc/SuSE-release -o -f /etc/UnitedLinux-release ]
then
. /etc/rc.status

init_status()
{
    rc_reset
}

success_status()
{
    /bin/true
    rc_status -v
}

failure_status()
{
    /bin/false
    rc_status -v
}

exit_status()
{
    rc_exit
}
else
init_status()
{
    return 0
}

success_status()
{
    gprintf "OK\n"
    return 0
}

failure_status()
{
    gprintf "Failed\n"
    return 0
}

exit_status()
{
    exit $?
}
fi

ocfs2mounts()
{
    LC_ALL=C awk '$3 == "ocfs2"  { print $2 }' /proc/mounts
}

ocfs2fstab()
{
    LC_ALL=C awk '!/^#/ && $3 == "ocfs2" && $4 !~ /noauto/ { print $2 }' /etc/fstab
}

init_status

FUSER=`which fuser`

case "$1" in
    start|reload)
        if [ -d /var/lock/subsys ] ; then
            touch /var/lock/subsys/ocfs2
        fi
        if [ -n "`ocfs2fstab`" ] ; then
            gprintf "Starting Oracle Cluster File System (OCFS2) "
            mount -at ocfs2
            if [ $? = 0 ]
            then
                success_status
            else
                failure_status "Unable to mount OCFS2 filesystems"
            fi
        fi
        ;;
    stop)
        gprintf "Stopping Oracle Cluster File System (OCFS2) "
        remaining="`ocfs2mounts`"
        sig=
        retry=3
        while [ -n "$remaining" -a "$retry" -gt 0 ]
        do
            if [ "$retry" -lt 3 ]; then
                gprintf "Retry stopping Oracle Cluster File System (OCFS2) "
            fi
            umount -a -t ocfs2 2>/dev/null
            sleep 1

            remaining="`ocfs2mounts`"
            [ -z "$remaining" ] && break
            failure_status "Unable to unmount OCFS2 filesystems"

            $FUSER -km $sig $remaining >/dev/null
            sleep 5
            retry=$(($retry - 1))
            sig=-9
        done
        if [ -z "$remaining" ] && [ -e /var/lock/subsys/ocfs2 ] ; then
                rm /var/lock/subsys/ocfs2
        fi
        [ -z "$remaining" ] && success_status
        ;;
    restart|force-reload)
        $0 stop
        $0 start
        ;;
    status)
        if [ -f /proc/mounts ] ; then
            [ -n "`ocfs2fstab`" ] && {
                gprintf "Configured OCFS2 mountpoints: \n" `ocfs2fstab`
            }

            [ -n "`ocfs2mounts`" ] && {
                gprintf "Active OCFS2 mountpoints: \n" `ocfs2mounts`
            }
        else
            gprintf "Checking OCFS2 mountpoints: "
            failure_status
        fi
        ;;
    try-restart|condrestart)
        $0 status
        if test $? = 0; then
            $0 restart
        fi
        ;;
    *)
        gprintf "Usage: %s {start|stop|status|reload|force-reload|restart|try-restart}\n" "$0"
        exit 1
esac

exit_status