Steven Dake wrote:
> ya logic sounds good
> 
> can you do the init.in parts and post a patch that removes the other
> init scripts?
> 
> Regards
> -steve
> 

There you go...

One question: do you want the init script to be also installed by the
Makefile?

It´s a few extra lines changes.. nothing spectacular. IMHO we should do
it, but I didn´t want to change the current behavior.

Fabio
Index: init/generic.in
===================================================================
--- init/generic.in     (revision 2549)
+++ init/generic.in     (working copy)
@@ -1,145 +1,146 @@
-#!/bin/sh
+#!/bin/bash
+
+# Authors:
+#  Andrew Beekhof <[email protected]>
+#  Fabio M. Di Nitto <[email protected]>
 #
-# corosync       Start the Corosync Cluster Engine
+# License: Revised BSD
+
+# chkconfig: 2345 20 20
+# description: Corosync Cluster Engine
+# processname: corosync
 #
-# Author:       Andrew Beekhof <[email protected]>
-# License:      Revised BSD
-#
-# chkconfig: - 20 20
-# processname:  corosync
-# description:  Corosync Cluster Engine
-#
 ### BEGIN INIT INFO
-# Description: corosync....
-#
-# Short-Description: Corosync Cluster Engine.
-# Provides: corosync
-# Required-Start: $network
-# Should-Start: $syslog
-# Required-Stop: $network
-# Default-Start: 3 5
-# Default-Stop: 0 6
+# Provides:            corosync
+# Required-Start:      $network
+# Should-Start:                $syslog
+# Required-Stop:       $network
+# Default-Start:       2 3 4 5
+# Default-Stop:                0 1 6
+# Short-Description:   Starts and stops Corosync Cluster Engine.
+# Description:         Starts and stops Corosync Cluster Engine.
 ### END INIT INFO
 
-do_force=0
+desc="Corosync Cluster Engine"
 prog="corosync"
-lockfile="/var/lock/subsys/$prog"
 
