#!/bin/sh
#
# Corosync daemon init script for Red Hat Linux and compatibles.
#
# chkconfig: - 20 20
# processname:  corosync
# pidfile:      /var/run/corosync.pid
# description:  Corosync Cluster Engine

# Source function library
. /etc/rc.d/init.d/functions

prog="corosync"
exec="/usr/sbin/corosync"
lockfile="/var/lock/subsys/corosync"

[ -x "$exec" ] || exit 0

start() {
    gprintf "Starting Corosync Cluster Engine (%s): " "$prog"
    daemon $exec
    retval=$?
    [ "$retval" -eq 0 ] && touch "$lockfile"
    echo
    return $retval
}

stop() {
    gprintf "Stopping Corosync Cluster Engine (%s): " "$prog"
    killproc $prog
    retval=$?
    [ "$retval" -eq 0 ] && rm -f "$lockfile"
    echo
    return $retval
}

restart() {
    stop
    start
}

case "$1" in
    start|stop|restart)
        $1
        ;;
    reload|force-reload)
        restart
        ;;
    condrestart|try-restart)
        [ ! -f "$lockfile" ] || restart
        ;;
    status)
        status $prog
        ;;
    *)
        gprintf "Usage: %s {start|stop|restart|try-restart|condrestart|reload|force-reload|status}\n" "$0"
        exit 2
esac
