From: Heiko Z. <smi...@us...> - 2015-12-12 21:52:03
|
Update of /cvsroot/devil-linux/build/scripts/scripts In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv15444/scripts/scripts Modified Files: heartbeat Added Files: logd Log Message: iptables needs kmod binaries in /sbin updating heartbeat to the latest version and adding required dependencies Index: heartbeat =================================================================== RCS file: /cvsroot/devil-linux/build/scripts/scripts/heartbeat,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- heartbeat 14 May 2008 14:10:50 -0000 1.6 +++ heartbeat 12 Dec 2015 21:52:00 -0000 1.7 @@ -1,6 +1,5 @@ #!/bin/sh # -# $Id$ # # heartbeat Start high-availability services # @@ -13,12 +12,13 @@ # We don't hate anyone, and like for everyone to use # our software, no matter what OS or distribution you're using. # -# chkconfig: 2345 75 05 +# chkconfig: - 75 05 # description: Startup script high-availability services. # processname: heartbeat # pidfile: /var/run/heartbeat.pid # config: /etc/ha.d/ha.cf # + ### BEGIN INIT INFO # Description: heartbeat is a basic high-availability subsystem. # It will start services at initialization, and when machines go up @@ -32,33 +32,25 @@ # - UDP/IP multicast (ethernet, etc) # - Unicast heartbeats # - "ping" heartbeats (for routers, switches, etc.) -# (to be used for breaking ties in 2-node systems +# (to be used for breaking ties in 2-node systems # and monitoring networking availability) -# # Short-Description: High-availability services. -# Provides: heartbeat HA -# Required-Start: $network $time $syslog -# Should-Start: xntpd -# Required-Stop: $network $time $syslog -# Default-Start: 3 5 -# Default-Stop: 0 6 +# Provides: heartbeat HA +# Required-Start: $remote_fs $network $time $syslog +# Should-Start: openhpid +# Required-Stop: $remote_fs $network $time $syslog +# Should-Stop: openhpid +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 ### END INIT INFO -# settings -source /etc/sysconfig/config - -# parameters -CONFIGNAME=HEARTBEAT - -eval START=\$START_$CONFIGNAME +test -r /lib/lsb/init-functions && . /lib/lsb/init-functions -# Determine the base and follow a runlevel link name. -base=${0##*/} -link=${base#*[SK][0-9][0-9]} +HEARTBEAT=/usr/libexec/heartbeat/heartbeat -# Force execution if not called by a runlevel directory. -test $link = $base && START=yes -test "$START" = "yes" || exit 0 +[ -r /etc/sysconfig/heartbeat ] && . /etc/sysconfig/heartbeat +[ -r /etc/sysconfig/pacemaker ] && . /etc/sysconfig/pacemaker +[ -r /etc/sysconfig/sbd ] && . /etc/sysconfig/sbd HA_DIR=/etc/ha.d; export HA_DIR CONFIG=$HA_DIR/ha.cf @@ -67,25 +59,52 @@ LOCKDIR=/var/lock/subsys RUNDIR=/var/run +LRMADMIN=/usr/sbin/lrmadmin +SBD_BIN=/usr/sbin/sbd -# Echo without putting a newline on the end -EchoNoNl() { - Echo "$@" +StartSBD() { + test -x $SBD_BIN || return + test -z "$SBD_DEVICE" && return + + # Would be nice if sbd would + # cleanly handle double start internally + ps -eo cmd | grep "^$SBD_BIN -d" > /dev/null && return + + echo -n "Starting SBD - " + local ERROR + if ! ERROR=`$SBD_BIN -d $SBD_DEVICE -D $SBD_OPTS watch 2>&1` ; then + echo "SBD failed to start; aborting." + if [ ! -z "$ERROR" ]; then + echo + echo "$ERROR" + fi + exit 1 + fi } -# Echo with escapes enabled... -EchoEsc() { - Echo "$@" +StopSBD() { + test -x $SBD_BIN || return + test -z "$SBD_DEVICE" && return + + echo -n "Stopping SBD - " + local ERROR + if ! ERROR=`$SBD_BIN -d $SBD_DEVICE -D $SBD_OPTS message LOCAL exit 2>&1` ; then + echo "SBD failed to stop; aborting." + if [ ! -z "$ERROR" ]; then + echo + echo "$ERROR" + fi + exit 1 + fi } echo_failure() { - EchoEsc " Heartbeat failure [rc=$1]. $rc_failed" + echo " Heartbeat failure [rc=$1]. $rc_failed" return $1 } echo_success() { - : Cool! It started! - EchoEsc "$rc_done" + echo "$rc_done" } if @@ -123,25 +142,24 @@ # Set this to a 1 if you want to automatically load kernel modules USE_MODULES=1 -[ -x $HA_BIN/heartbeat ] || exit 0 +[ -x $HEARTBEAT ] || exit 0 # # Some environments like it if we use their functions... # if - [ ! -x $DISTFUNCS ] + [ ! -r $DISTFUNCS ] then # Provide our own versions of these functions status() { - $HA_BIN/heartbeat -s + $HEARTBEAT -s } echo_failure() { - EchoEsc " Heartbeat failure [rc=$1]. $rc_failed" + echo " Heartbeat failure [rc=$1]. $rc_failed" return $1 } echo_success() { - : Cool! It started! - EchoEsc "$rc_done" + echo "$rc_done" } else . $DISTFUNCS @@ -153,55 +171,26 @@ if [ ! -f $CONFIG ] then - EchoNoNl "Heartbeat not configured: $CONFIG not found." + echo -n "Heartbeat not configured: $CONFIG not found." echo_failure 1 exit 0 fi +CRM_ENABLED_RV="" CrmEnabled() { - case `ha_parameter crm | tr '[A-Z]' '[a-z]'` in - y|yes|enable|on|true|1|manual) true;; - *) false;; + test -n "$CRM_ENABLED_RV" && return $CRM_ENABLED_RV + local value + value=`ha_parameter pacemaker | tr '[A-Z]' '[a-z]'` + [ -n "$value" ] || value=`ha_parameter crm | tr '[A-Z]' '[a-z]'` + case $value in + y|yes|enable|on|true|1|manual|respawn) + CRM_ENABLED_RV=0 + return 0 ;; + *) + CRM_ENABLED_RV=1 + return 1 ;; esac } -StartLogd() { - - $HA_BIN/ha_logd -s >/dev/null 2>&1 - - if - [ $? -eq 0 ] - then - Echo "logd is already running" - return 0 - fi - - - $HA_BIN/ha_logd -d >/dev/null 2>&1 - if - [ $? -ne 0 ] - then - Echo "starting logd failed" - fi - -} - -StopLogd() { - $HA_BIN/ha_logd -s >/dev/null 2>&1 - - if - [ $? -ne 0 ] - then - Echo "logd is already stopped" - return 0 - fi - - $HA_BIN/ha_logd -k >/dev/null 2>&1 - if - [ $? -ne 0 ] - then - Echo "stopping logd failed" - fi -} init_watchdog() { if @@ -231,9 +220,9 @@ insmod=no # What do they think /dev/watchdog is named? MISCDEV=`grep ' misc$' /proc/devices | cut -c1-4` - MISCDEV=`Echo $MISCDEV` + MISCDEV=`echo $MISCDEV` WATCHDEV=`ha_parameter watchdog` - WATCHDEV=`Echo $WATCHDEV` + WATCHDEV=`echo $WATCHDEV` if [ "X$WATCHDEV" != X ] then @@ -274,6 +263,33 @@ fi } # init_watchdog_linux() +wait_for_lrmd() { + local maxwait=20 + local i=0 + echo -n "waiting for lrmd to become responsive " + while [ $i -lt $maxwait ]; do + $LRMADMIN -C > /dev/null 2>&1 && + break + sleep 2 + echo -n . + i=$(($i+1)) + done + if [ $i -lt $maxwait ]; then + return 0 + else + echo "lrmd apparently didn't start" + return 1 + fi +} +set_lrmd_options() { + CrmEnabled || return + test -x $LRMADMIN || return + if [ -n "$LRMD_MAX_CHILDREN" ]; then + wait_for_lrmd || return + $LRMADMIN -p max-children $LRMD_MAX_CHILDREN + fi +} + # # Start the heartbeat daemon... @@ -281,7 +297,7 @@ start_heartbeat() { if - ERROR=`$HA_BIN/heartbeat 2>&1` + ERROR=`$HEARTBEAT 2>&1` then : OK else @@ -289,13 +305,20 @@ fi } +mkdir_chmod_chown() +{ + local d=$1 m=$2 o=$3 + test -n "$d" || return + test -d "$d" || mkdir "$d" || return + chmod "$m" "$d" && chown "$o" "$d" +} # # Start Linux-HA # StartHA() { - EchoNoNl "Starting High-Availability services: " + echo -n "Starting High-Availability services: " if CrmEnabled @@ -310,32 +333,40 @@ # Create /dev/watchdog and load module if we should init_watchdog fi - rm -f $RUNDIR/ppp.d/* - if - [ ! -d $RUNDIR/heartbeat ] - then - mkdir -p $RUNDIR/heartbeat/ccm - mkdir -p $RUNDIR/heartbeat/crm - chown -R hacluster:haclient $RUNDIR/heartbeat - chmod -R 750 $RUNDIR/heartbeat - fi + ( + # $RUNDIR may be a tmpfs on some systems + umask 027 + + # see http://developerbugs.linux-foundation.org/show_bug.cgi?id=2378 + # HA_RSCTMP is defined in ocf-directories, sourced from ocf-shellfuncs, + # sourced from $HA_DIR/shellfuncs. + mkdir_chmod_chown "$HA_RSCTMP" 1755 root:root + + for d in crm heartbeat heartbeat/ccm heartbeat/crm heartbeat/dopd; do + mkdir_chmod_chown "$RUNDIR/$d" 750 hacluster:haclient + done + ) if [ -f $HA_DIR/ipresources -a ! -f $HA_DIR/haresources ] then mv $HA_DIR/ipresources $HA_DIR/haresources fi + # Start SBD, if enabled. + # Start failure will be fatal (exit this script) + StartSBD # Start heartbeat daemon if start_heartbeat then + set_lrmd_options echo_success return 0 else RC=$? echo_failure $RC if [ ! -z "$ERROR" ]; then - Echo - Echo "$ERROR" + echo + echo "$ERROR" fi return $RC fi @@ -345,11 +376,12 @@ # Ask heartbeat to stop. It will give up its resources... # StopHA() { - EchoNoNl "Stopping High-Availability services: " + echo -n "Stopping High-Availability services: " if - $HA_BIN/heartbeat -k &> /dev/null # Kill it + $HEARTBEAT -k >/dev/null 2>&1 # Kill it then + StopSBD echo_success return 0 else @@ -360,7 +392,7 @@ } StatusHA() { - $HA_BIN/heartbeat -s + $HEARTBEAT -s } StandbyHA() { @@ -384,7 +416,7 @@ if StatusHA >/dev/null 2>&1 then - EchoNoNl "Attempting to enter standby mode" + echo -n "Attempting to enter standby mode" if $HA_NOARCHBIN/hb_standby then @@ -394,7 +426,7 @@ echo_failure $? fi else - Echo "Heartbeat is not currently running." + echo "Heartbeat is not currently running." exit 1 fi } @@ -403,10 +435,10 @@ # Ask heartbeat to restart. It will *keep* its resources # ReloadHA() { - EchoNoNl "Reloading High-Availability services: " + echo -n "Reloading High-Availability services: " if - $HA_BIN/heartbeat -r # Restart, and keep your resources + $HEARTBEAT -r # Restart, and keep your resources then echo_success return 0 @@ -431,11 +463,10 @@ case "$1" in start) - StartLogd RunStartStop pre-start StartHA RC=$? - Echo + echo if [ $RC -eq 0 ] then @@ -446,8 +477,14 @@ ;; standby) - StandbyHA - RC=$?;; + if CrmEnabled; then + echo "use 'crm_stanby -v on' instead" + RC=1 + else + StandbyHA + RC=$? + fi + ;; status) StatusHA @@ -457,37 +494,38 @@ RunStartStop "pre-stop" StopHA RC=$? - Echo + echo if [ $RC -eq 0 ] then rm -f $LOCKDIR/$SUBSYS fi RunStartStop post-stop $RC - StopLogd ;; restart) sleeptime=`ha_parameter deadtime` StopHA - Echo - EchoNoNl Waiting to allow resource takeover to complete: - sleep $sleeptime - sleep 10 # allow resource takeover to complete (hopefully). - echo_success - Echo + if ! CrmEnabled ; then + echo + echo -n "Waiting to allow resource takeover to complete:" + sleep $sleeptime + sleep 10 # allow resource takeover to complete (hopefully). + echo_success + fi + echo StartHA - Echo + echo ;; force-reload|reload) ReloadHA - Echo + echo RC=$? ;; *) - Echo "Usage: $0 {start|stop|status|restart|reload|force-reload}" + echo "Usage: $0 {start|stop|status|restart|reload|force-reload}" exit 1 esac --- NEW FILE: logd --- #!/bin/sh # # # logd Start logd (non-blocking log service) # # Author: Dejan Muhamedagic <dmu...@su...> # (After the heartbeat init script) # License: GNU General Public License (GPL) # # This script works correctly under SuSE, Debian, # Conectiva, Red Hat and a few others. Please let me know if it # doesn't work under your distribution, and we'll fix it. # We don't hate anyone, and like for everyone to use # our software, no matter what OS or distribution you're using. # # chkconfig: 2345 19 21 # description: Startup script logd service. # processname: ha_logd # pidfile: /var/run/logd.pid # config: /etc/logd.cf # ### BEGIN INIT INFO # Description: ha_logd is a non-blocking logging daemon. # It can log messages either to a file or through syslog # daemon. # Short-Description: ha_logd logging daemon # Provides: ha_logd # Required-Start: $network $syslog $remote_fs # Required-Stop: $network $syslog $remote_fs # X-Start-Before: heartbeat openais corosync # Default-Start: 3 5 # Default-Stop: 0 1 6 ### END INIT INFO # settings source /etc/sysconfig/config # parameters CONFIGNAME=LDIRECTORD eval START=\$START_$CONFIGNAME # Determine the base and follow a runlevel link name. base=${0##*/} link=${base#*[SK][0-9][0-9]} # Force execution if not called by a runlevel directory. test $link = $base && START=yes test "$START" = "yes" || exit 0 LOGD_CFG=/etc/logd.cf LOGD_OPT="" [ -f "$LOGD_CFG" ] && LOGD_OPT="-c $LOGD_CFG" [ -d /usr/lib ] && LOGD_BIN="/usr/lib/heartbeat/ha_logd" [ -d /usr/lib64 ] && LOGD_BIN="/usr/lib64/heartbeat/ha_logd" if [ ! -f $LOGD_BIN ]; then echo -n "ha_logd not installed." exit 5 fi StartLogd() { echo -n "Starting ha_logd: " $LOGD_BIN -s >/dev/null 2>&1 if [ $? -eq 0 ]; then echo "logd is already running" return 0 fi $LOGD_BIN -d $LOGD_OPT >/dev/null 2>&1 if [ $? -ne 0 ]; then echo "starting logd failed" exit 1 fi echo "ok" exit 0 } StopLogd() { echo -n "Stopping ha_logd: " $LOGD_BIN -s >/dev/null 2>&1 if [ $? -ne 0 ]; then echo "logd is already stopped" return 0 fi $LOGD_BIN -k >/dev/null 2>&1 if [ $? -ne 0 ]; then echo "stopping logd failed" exit 1 fi echo "stopped" exit 0 } StatusLogd() { $LOGD_BIN -s exit $? } case "$1" in start) StartLogd ;; status) StatusLogd ;; stop) StopLogd ;; restart) sleeptime=1 $0 stop && sleep $sleeptime && $0 start echo ;; try-restart) $0 status && $0 restart ;; *) echo "Usage: $0 {start|stop|status|restart}" exit 1 esac |