Sophie

Sophie

distrib > CentOS > 5 > x86_64 > by-pkgid > dd22d6e66cb8b92d89c006eb5a72a31d > files > 1

cmirror-1.1.39-15.el5.x86_64.rpm

#!/bin/bash
#
# chkconfig: - 22 78
# description: Loads/Unloads dm-log-clustered module
#
#
### BEGIN INIT INFO
# Provides:
### END INIT INFO

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

start()
{
        echo -n "Loading clustered mirror log module:"

        modprobe dm-log-clustered >& /dev/null
        rtrn=$?

        if [ $rtrn -eq 0 ]; then
                success "startup"
        else
                failure "startup"
		echo
		return $rtrn
        fi

        # need the extra echo to properly terminate the line
	echo

        echo -n "Starting clustered mirror log server:"
	if ! ps -C aisexec >& /dev/null; then
	    failure "startup"
	    echo
	    echo "  Cluster infrastructure is not running"
	    return 1
	fi

	ps -C clogd >& /dev/null || clogd >& /dev/null

	rtrn=$?
        if [ $rtrn -eq 0 ]; then
                success "startup"
        else
                failure "startup"
        fi

        # need the extra echo to properly terminate the line
        echo
        return $rtrn
}

stop()
{
        echo -n "Stopping clustered mirror log server:"
	killall clogd >& /dev/null
	for ((i=0; $i < 10; i++)); do
	    if ! ps -C clogd >& /dev/null; then
		break;
	    fi
	    sleep 1
	done

	if [ $i -ge 10 ]; then
	    failure "shutdown"
	    echo
	    return 1
	else
	    success "shutdown"
	fi

	echo
        echo -n "Unloading clustered mirror log module:"
	rtrn=0
	if lsmod | grep -w dm_log_clustered >& /dev/null; then
	    rmmod dm-log-clustered
	    rtrn=$?
	fi

        if [ $rtrn -eq 0 ]; then
            success "shutdown"
        else
            failure "shutdown"
        fi

        # need the extra echo to properly terminate the line
        echo
        return $rtrn
}

cmirror_status()
{
	ps -C clogd >& /dev/null
	if [ $? -ne 0 ]; then
		echo "Cluster log server is not running.  (Cluster mirrors will not work.)"
		return 1
	fi

	modprobe dm-log-clustered
	if [ $? -ne 0 ]; then
		echo "Cluster log module is not loaded.  (Cluster mirrors will not work.)"
		return 1
	fi

	return 0
}

rtrn=1

# See how we were called.
case "$1" in
  start)
        start
        rtrn=$?
        ;;

  stop)
        stop
        rtrn=$?
        ;;

  restart)
        $0 stop
        $0 start
        rtrn=$?
        ;;

  status)
	cmirror_status
        rtrn=$?
	if [ $rtrn -eq 0 ]; then
		echo "cmirror is running."
	fi
        ;;

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

exit $rtrn