diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-03 17:01:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-03 17:01:24 +0000 |
commit | 6dd3dfb79125cd02d02efbce435a6c82e5af92ef (patch) | |
tree | 45084fc83278586f6bbafcb935f92d53f71a6b03 /init/corosync-notifyd.in | |
parent | Initial commit. (diff) | |
download | corosync-6dd3dfb79125cd02d02efbce435a6c82e5af92ef.tar.xz corosync-6dd3dfb79125cd02d02efbce435a6c82e5af92ef.zip |
Adding upstream version 3.1.8.upstream/3.1.8upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'init/corosync-notifyd.in')
-rwxr-xr-x | init/corosync-notifyd.in | 150 |
1 files changed, 150 insertions, 0 deletions
diff --git a/init/corosync-notifyd.in b/init/corosync-notifyd.in new file mode 100755 index 0000000..5f36b9a --- /dev/null +++ b/init/corosync-notifyd.in @@ -0,0 +1,150 @@ +#!@BASHPATH@ + +# Authors: +# Angus Salkeld <asalkeld@redhat.com> +# +# 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 +} + +[ -f @INITCONFIGDIR@/$prog ] && . @INITCONFIGDIR@/$prog + +case '@INITCONFIGDIR@' in + */sysconfig) # rpm based distros + [ -f @INITDDIR@/functions ] && . @INITDDIR@/functions + [ -z "$LOCK_FILE" ] && LOCK_FILE="@LOCALSTATEDIR@/lock/subsys/$prog";; + */default) # deb based distros + [ -z "$LOCK_FILE" ] && LOCK_FILE="@LOCALSTATEDIR@/lock/$prog";; +esac + +# 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 |