#!/bin/bash
# vim:shiftwidth=4:tabstop=4:expandtab:textwidth=78:softtabstop=4:ai:

   #########################################################
  # Written Nov 13, 2007 and released under the GNU/GPLv2 ##
 # (c) Jeff Schroeder (jeffschroeder@computer.org)       # #
#########################################################  #
#                                                       #  #
# status-file - Create a file to indicate the current   #  #
#               keepalived status and when the last     #  #
#               transition change happened              #  #
#                                                       # #
##########################################################

#$Id: status-file 67950 2008-03-07 01:47:57Z jschroeder $

export PATH=/bin:$PATH

MASTER=/var/run/MASTER
BACKUP=/var/run/BACKUP
FAULT=/var/run/FAULT
STATE=${1:-unknown}

case $STATE in
    master)
        rm -f $BACKUP $FAULT    
        date > $MASTER
    ;;
    backup)
        rm -f $MASTER $FAULT
        date > $BACKUP
    ;;
    fault)
        rm -f $MASTER $BACKUP
        date > $FAULT
    ;;
    *)
        echo "Usage: $0 { master | backup | fault }" >&2
    ;;
esac
