#!/bin/bash state="$3" intf="$2" [ -n "$state" -a -n "$intf" ] || exit 1 vrrp_dir=/var/state/vrrp_state echo "$state" > $vrrp_dir/"$intf" if grep -q "BACKUP\|MASTER" $vrrp_dir/*; then if grep -q "BACKUP" $vrrp_dir/*; then global="BACKUP" else global="MASTER" fi else if grep -q "INIT" $vrrp_dir/*; then global="INIT" else global="FAULT" fi fi # we can write this state so that other processes can check it echo "$global" > $vrrp_dir/.global lcddev=/dev/lcd hname="$(/bin/uname -n)" hname="${hname%%.*}" [ -c "$lcddev" ] || exit 0 exec 2>/dev/null # write the state on the LCD panel if [ "$global" = "MASTER" ]; then echo -e "\e[H\e[2J${hname}\nVRRP MASTER" >$lcddev elif [ "$global" = "BACKUP" ]; then echo -e "\e[H\e[2J${hname}\nVRRP BACKUP" >$lcddev elif [ "$global" = "INIT" ]; then echo -e "\e[H\e[2J${hname}\nVRRP INIT" >$lcddev elif [ "$global" = "FAULT" ]; then echo -e "\e[H\e[2J${hname}\nVRRP FAULT" >$lcddev else : fi exit 0