Hi guys, this is a slightly revamped init script and it merges both init/generic and init/redhat.
It is LSB compliant, with full chkconfig and LSB headers and return codes. This isn´t the final init, but it´s a quick drop-in replacement for testing. In order to be plugged in into corosync, it needs to be become an init.in and replace a bunch of hard coded paths with proper substitute from configure invocation (easy stuff anyway). The script works fine in Fedora and should work as well in Debian/Ubuntu environments. None of the commands executed in there use anything distro specific and in theory it could also replace the montavista init script (that uses specific Debian based tools such as start-stop-daemon). Fabio
#!/bin/bash # Authors: # Andrew Beekhof <[email protected]> # Fabio M. Di Nitto <[email protected]> # # License: Revised BSD # chkconfig: 2345 20 20 # description: Corosync Cluster Engine # processname: corosync # ### BEGIN INIT INFO # Provides: corosync # Required-Start: $network # Should-Start: $syslog # Required-Stop: $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # 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 /etc/sysconfig ]; then [ -f /etc/rc.d/init.d/functions ] && . /etc/rc.d/init.d/functions [ -f /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog [ -z "$LOCK_FILE" ] && LOCK_FILE="/var/lock/subsys/$prog" fi # deb based distros if [ -d /etc/default ]; then [ -f /etc/default/$prog ] && . /etc/default/$prog [ -z "$LOCK_FILE" ] && LOCK_FILE="/var/lock/$prog" fi start() { echo -n "Starting $desc ($prog): " # 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 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 > /var/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 /var/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
_______________________________________________ Openais mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/openais
