Same as the corosync one except for a couple of bits where we need to
differentiate between corosync/aisexec/openais bits (real deamon,
invokation script/expected name).
Also tidy up the spec file as we did for corosync (handle new init,
remove condrestart and small clean up).
Fabio
diff --git a/configure.ac b/configure.ac
index bbc70bd..4ed1fdd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -170,6 +170,11 @@ AC_ARG_ENABLE([coverage],
[ --enable-coverage : coverage analysis of the codebase. ],
[ default="no" ])
+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" ],
@@ -311,6 +316,7 @@ CPPFLAGS="$ENV_CPPFLAGS $OS_CPPFLAGS"
LDFLAGS="$ENV_LDFLAGS $COVERAGE_LDFLAGS $OS_LDFLAGS"
# substitute what we need:
+AC_SUBST([INITDDIR])
AC_SUBST([LCRSODIR])
AC_SUBST([SOMAJOR])
@@ -350,6 +356,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([ Features = ${PACKAGE_FEATURES}])
diff --git a/init/Makefile.am b/init/Makefile.am
index d495c13..aa88e31 100644
--- a/init/Makefile.am
+++ b/init/Makefile.am
@@ -34,4 +34,30 @@
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#@''initd...@#$(INITDDIR)#g' \
+ -e 's#@''localstate...@#$(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)/openais
+
+uninstall-local:
+ cd $(DESTDIR)/$(INITDDIR) && \
+ rm -f openais
diff --git a/init/README b/init/README
deleted file mode 100644
index 59306b6..0000000
--- a/init/README
+++ /dev/null
@@ -1,5 +0,0 @@
-This directory contains init scripts used to start and stop openais.
-
-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
index e0f6b27..0000000
--- a/init/generic
+++ /dev/null
@@ -1,146 +0,0 @@
-#!/bin/sh
-#
-# corosync Start the OpenAIS
-#
-# Author: Andrew Beekhof <[email protected]>
-# License: Revised BSD
-#
-# chkconfig: - 20 20
-# processname: corosync
-# description: OpenAIS
-#
-### BEGIN INIT INFO
-# Description: corosync....
-#
-# Short-Description: OpenAIS
-# 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 OpenAIS ($prog): "
- if
- ! internal_status
- then
- echo -n "starting... "
- export
COROSYNC_DEFAULT_CONFIG_IFACE="openaisserviceenableexperimental:corosync_parser"
- $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 OpenAIS ($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
index 0000000..ac63a5f
--- /dev/null
+++ b/init/generic.in
@@ -0,0 +1,150 @@
+#!/bin/bash
+
+# Authors:
+# Andrew Beekhof <[email protected]>
+# Fabio M. Di Nitto <[email protected]>
+#
+# License: Revised BSD
+
+# chkconfig: - 20 20
+# description: OpenAIS
+# processname: corosync
+#
+### BEGIN INIT INFO
+# Provides: openais
+# Required-Start: $network
+# Should-Start: $syslog
+# Required-Stop: $network
+# Default-Start:
+# Default-Stop:
+# Short-Description: Starts and stops OpenAIS.
+# Description: Starts and stops OpenAIS.
+### END INIT INFO
+
+desc="OpenAIS"
+prog="openais"
+exec="aisexec"
+proc="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 ($exec): "
+
+ # 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 $proc > /dev/null 2>&1; then
+ success
+ else
+ $exec > /dev/null 2>&1
+
+ # give it time to fail
+ sleep 2
+ if status $proc > /dev/null 2>&1; then
+ touch $LOCK_FILE
+ pidof $proc > @LOCALSTATEDIR@/run/$prog.pid
+ success
+ else
+ failure
+ rtrn=1
+ fi
+ fi
+ echo
+}
+
+stop()
+{
+ ! status $proc > /dev/null 2>&1 && return
+
+ echo -n "Signaling $desc ($prog) to terminate: "
+ kill -TERM $(pidof $proc) > /dev/null 2>&1
+ success
+ echo
+
+ echo -n "Waiting for $prog services to unload:"
+ while status $proc > /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
index 00152fa..0000000
--- a/init/mvlcge
+++ /dev/null
@@ -1,27 +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 OpenAIS: "
- export
COROSYNC_DEFAULT_CONFIG_IFACE="openaisserviceenable:openaisparser"
- start-stop-daemon --start --quiet --exec /usr/sbin/corosync
- echo "."
-
- ;;
- stop)
- echo -n "Stopping OpenAIS: "
- start-stop-daemon --stop --quiet --exec /usr/sbin/corosync
- echo "."
- ;;
- *)
- echo "Usage: /etc/init.d/openais {start|stop}" >&2
- exit 1
- ;;
-esac
diff --git a/init/redhat b/init/redhat
deleted file mode 100755
index 403d06f..0000000
--- a/init/redhat
+++ /dev/null
@@ -1,59 +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: OpenAIS
-
-# 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() {
- echo -n $"Starting OpenAIS ($prog): "
- export
COROSYNC_DEFAULT_CONFIG_IFACE="openaisserviceenableexperimental:corosync_parser"
- daemon $exec
- retval=$?
- [ "$retval" -eq 0 ] && touch "$lockfile"
- echo
- return $retval
-}
-
-stop() {
- echo -n $"Stopping OpenAIS ($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
- ;;
- *)
- echo $"Usage: $0
{start|stop|restart|try-restart|condrestart|reload|force-reload|status}"
- exit 2
-esac
diff --git a/openais.spec.in b/openais.spec.in
index 9ba7e1c..be47f16 100644
--- a/openais.spec.in
+++ b/openais.spec.in
@@ -7,7 +7,7 @@ Release: 1%{?alphatag:.%{alphatag}}%{?dist}
License: BSD
Group: System Environment/Base
URL: http://developer.osdl.org/dev/openais/
-Source0:
http://www.osdl.org/downloads/openais-%{version}/openais-%{version}.tar.gz
+Source0:
http://www.osdl.org/downloads/%{name}-%{version}/%{name}-%{version}.tar.gz
# Runtime bits
Requires(post): /sbin/chkconfig
@@ -29,13 +29,14 @@ BuildRequires: autoconf automake
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
%prep
-%setup -q -n openais-%{version}
+%setup -q -n %{name}-%{version}
%if %{buildtrunk}
./autogen.sh
%endif
-%{configure}
+%{configure} \
+ --with-initddir=%{_initddir}
%build
make %{_smp_mflags}
@@ -44,8 +45,6 @@ make %{_smp_mflags}
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}
-mkdir -p %{buildroot}%{_initrddir}
-install -m 755 init/redhat %{buildroot}%{_initrddir}/openais
## tree fixup
# drop static libs
@@ -69,9 +68,6 @@ if [ $1 -eq 0 ]; then
/sbin/chkconfig --del openais || :
fi
-%postun
-[ "$1" -ge "1" ] && %{_initrddir}/openais condrestart &>/dev/null || :
-
%files
%defattr(-,root,root,-)
%doc LICENSE README.amf
@@ -96,7 +92,7 @@ fi
%package -n openaislib
Summary: The openais Standards-Based Cluster Framework libraries
Group: System Environment/Libraries
-Conflicts: openais < 0.91-6
+Requires: %{name} = %{version}-%{release}
%description -n openaislib
This package contains openais libraries.
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais