Re: [PATCH] init: major cleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ACK

Fabio M. Di Nitto napsal(a):
From: "Fabio M. Di Nitto" <fdinitto@xxxxxxxxxx>

- rename generic.in and notifyd.in to corosync.in and corosync-notifyd.in
  (makes build simpler)
- fix sysvinit corosync.in sleep time to include a check for when IPC
  are ready and drop cman bits (there is no cman with corosync 2.0)
- corosync-notifyd.service should always start after corosync.service
- corosync.service should always start after network
- corosync.service uses init script wrapper
- install/ship sysvinit as wrappers for systemd in /usr/share/corosync
  when necessary
- change the build system to deal with all of the above

Signed-off-by: Fabio M. Di Nitto <fdinitto@xxxxxxxxxx>
---
 TODO                             |    1 -
 configure.ac                     |    9 ++
 corosync.spec.in                 |    3 +
 init/Makefile.am                 |   32 +++----
 init/corosync-notifyd.in         |  153 +++++++++++++++++++++++++++++++
 init/corosync-notifyd.service.in |    1 +
 init/corosync.in                 |  178 ++++++++++++++++++++++++++++++++++++
 init/corosync.service.in         |    7 +-
 init/generic.in                  |  184 --------------------------------------
 init/notifyd.in                  |  153 -------------------------------
 10 files changed, 360 insertions(+), 361 deletions(-)
 create mode 100755 init/corosync-notifyd.in
 create mode 100755 init/corosync.in
 delete mode 100755 init/generic.in
 delete mode 100755 init/notifyd.in

diff --git a/TODO b/TODO
index 18a8a08..c831948 100644
--- a/TODO
+++ b/TODO
@@ -17,7 +17,6 @@
 * porting of qdisk to votequorum and eventually finalize qdevice API
    in votequorum. (Fabio)
 * Cleaner shutdown process -> free memory (Fabio)
-* Merge init and systemd stuff (Fabio)
--------------------------------------
  Current priority list for Needle 2.X
diff --git a/configure.ac b/configure.ac
index f2222b2..7ce168f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -290,6 +290,11 @@ AC_ARG_WITH([systemddir],
 	[ SYSTEMDDIR="$withval" ],
 	[ SYSTEMDDIR="/lib/systemd/system" ])
+AC_ARG_WITH([initwrappersdir],
+	[  --with-initwrappersdir=DIR   : path to init wrappers files directory. ],
+	[ INITWRAPPERSDIR="$withval" ],
+	[ INITWRAPPERSDIR="$datarootdir/corosync" ])
+
 AC_ARG_ENABLE([snmp],
        [  --enable-snmp                   : SNMP protocol support ],
        [ default="no" ])
@@ -585,6 +590,8 @@ LDFLAGS="$ENV_LDFLAGS $COVERAGE_LDFLAGS $OS_LDFLAGS"
 # substitute what we need:
 AC_SUBST([INITDDIR])
 AC_SUBST([SYSTEMDDIR])
+INITWRAPPERSDIR=$(eval echo ${INITWRAPPERSDIR})
+AC_SUBST([INITWRAPPERSDIR])
AC_SUBST([SOMAJOR])
 AC_SUBST([SOMINOR])
@@ -631,6 +638,8 @@ 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([  System systemd directory = ${SYSTEMDDIR}])
+AC_MSG_RESULT([  System init wraps dir    = ${INITWRAPPERSDIR}])
 AC_MSG_RESULT([  corosync config dir      = ${COROSYSCONFDIR}])
 AC_MSG_RESULT([  Features                 =${PACKAGE_FEATURES}])
 AC_MSG_RESULT([])
diff --git a/corosync.spec.in b/corosync.spec.in
index 4062351..1c99d20 100644
--- a/corosync.spec.in
+++ b/corosync.spec.in
@@ -169,6 +169,9 @@ fi
 %if %{with systemd}
 %{_unitdir}/corosync.service
 %{_unitdir}/corosync-notifyd.service
+%dir %{_datadir}/corosync
+%{_datadir}/corosync/corosync
+%{_datadir}/corosync/corosync-notifyd
 %else
 %{_initrddir}/corosync
 %{_initrddir}/corosync-notifyd
diff --git a/init/Makefile.am b/init/Makefile.am
index 00d56d4..8e4d4c7 100644
--- a/init/Makefile.am
+++ b/init/Makefile.am
@@ -34,38 +34,30 @@
MAINTAINERCLEANFILES = Makefile.in -EXTRA_DIST = generic.in notifyd.in corosync.service.in corosync-notifyd.service.in
+EXTRA_DIST		= corosync.in corosync-notifyd.in corosync.service.in corosync-notifyd.service.in
if INSTALL_SYSTEMD
-systemdconfdir = $(SYSTEMDDIR)
-systemdconf_DATA = corosync.service corosync-notifyd.service
+systemdconfdir	   = $(SYSTEMDDIR)
+systemdconf_DATA   = corosync.service corosync-notifyd.service
+initscriptdir	   = $(INITWRAPPERSDIR)
 else
-target_INIT		= generic notifyd
+initscriptdir	   = $(INITDDIR)
 endif
+initscript_SCRIPTS  = corosync corosync-notifyd
%: %.in Makefile
 	rm -f $@-t $@
-	sed \
+	cp $< $@-t
+	sed -i \
 		-e 's#@''SBINDIR@#$(sbindir)#g' \
 		-e 's#@''SYSCONFDIR@#$(sysconfdir)#g' \
 		-e 's#@''INITDDIR@#$(INITDDIR)#g' \
+		-e 's#@''INITWRAPPERSDIR@#$(INITWRAPPERSDIR)#g' \
 		-e 's#@''LOCALSTATEDIR@#$(localstatedir)#g' \
-	    $< > $@-t
+	    $@-t
 	mv $@-t $@
