File openais-suse-init.patch of Package openais

Index: openais-1.1.4/init/Makefile.am
===================================================================
--- openais-1.1.4.orig/init/Makefile.am
+++ openais-1.1.4/init/Makefile.am
@@ -34,7 +34,7 @@
 
 MAINTAINERCLEANFILES	= Makefile.in
 
-EXTRA_DIST		= generic.in
+EXTRA_DIST		= generic.in suse
 
 target_INIT		= generic
 
Index: openais-1.1.4/init/suse
===================================================================
--- /dev/null
+++ openais-1.1.4/init/suse
@@ -0,0 +1,208 @@
+#!/bin/bash
+#
+# 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 iscsi
+# Required-Stop: $network
+# Default-Start: 3 5
+# Default-Stop: 0 6
+# Should-Stop: $syslog sshd drbd $named $remote_fs logd xendomains xend iscsi
+### 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
+	while pidofproc $SBD_BIN ; do
+		sleep 1
+	done
+	echo -n "done "
+}
+
+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() {
+    local waitcount=0
+    local iter=0
+    local stopsbd=1
+    local sig=TERM
+    echo -n $"Stopping OpenAIS/corosync daemon ($prog): "
+
+    while internal_status; do
+	if [ $waitcount -eq 0 ]; then
+           c_pid="`pidofproc $exec`"
+	   if [ $iter -gt 0 ]; then
+	      if [ $do_force = 1 ]; then
+	         echo -n " Escalating... "
+	         sig=KILL
+	         # Do not stop SBD if we forcibly killed corosync; other
+	         # nodes may still have a legitimate desire to STONITH us.
+	         stopsbd=0
+	      fi
+	      if [ $do_forever = 0 ]; then
+	     	 echo "Failed"
+		 return 1
+	      fi
+	   fi
+	   # Start a new cycle:
+	   kill -$sig $c_pid
+	   waitcount=0
+	   iter=$[iter+1]
+	fi
+
+	waitcount=$[waitcount+1]
+	echo -n "."
+	sleep 2
+    done
+
+    if [ $stopsbd = 1 ]; then
+    	StopSBD
+    fi
+
+    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
openSUSE Build Service is sponsored by