#!/usr/bin/env sh to_backup() { # NOOP } to_master() { # NOOP } if [ ! -f "$1" ]; then echo "Config file does not exist" exit 1 fi source "$1" if [ "$?" -gt "0" ]; then echo "loading config file caused an error" exit 1 fi old_state="" while true; do state="$(ifconfig | awk '/carp/ { print $2 }')" if [ "$old_state" = "${state}" ]; then sleep 10 continue fi if [ "$state" = "BACKUP" ]; then logger "going into backup mode" to_backup elif [ "$state" = "MASTER" ]; then logger "going into master mode" to_master else logger "unknown state '${state}'!" fi old_state="$state" sleep 10 done