]> git.proxmox.com Git - mirror_corosync.git/commitdiff
Clean up init scripts and make a single generic one
authorFabio M. Di Nitto <fdinitto@redhat.com>
Mon, 30 Nov 2009 18:56:28 +0000 (18:56 +0000)
committerFabio M. Di Nitto <fdinitto@redhat.com>
Mon, 30 Nov 2009 18:56:28 +0000 (18:56 +0000)
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2554 fd59a12c-fef9-0310-b244-a6a79926bd2f

configure.ac
corosync.spec.in
init/Makefile.am
init/README [deleted file]
init/generic [deleted file]
init/generic.in [new file with mode: 0755]
init/mvlcge [deleted file]
init/redhat [deleted file]

index 9487103d2f74207cf5ef2c9826420541849baa2c..dc78d1de894b1fd047d5e82f9119148f9da897e1 100644 (file)
@@ -205,6 +205,11 @@ AC_ARG_ENABLE([rdma],
        [ enable_rdma="no" ])
 AM_CONDITIONAL(BUILD_RDMA, test x$enable_rdma = xyes)
 
+AC_ARG_WITH([initddir],
+       [  --with-initddir=DIR     : path to init script directory. ],
+       [ INITDDIR="$withval" ],
+       [ INITDDIR="$sysconfdir/init.d" ])
+
 AC_ARG_WITH([lcrso-dir],
        [  --with-lcrso-dir=DIR    : corosync lcrso files. ],
        [ LCRSODIR="$withval" ],
@@ -390,6 +395,7 @@ CPPFLAGS="$ENV_CPPFLAGS $ANSI_CPPFLAGS $OS_CPPFLAGS"
 LDFLAGS="$ENV_LDFLAGS $COVERAGE_LDFLAGS $OS_LDFLAGS"
 
 # substitute what we need:
+AC_SUBST([INITDDIR])
 AC_SUBST([LCRSODIR])
 AC_SUBST([SOCKETDIR])
 
@@ -438,6 +444,7 @@ AC_MSG_RESULT([  Header files             = ${includedir}])
 AC_MSG_RESULT([  Arch-independent files   = ${datadir}])
 AC_MSG_RESULT([  State information        = ${localstatedir}])
 AC_MSG_RESULT([  System configuration     = ${sysconfdir}])
+AC_MSG_RESULT([  System init.d directory  = ${INITDDIR}])
 AC_MSG_RESULT([  corosync config dir      = ${COROSYSCONFDIR}])
 AC_MSG_RESULT([  LCRSO                    = ${LCRSODIR}])
 AC_MSG_RESULT([  SOCKETDIR                = ${SOCKETDIR}])
index 0b3435ef954bd99fcb49a28c4a25ecb6ed6a93e8..a08c7a21a96c16c1ee679abd27039dcff163a970 100644 (file)
@@ -40,7 +40,8 @@ export rdmacm_CFLAGS=-I/usr/include/rdma \
 export rdmacm_LIBS=-lrdmacm \
 %{configure} \
        --enable-nss \
-       --enable-rdma
+       --enable-rdma \
+       --with-initddir=%{_initddir}
 
 %build
 make %{_smp_mflags}
@@ -49,8 +50,6 @@ make %{_smp_mflags}
 rm -rf %{buildroot}
 
 make install DESTDIR=%{buildroot}
-install -d %{buildroot}%{_initddir}
-install -m 755 init/redhat %{buildroot}%{_initddir}/corosync
 
 ## tree fixup
 # drop static libs
index d495c13a442aaaf730c1fc3a791bbf0e4cd4b60b..2d079d1282c274bec29fce9d45293b0583edfa82 100644 (file)
 
 MAINTAINERCLEANFILES   = Makefile.in
 
-EXTRA_DIST             = generic mvlcge README redhat
+EXTRA_DIST             = generic.in
+
+target_INIT            = generic
+
+%: %.in Makefile
+       rm -f $@-t $@
+       sed \
+               -e 's#@''SBINDIR@#$(sbindir)#g' \
+               -e 's#@''SYSCONFDIR@#$(sysconfdir)#g' \
+               -e 's#@''INITDDIR@#$(INITDDIR)#g' \
+               -e 's#@''LOCALSTATEDIR@#$(localstatedir)#g' \
+           $< > $@-t
+       chmod 0755 $@-t
+       mv $@-t $@
+
+all-local: $(target_INIT)
+
+clean-local:
+       rm -rf $(target_INIT)
+
+install-exec-local:
+       $(INSTALL) -d $(DESTDIR)/$(INITDDIR)
+       $(INSTALL) -m 755 generic $(DESTDIR)/$(INITDDIR)/corosync
+
+uninstall-local:
+       cd $(DESTDIR)/$(INITDDIR) && \
+               rm -f corosync
diff --git a/init/README b/init/README
deleted file mode 100644 (file)
index ef0d408..0000000
+++ /dev/null
@@ -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.
diff --git a/init/generic b/init/generic
deleted file mode 100755 (executable)
index f13be6b..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-#!/bin/sh
-#
-# corosync       Start the Corosync Cluster Engine
-#
-# Author:       Andrew Beekhof <abeekhof@suse.de>
-# 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
diff --git a/init/generic.in b/init/generic.in
new file mode 100755 (executable)
index 0000000..d175f22
--- /dev/null
@@ -0,0 +1,146 @@
+#!/bin/bash
+
+# Authors:
+#  Andrew Beekhof <abeekhof@redhat.com>
+#  Fabio M. Di Nitto <fdinitto@redhat.com>
+#
+# License: Revised BSD
+
+# chkconfig: - 20 20
+# description: Corosync Cluster Engine
+# processname: corosync
+#
+### BEGIN INIT INFO
+# Provides:            corosync
+# Required-Start:      $network
+# Should-Start:                $syslog
+# Required-Stop:       $network
+# Default-Start:
+# Default-Stop:
+# Short-Description:   Starts and stops Corosync Cluster Engine.
+# Description:         Starts and stops Corosync Cluster Engine.
+### END INIT INFO
+
+desc="Corosync Cluster Engine"
+prog="corosync"
+
+# set secure PATH
+PATH="/sbin:/bin:/usr/sbin:/usr/bin:@SBINDIR@"
+
+success()
+{
+       echo -ne "[  OK  ]\r"
+}
+
+failure()
+{
+       echo -ne "[FAILED]\r"
+}
+
+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
+}
+
+# rpm based distros
+if [ -d @SYSCONFDIR@/sysconfig ]; then
+       [ -f @INITDDIR@/functions ] && . @INITDDIR@/functions
+       [ -f @SYSCONFDIR@/sysconfig/$prog ] && . @SYSCONFDIR@/sysconfig/$prog
+       [ -z "$LOCK_FILE" ] && LOCK_FILE="@LOCALSTATEDIR@/lock/subsys/$prog"
+fi
+
+# deb based distros
+if [ -d @SYSCONFDIR@/default ]; then
+       [ -f @SYSCONFDIR@/default/$prog ] && . @SYSCONFDIR@/default/$prog
+       [ -z "$LOCK_FILE" ] && LOCK_FILE="@LOCALSTATEDIR@/lock/$prog"
+fi
+
+start()
+{
+       echo -n "Starting $desc ($prog): "
+
+       # 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
+
+       if status $prog > /dev/null 2>&1; then
+               success
+       else
+               $prog > /dev/null 2>&1
+
+               # 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
+}
+
+stop()
+{
+       echo -n "Signaling $desc ($prog) to terminate: "
+       killall -TERM $prog > /dev/null 2>&1
+       success
+       echo
+
+       echo -n "Waiting for $prog services to unload:"
+       while status $prog > /dev/null 2>&1; do
+               sleep 1
+               echo -n "."
+       done
+
+       rm -f $LOCK_FILE
+       rm -f @LOCALSTATEDIR@/run/$prog.pid
+       success
+       echo
+}
+
+restart()
+{
+       stop
+       start
+}
+
+rtrn=0
+
+case "$1" in
+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
diff --git a/init/mvlcge b/init/mvlcge
deleted file mode 100755 (executable)
index 45fa240..0000000
+++ /dev/null
@@ -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
diff --git a/init/redhat b/init/redhat
deleted file mode 100755 (executable)
index 76f6761..0000000
+++ /dev/null
@@ -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