initial commit
This commit is contained in:
parent
4d82e50db8
commit
0d28f8880c
|
@ -0,0 +1,15 @@
|
||||||
|
NAME = carp_faillover
|
||||||
|
DESTDIR ?= /usr/local
|
||||||
|
prefix ?= ${DESTDIR}/usr/local
|
||||||
|
exec_prefix ?= ${prefix}
|
||||||
|
bindir ?= ${exec_prefix}/bin
|
||||||
|
sysconfdir ?= ${prefix}/etc/${NAME}
|
||||||
|
datarootdir ?= ${prefix}/share
|
||||||
|
datadir ?= ${datarootdir}/${NAME}
|
||||||
|
|
||||||
|
install:
|
||||||
|
install -D ${datadir}
|
||||||
|
install carp_failover.conf ${datadir}
|
||||||
|
install carp_failover ${exec_prefix}
|
||||||
|
|
||||||
|
.PHONY: install
|
|
@ -0,0 +1,40 @@
|
||||||
|
#!/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
|
|
@ -0,0 +1,9 @@
|
||||||
|
# Set the action when the node changes to BACKUP state.
|
||||||
|
to_backup() {
|
||||||
|
logger "changed to backup"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set the action when the node changes to MASTER state.
|
||||||
|
to_master() {
|
||||||
|
logger "changed to master"
|
||||||
|
}
|
Loading…
Reference in New Issue