/ Published in: Bash
Obviously you need to have heartbeatd handled by Launchd
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/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