Return to Snippet

Revision: 1913
at November 21, 2006 02:15 by smoothnoodle


Initial Code
#!/bin/bash

###
# Stop heartbeatd so that failoverd initiates IPFailover
# leaving network interfaces intact.
###
# Setup mail
###
C_NAME=`/usr/sbin/scutil --get ComputerName`
NOTIFY="[email protected]"
WARNING="Heartbeatd has been halted - Failover process initiated"
###
# End Setup mail
###
HEARTD=`/bin/ps -axcu | /usr/bin/grep -i heartbeatd > /dev/null; echo $?`

if [ ! ${HEARTD} -eq 0 ];
then
        echo "heartbeatd is not running - uh oh..."
        /usr/bin/logger "FAILOVER: heartbeatd is not running - uh oh..."

        echo From: ${C_NAME} - ${WARNING} > /tmp/heartbeat_warning.txt | mail -s \
        "FAILOVER PROCESS: Heartbeatd was not running" ${NOTIFY} < /tmp/heartbeat_warning.txt
else
        launchctl unload /Library/LaunchDaemons/uk.ac.rave.heartbeatd.plist
        while [ $(/bin/ps -axcu | /usr/bin/grep -i heartbeatd > /dev/null; echo $?) -eq 0 ];
        do
        echo "Halting heartbeatd"
        /usr/bin/logger "FAILOVER: Halting heartbeatd"
        /bin/sleep 5
        done

        echo "heartbeatd has been halted"
        /usr/bin/logger "FAILOVER: heartbeatd has been halted"

        rm -f /var/run/heartbeatd.pid

        echo From: ${C_NAME} - ${WARNING} > /tmp/heartbeat_warning.txt | mail -s \
        "FAILOVER PROCESS: Heartbeat halted - failover in process" ${NOTIFY} < /tmp/heartbeat_warning.txt
fi
exit 0

Initial URL

                                

Initial Description
Obviously you need to have heartbeatd handled by Launchd

Initial Title
Disable heartbeatd using Launchd and email administrator

Initial Tags
Bash, osx

Initial Language
Bash