diff options
author | André Fabian Silva Delgado <emulatorman@lavabit.com> | 2013-05-21 19:02:46 -0300 |
---|---|---|
committer | André Fabian Silva Delgado <emulatorman@lavabit.com> | 2013-05-21 19:02:46 -0300 |
commit | 60326640ae40c84e9e62855001d03b94b516802d (patch) | |
tree | 388952b76054774aa3c507004e448509dd00173d /pcr/corosync/corosync.init | |
parent | 89c0af8305046890734eba2969c9b057e0a6bf9a (diff) | |
download | abslibre-60326640ae40c84e9e62855001d03b94b516802d.tar.gz abslibre-60326640ae40c84e9e62855001d03b94b516802d.tar.bz2 abslibre-60326640ae40c84e9e62855001d03b94b516802d.zip |
corosync: add new package to pcr repo
Diffstat (limited to 'pcr/corosync/corosync.init')
-rwxr-xr-x | pcr/corosync/corosync.init | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/pcr/corosync/corosync.init b/pcr/corosync/corosync.init new file mode 100755 index 000000000..b97186dee --- /dev/null +++ b/pcr/corosync/corosync.init @@ -0,0 +1,126 @@ +#!/bin/bash + +# Authors: +# Eric Renfro <erenfro@gmail.com> + +desc="Corosync Cluster Engine" +prog="corosync" + +# set secure PATH +PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/sbin" + +status() +{ + pid=$(pidof $prog 2>/dev/null) + return $? +} + +if [ -d /etc/default ]; then + [ -f /etc/default/$prog ] && . /etc/default/$prog + [ -z "$LOCK_FILE" ] && LOCK_FILE="/var/lock/$prog" +fi + +cluster_disabled_at_boot() +{ + if grep -q nocluster /proc/cmdline && \ + [ "$(tty)" = "/dev/console" ]; then + return 1 + fi + return 0 +} + +wait_for_ipc() +{ + local try=0 + while [ "$try" -le "20" ]; do + if corosync-cfgtool -s > /dev/null 2>&1; then + return 0 + fi + sleep 0.5 + let try++ + done + + return 1 +} + +start() +{ + echo -n "Starting $desc ($prog): " + + ! cluster_disabled_at_boot && return + + # most recent distributions use tmpfs for /var/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 /var/run + + if status $prog > /dev/null 2>&1; then + rtrn=0 + else + $prog > /dev/null 2>&1 + + if ! wait_for_ipc; then + echo "FAILED" + rtrn=1 + fi + touch $LOCK_FILE + rtrn=0 + fi + echo "OK" +} + +stop() +{ + ! status $prog > /dev/null 2>&1 && return + + echo -n "Signaling $desc ($prog) to terminate: " + kill -TERM $(pidof $prog) > /dev/null 2>&1 + echo "OK" + + 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 + echo " OK" + rtrn=0 +} + +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 + |