-internal_status() {
-    killall -0 corosync > /dev/null 2>&1
-    return $?
+# set secure PATH
+PATH="/sbin:/bin:/usr/sbin:/usr/bin:@SBINDIR@"
+
+success()
+{
+       echo -ne "[  OK  ]\r"
 }
 
-status() {
-    if
-       ! internal_status
-    then
-       echo "Stopped"
-       return 7
-    fi
+failure()
+{
+       echo -ne "[FAILED]\r"
+}
 
-    echo "Running"
-    return 0
+status()
+{
+       pid=$(pidof $1 2>/dev/null)
+       rtrn=$?
+       if [ $rtrn -ne 0 ]; then
+               echo "$1 is stopped"
+       else
+               echo "$1 (pid $pid) is running..."
+       fi
+       return $rtrn
 }
 
-start() {
-    echo -n $"Starting Corosync Cluster Engine ($prog): "
-    if
-       ! internal_status
-    then
-       echo -n "starting... "
-       $prog 2>&1 > /dev/null 2>&1
-       echo -n "rc=$?: "
-    fi
+# rpm based distros
+if [ -d @SYSCONFDIR@/sysconfig ]; then
+       [ -f @SYSCONFDIR@/rc.d/init.d/functions ] && . 
@SYSCONFDIR@/rc.d/init.d/functions
+       [ -f @SYSCONFDIR@/sysconfig/$prog ] && . @SYSCONFDIR@/sysconfig/$prog
+       [ -z "$LOCK_FILE" ] && LOCK_FILE="@LOCALSTATEDIR@/lock/subsys/$prog"
+fi
 
-    sleep 2 # give it time to fail... $? isn't definitive
+# deb based distros
+if [ -d @SYSCONFDIR@/default ]; then
+       [ -f @SYSCONFDIR@/default/$prog ] && . @SYSCONFDIR@/default/$prog
+       [ -z "$LOCK_FILE" ] && LOCK_FILE="@LOCALSTATEDIR@/lock/$prog"
+fi
 
-    if
-       internal_status
-    then
-       echo "OK"
-       return 0
-    fi
+start()
+{
+       echo -n "Starting $desc ($prog): "
 
-    echo "Failed"
-    return 1
-}
+       # most recent distributions use tmpfs for @LOCALSTATEDIR@/run
+       # to avoid to clean it up on every boot.
+       # they also assume that init scripts will create
+       # required subdirectories for proper operations
+       mkdir -p @LOCALSTATEDIR@/run
 
-do_force=0
-do_forever=1
+       if status $prog > /dev/null 2>&1; then
+               success
+       else
+               $prog > /dev/null 2>&1
 
-stop() {
-    echo -n $"Stopping Corosync Cluster Engine ($prog): "
+               # give it time to fail
+               sleep 2
+               if status $prog > /dev/null 2>&1; then
+                       touch $LOCK_FILE
+                       pidof $prog > @LOCALSTATEDIR@/run/$prog.pid
+                       success
+               else
+                       failure
+                       rtrn=1
+               fi
+       fi
+       echo
+}
 
-    killall -QUIT corosync
+stop()
+{
+       echo -n "Signaling $desc ($prog) to terminate: "
+       killall -TERM $prog > /dev/null 2>&1
+       success
+       echo
 
-    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 "Waiting for $prog services to unload:"
+       while status $prog > /dev/null 2>&1; do
+               sleep 1
                echo -n "."
-           else
-               rm -f "$lockfile"
-               echo "OK"
-               return 0
-           fi
        done
 
-       if [ $do_force = 1 ]; then
-           echo -n "Escalating... "
-           killall -KILL corosync
-           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
-
-    rm -f "$lockfile"
-    echo "OK"
-    return 0
+       rm -f $LOCK_FILE
+       rm -f @LOCALSTATEDIR@/run/$prog.pid
+       success
+       echo
 }
 
-restart() {
-    stop
-    start
+restart()
+{
+       stop
+       start
 }
 
+rtrn=0
+
 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
+start)
+       start
+;;
+restart|reload|force-reload)
+       restart
+;;
+condrestart|try-restart)
+       if status $prog > /dev/null 2>&1; then
+               restart
+       fi
+;;
+status)
+       status $prog
+       rtrn=$?
+;;
+stop)
+       stop
+;;
+*)
+       echo "usage: $0 
{start|stop|restart|reload|force-reload|condrestart|try-restart|status}"
+       rtrn=2
+;;
 esac
+
+exit $rtrn
Index: init/redhat
===================================================================
--- init/redhat (revision 2549)
+++ init/redhat (working copy)
@@ -1,71 +0,0 @@
-#!/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"
-DAEMON_COREFILE_LIMIT=unlimited
-
-[ -x "$exec" ] || exit 0
-
-start() {
-    echo -n $"Starting Corosync Cluster Engine ($prog): "
-    daemon $exec
-    retval=$?
-    [ "$retval" -eq 0 ] && touch "$lockfile"
-    echo
-    return $retval
-}
-
-stop() {
-    echo -n $"Stopping Corosync Cluster Engine ($prog): "
-    # If no signal is specified, -TERM is used but _also_ -KILL 3s later
-    # This is far too aggressive for a cluster resource manager running on top 
of Corosync
-    killproc $prog -TERM
-    echo
-
-    echo -n $"Waiting for services to unload:"
-    while
-        pidofproc $prog > /dev/null 2>&1
-    do
-        sleep 2
-    done
-
-    success $"$base shutdown"
-    echo
-
-    rm -f "$lockfile"
-    return 0
-}
-
-restart() {
-    stop
-    start
-}
-
-case "$1" in
-    start|stop|restart)
-        $1
-        ;;
-    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|status}"
-        exit 2
-esac
Index: init/Makefile.am
===================================================================
--- init/Makefile.am    (revision 2549)
+++ init/Makefile.am    (working copy)
@@ -34,4 +34,18 @@
 
 MAINTAINERCLEANFILES   = Makefile.in
 
-EXTRA_DIST             = generic mvlcge README redhat
+EXTRA_DIST             = generic.in
+
+target_INIT            = generic
+
+%: %.in Makefile
+       rm -f $...@-t $@
+       sed \
+               -e 's#@''sbin...@#$(sbindir)#g' \
+               -e 's#@''sysconf...@#$(sysconfdir)#g' \
+               -e 's#@''localstate...@#$(localstatedir)#g' \
+           $< > $...@-t
+       chmod 0755 $...@-t
+       mv $...@-t $@
+
+all-local: $(target_INIT)
Index: init/generic
===================================================================
--- init/generic        (revision 2549)
+++ init/generic        (working copy)
@@ -1,145 +0,0 @@
-#!/bin/sh
-#
-# corosync       Start the Corosync Cluster Engine
-#
-# Author:       Andrew Beekhof <[email protected]>
-# License:      Revised BSD
-#
-# chkconfig: - 20 20
-# processname:  corosync
-# description:  Corosync Cluster Engine
-#
-### BEGIN INIT INFO
-# Description: corosync....
-#
-# Short-Description: Corosync Cluster Engine.
-# Provides: corosync
-# Required-Start: $network
-# Should-Start: $syslog
-# Required-Stop: $network
-# Default-Start: 3 5
-# Default-Stop: 0 6
-### END INIT INFO
-
-do_force=0
-prog="corosync"
-lockfile="/var/lock/subsys/$prog"
-
-internal_status() {
-    killall -0 corosync > /dev/null 2>&1
-    return $?
-}
-
-status() {
-    if
-       ! internal_status
-    then
-       echo "Stopped"
-       return 7
-    fi
-
-    echo "Running"
-    return 0
-}
-
-start() {
-    echo -n $"Starting Corosync Cluster Engine ($prog): "
-    if
-       ! internal_status
-    then
-       echo -n "starting... "
-       $prog 2>&1 > /dev/null 2>&1
-       echo -n "rc=$?: "
-    fi
-
-    sleep 2 # give it time to fail... $? isn't definitive
-
-    if
-       internal_status
-    then
-       echo "OK"
-       return 0
-    fi
-
-    echo "Failed"
-    return 1
-}
-
-do_force=0
-do_forever=1
-
-stop() {
-    echo -n $"Stopping Corosync Cluster Engine ($prog): "
-
-    killall -QUIT corosync
-
-    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"
-               echo "OK"
-               return 0
-           fi
-       done
-
-       if [ $do_force = 1 ]; then
-           echo -n "Escalating... "
-           killall -KILL corosync
-           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
-
-    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
Index: init/README
===================================================================
--- init/README (revision 2549)
+++ init/README (working copy)
@@ -1,6 +0,0 @@
-This directory contains init scripts used to start and stop the Corosync 
Cluster
-Engine.
-
-redhat contains an init script for Red Hat systems.
-mvlcge contains an init script for MontaVista Linux systems.
-generic contains an init script for Generic Systems.
Index: init/mvlcge
===================================================================
--- init/mvlcge (revision 2549)
+++ init/mvlcge (working copy)
@@ -1,26 +0,0 @@
-#! /bin/sh
-#
-# Application Interface Specification Startup
-# chkconfig: 2345 20 20
-
-PATH=/bin:/usr/bin:/sbin:/usr/sbin
-
-test -f /usr/sbin/corosync | exit 0
-
-case "$1" in
-       start)
-               echo -n "Starting Corosync Cluster Engine: "
-               start-stop-daemon --start --quiet --exec /usr/sbin/corosync
-               echo "."
-
-               ;;
-               stop)
-               echo -n "Stopping Corosync Cluster Engine: "
-               start-stop-daemon --stop --quiet --exec /usr/sbin/corosync
-               echo "."
-                       ;;
-               *)
-               echo "Usage: /etc/init.d/corosync {start|stop}" >&2
-               exit 1
-               ;;
-esac
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to