-all-local: $(target_INIT) $(systemdconf_DATA)
+all-local: $(initscript_SCRIPTS) $(systemdconf_DATA)
clean-local:
-	rm -rf $(target_INIT) $(systemdconf_DATA)
-
-if INSTALL_SYSTEMD
-else
-install-exec-local:
-	$(INSTALL) -d $(DESTDIR)/$(INITDDIR)
-	$(INSTALL) -m 755 generic $(DESTDIR)/$(INITDDIR)/corosync
-	$(INSTALL) -m 755 notifyd $(DESTDIR)/$(INITDDIR)/corosync-notifyd
-
-uninstall-local:
-	cd $(DESTDIR)/$(INITDDIR) && \
-		rm -f corosync corosync-notifyd
-endif
+	rm -rf $(initscript_SCRIPTS) $(systemdconf_DATA)
diff --git a/init/corosync-notifyd.in b/init/corosync-notifyd.in
new file mode 100755
index 0000000..84de9ae
--- /dev/null
+++ b/init/corosync-notifyd.in
@@ -0,0 +1,153 @@
+#!/bin/bash
+
+# Authors:
+#  Angus Salkeld <asalkeld@xxxxxxxxxx>
+#
+# License: Revised BSD
+
+# chkconfig: - 23 77
+# description: Corosync Dbus and snmp notifier
+# processname: corosync-notifyd
+#
+### BEGIN INIT INFO
+# Provides:		corosync-notifyd
+# Required-Start:	$corosync $cman
+# Required-Stop:	$corosync $cman
+# Default-Start:
+# Default-Stop:
+# Short-Description:	Starts and stops Corosync Notifier.
+# Description:		Starts and stops Corosync Notifier.
+### END INIT INFO
+
+desc="Corosync Notifier"
+prog="corosync-notifyd"
+
+# 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
+
+# The version of __pids_pidof in /etc/init.d/functions calls pidof with -x
+# This means it matches scripts, including this one.
+# Redefine it here so that status (from the same file) works.
+# Otherwise simultaneous calls to stop() will loop forever
+__pids_pidof() {
+        pidof -c -o $$ -o $PPID -o %PPID "$1" || \
+                pidof -c -o $$ -o $PPID -o %PPID "${1##*/}"
+}
+
+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 $OPTIONS > /dev/null 2>&1
+
+		# give it time to fail
+		sleep 2
+		if status $prog > /dev/null 2>&1; then
+			touch $LOCK_FILE
+			success
+		else
+			failure
+			rtrn=1
+		fi
+	fi
+	echo
+}
+
+stop()
+{
+	! status $prog > /dev/null 2>&1 && return
+
+	echo -n "Signaling $desc ($prog) to terminate: "
+	kill -TERM $(pidof $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
+	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/corosync-notifyd.service.in b/init/corosync-notifyd.service.in
index 26a278a..172653c 100644
--- a/init/corosync-notifyd.service.in
+++ b/init/corosync-notifyd.service.in
@@ -1,6 +1,7 @@
 [Unit]
 Description=Corosync Dbus and snmp notifier
 Wants=corosync.service
+After=corosync.service
[Service]
 EnvironmentFile=@SYSCONFIGDIR@/corosync-notifyd
diff --git a/init/corosync.in b/init/corosync.in
new file mode 100755
index 0000000..a9840bd
--- /dev/null
+++ b/init/corosync.in
@@ -0,0 +1,178 @@
+#!/bin/bash
+
+# Authors:
+#  Andrew Beekhof <abeekhof@xxxxxxxxxx>
+#  Fabio M. Di Nitto <fdinitto@xxxxxxxxxx>
+#
+# License: Revised BSD
+
+# chkconfig: - 20 80
+# description: Corosync Cluster Engine
+# processname: corosync
+#
+### BEGIN INIT INFO
+# Provides:		corosync
+# Required-Start:	$network $syslog
+# Required-Stop:	$network $syslog
+# 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
+
+# The version of __pids_pidof in /etc/init.d/functions calls pidof with -x
+# This means it matches scripts, including this one.
+# Redefine it here so that status (from the same file) works.
+# Otherwise simultaneous calls to stop() will loop forever
+__pids_pidof() {
+        pidof -c -o $$ -o $PPID -o %PPID "$1" || \
+                pidof -c -o $$ -o $PPID -o %PPID "${1##*/}"
+}
+
+cluster_disabled_at_boot()
+{
+       if grep -q nocluster /proc/cmdline && \
+          [ "$(tty)" = "/dev/console" ]; then
+               echo -e "not configured to run at boot"
+               failure
+               return 1
+       fi
+       return 0
+}
+
+wait_for_ipc()
+{
+	try=0
+	while [ "$try" -le "20" ]; do
+		if corosync-cfgtool -s > /dev/null 2>&1; then
+			return 0
+		fi
+		sleep 0.5
+		try=$((try + 1))
+	done
+
+	return 1
+}
+
+start()
+{
+	echo -n "Starting $desc ($prog): "
+
+	! cluster_disabled_at_boot && return
+
+	# 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
+
+		if ! wait_for_ipc; then
+			failure
+			rtrn=1
+		fi
+		touch $LOCK_FILE
+		success
+	fi
+	echo
+}
+
+stop()
+{
+	! status $prog > /dev/null 2>&1 && return
+
+	echo -n "Signaling $desc ($prog) to terminate: "
+	kill -TERM $(pidof $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
+	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/corosync.service.in b/init/corosync.service.in
index 8cc692b..8a43ccf 100644
--- a/init/corosync.service.in
+++ b/init/corosync.service.in
@@ -1,12 +1,13 @@
 [Unit]
 Description=Corosync Cluster Engine
 ConditionKernelCommandLine=!nocluster
-#Conflicts=cman.service
+Requires=network.target
+After=network.target
[Service]
-ExecStart=@SBINDIR@/corosync
+ExecStart=@INITWRAPPERSDIR@/corosync start
+ExecStop=@INITWRAPPERSDIR@/corosync stop
 Type=forking
-#RestartSec=90s
[Install]
 WantedBy=multi-user.target
diff --git a/init/generic.in b/init/generic.in
deleted file mode 100755
index 1ce26f0..0000000
--- a/init/generic.in
+++ /dev/null
@@ -1,184 +0,0 @@
-#!/bin/bash
-
-# Authors:
-#  Andrew Beekhof <abeekhof@xxxxxxxxxx>
-#  Fabio M. Di Nitto <fdinitto@xxxxxxxxxx>
-#
-# License: Revised BSD
-
-# chkconfig: - 20 80
-# description: Corosync Cluster Engine
-# processname: corosync
-#
-### BEGIN INIT INFO
-# Provides:		corosync
-# Required-Start:	$network $syslog
-# Required-Stop:	$network $syslog
-# 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
-
-# The version of __pids_pidof in /etc/init.d/functions calls pidof with -x
-# This means it matches scripts, including this one.
-# Redefine it here so that status (from the same file) works.
-# Otherwise simultaneous calls to stop() will loop forever
-__pids_pidof() {
-        pidof -c -o $$ -o $PPID -o %PPID "$1" || \
-                pidof -c -o $$ -o $PPID -o %PPID "${1##*/}"
-}
-
-cluster_disabled_at_boot()
-{
-       if grep -q nocluster /proc/cmdline && \
-          [ "$(tty)" = "/dev/console" ]; then
-               echo -e "not configured to run at boot"
-               failure
-               return 1
-       fi
-       return 0
-}
-
-start()
-{
-	echo -n "Starting $desc ($prog): "
-
-	! cluster_disabled_at_boot && return
-
-	# 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
-			success
-		else
-			failure
-			rtrn=1
-		fi
-	fi
-	echo
-}
-
-executed_by_cman()
-{
-	[ -f @LOCALSTATEDIR@/run/cman.pid ] || return 0
-
-	read cman_pid foo < @LOCALSTATEDIR@/run/cman.pid
-	if [ "$(pidof $prog)" == "$cman_pid" ];then
-		echo -n "$desc was executed by cman"
-		failure
-		echo
-		return 1
-	fi
-
-	return 0
-}
-
-stop()
-{
-	! status $prog > /dev/null 2>&1 && return
-
-	! executed_by_cman && return
-
-	echo -n "Signaling $desc ($prog) to terminate: "
-	kill -TERM $(pidof $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
-	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/notifyd.in b/init/notifyd.in
deleted file mode 100755
index 84de9ae..0000000
--- a/init/notifyd.in
+++ /dev/null
@@ -1,153 +0,0 @@
-#!/bin/bash
-
-# Authors:
-#  Angus Salkeld <asalkeld@xxxxxxxxxx>
-#
-# License: Revised BSD
-
-# chkconfig: - 23 77
-# description: Corosync Dbus and snmp notifier
-# processname: corosync-notifyd
-#
-### BEGIN INIT INFO
-# Provides:		corosync-notifyd
-# Required-Start:	$corosync $cman
-# Required-Stop:	$corosync $cman
-# Default-Start:
-# Default-Stop:
-# Short-Description:	Starts and stops Corosync Notifier.
-# Description:		Starts and stops Corosync Notifier.
-### END INIT INFO
-
-desc="Corosync Notifier"
-prog="corosync-notifyd"
-
-# 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
-
-# The version of __pids_pidof in /etc/init.d/functions calls pidof with -x
-# This means it matches scripts, including this one.
-# Redefine it here so that status (from the same file) works.
-# Otherwise simultaneous calls to stop() will loop forever
-__pids_pidof() {
-        pidof -c -o $$ -o $PPID -o %PPID "$1" || \
-                pidof -c -o $$ -o $PPID -o %PPID "${1##*/}"
-}
-
-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 $OPTIONS > /dev/null 2>&1
-
-		# give it time to fail
-		sleep 2
-		if status $prog > /dev/null 2>&1; then
-			touch $LOCK_FILE
-			success
-		else
-			failure
-			rtrn=1
-		fi
-	fi
-	echo
-}
-
-stop()
-{
-	! status $prog > /dev/null 2>&1 && return
-
-	echo -n "Signaling $desc ($prog) to terminate: "
-	kill -TERM $(pidof $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
-	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

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss


[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux