diff -urN openais-1.1.2.orig//init/Makefile.am openais-1.1.2/init/Makefile.am --- openais-1.1.2.orig//init/Makefile.am 2010-01-26 18:35:03.000000000 +0100 +++ openais-1.1.2/init/Makefile.am 2010-02-09 22:41:29.091663000 +0100 @@ -34,7 +34,7 @@ MAINTAINERCLEANFILES = Makefile.in -EXTRA_DIST = generic.in +EXTRA_DIST = generic.in suse target_INIT = generic diff -urN openais-1.1.2.orig//init/suse openais-1.1.2/init/suse --- openais-1.1.2.orig//init/suse 1970-01-01 01:00:00.000000000 +0100 +++ openais-1.1.2/init/suse 2010-02-09 22:41:12.278197000 +0100 @@ -0,0 +1,210 @@ +#!/bin/sh +# +# Corosync daemon init script for LSB-compliant Linux distributions. +# +# openais Start the openais (corosync) cluster service +# +# chkconfig: - 20 20 +# processname: corosync +# pidfile: /var/run/corosync.pid +# description: Corosync/OpenAIS +### BEGIN INIT INFO +# Description: Manages the openais cluster services. +# +# Short-Description: openais cluster services. +# Provides: openais +# Required-Start: $network +# Should-Start: $syslog sshd drbd $named $remote_fs logd xendomains xend +# Required-Stop: $network +# Default-Start: 3 5 +# Default-Stop: 0 6 +# Should-Stop: logd drbd $syslog $named xendomains xend +### END INIT INFO + +do_force=0 +prog="corosync" +exec="/usr/sbin/corosync" +lockfile="/var/lock/subsys/$prog" + +OPENAIS_SYSCONFIG=/etc/sysconfig/openais +if [ -f $OPENAIS_SYSCONFIG ]; then + . $OPENAIS_SYSCONFIG +fi +PACEMAKER_SYSCONFIG=/etc/sysconfig/pacemaker +if [ -f $PACEMAKER_SYSCONFIG ]; then + . $PACEMAKER_SYSCONFIG +fi +LRMADMIN="/usr/sbin/lrmadmin" + +SBD_CONFIG=/etc/sysconfig/sbd +SBD_BIN="/usr/sbin/sbd" +if [ -f $SBD_CONFIG ]; then + . $SBD_CONFIG +fi + +[ -x "$exec" ] || exit 0 + +StartSBD() { + test -x $SBD_BIN || return + if [ -n "$SBD_DEVICE" ]; then + if ! pidofproc $SBD_BIN ; then + echo -n "Starting SBD - " + if ! $SBD_BIN -d $SBD_DEVICE -D $SBD_OPTS watch ; then + echo "SBD failed to start; aborting." + exit 1 + fi + fi + fi +} + +StopSBD() { + test -x $SBD_BIN || return + if [ -n "$SBD_DEVICE" ]; then + echo -n "Stopping SBD - " + if ! $SBD_BIN -d $SBD_DEVICE -D $SBD_OPTS message LOCAL exit ; then + echo "SBD failed to stop; aborting." + exit 1 + fi + fi +} + +wait_for_lrmd() { + local maxwait=30 + local i=0 + while [ $i -lt $maxwait ]; do + $LRMADMIN -C > /dev/null 2>&1 && + break + sleep 1 + i=$(($i+1)) + done + if [ $i -lt $maxwait ]; then + return 0 + else + echo "lrmd apparently didn't start" + return 1 + fi +} +set_lrmd_options() { + test -x $LRMADMIN || return + if [ -n "$LRMD_MAX_CHILDREN" ]; then + wait_for_lrmd || return + $LRMADMIN -p max-children $LRMD_MAX_CHILDREN + fi +} + +internal_status() { + checkproc $exec > /dev/null 2>&1 + return $? +} + +status() { + if internal_status; then + echo "Running" + return 0 + else + echo "Stopped" + return 7 + fi +} + +start() { + export COROSYNC_DEFAULT_CONFIG_IFACE + : ${COROSYNC_DEFAULT_CONFIG_IFACE="openaisserviceenableexperimental:corosync_parser"} + echo -n $"Starting OpenAIS/Corosync daemon ($prog): " + if ! internal_status; then + StartSBD + echo -n "starting... " + startproc $exec + fi + + sleep 2 # give it time to fail... $? isn't definitive + + if internal_status; then + set_lrmd_options + echo "OK" + touch "$lockfile" + return 0 + fi + + echo "Failed" + return 1 +} + +do_force=0 +do_forever=1 + +stop() { + echo -n $"Stopping OpenAIS/Corosync daemon ($prog): " + + c_pid="`pidofproc $exec`" + if [ -n "$c_pid" ]; then + kill -TERM $c_pid + fi + + if [ $do_forever = 0 ]; then + for i in 1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20; do + if internal_status; then + sleep 2 + echo -n "." + else + rm -f "$lockfile" + StopSBD + echo "OK" + return 0 + fi + done + + if [ $do_force = 1 ]; then + echo -n "Escalating... " + kill -KILL $c_pid + sleep 5 + + if ! internal_status; then + rm -f "$lockfile" + echo "OK" + return 0 + fi + fi + + echo "Failed" + return 1 + fi + + while internal_status; do + sleep 1 + echo -n "." + done + + StopSBD + + rm -f "$lockfile" + echo "OK" + return 0 +} + +restart() { + stop + start +} + +case "$1" in + start|stop|restart) + $1 + ;; + force-stop) + do_force=1 + stop + ;; + reload|force-reload) + restart + ;; + condrestart|try-restart) + [ ! -f "$lockfile" ] || restart + ;; + status) + status $prog + ;; + *) + echo $"Usage: $0 {start|stop|restart|try-restart|condrestart|reload|force-reload|force-stop|status}" + exit 2 +esac