#! /bin/sh
#
# chkconfig: 345 99 01
# description: voldemort is the process that will pull files from the 
#              rsync server if the machine was not shut down cleanly

# Get config.
# See how we were called.
case "$1" in
  start)
        if [ -e /etc/pullrsync ]
	then 
             HOSTNAME="$(grep HOSTNAME /etc/sysconfig/network | grep -v DHCP | cut -d'=' -f2 | cut -d'.' -f1)"
	echo $HOSTNAME > /tmp/hostname
	   /sbin/pullrsync -H $HOSTNAME
           touch /etc/pullrsync
        else
	   touch /etc/pullrsync
        fi
	;;
# if there was not a clean shutdown, /etc/pullrsync will still be there
# on reboot
  stop)
	rm /etc/pullrsync
	;;
  *)
	echo "Usage: voldemort  {start|stop}"
	exit 1
esac

exit 0
