File dhcpsync of Package dhcp

#!/bin/bash

# Peter Poeml <poeml@suse.de>
# $Id: dhcpsync,v 1.10 2002/01/27 14:24:42 poeml Exp $

# for usage info, refer to dhcpsync(8) 

test -n "$1" && SLAVE=$1

: ${SLAVE:?}
: ${SHARED:="/etc/dhcpd.conf.shared"}
: ${KEY:="/root/.ssh/dhcp-share"}
: ${SLEEP:=10}

# if run from the commandline, do not use an identity
# that ssh-agent holds for us -- use the $KEY
test -t 0 && unset SSH_AUTH_SOCK

PROGNAME=`basename $0`
PIDFILE=/var/run/$PROGNAME.pid

test "`/etc/init.d/dhcpd probe`" = restart \
	&& {
		trap 'rm $PIDFILE; exit 0' SIGTERM SIGINT SIGQUIT

		test -e $PIDFILE \
			&& { echo "$0 [`cat $PIDFILE`] is already running... maybe you can delete $PIDFILE. Exiting."; exit 2; }
		echo $$ > $PIDFILE

		logger $PROGNAME: restarting dhcpd; 
		/etc/init.d/dhcpd try-restart; 
		sleep $SLEEP; 
		RSYNC_RSH="/usr/bin/ssh -i $KEY" /usr/bin/rsync -cav $SHARED $SLAVE:/etc/; 
		rm $PIDFILE
	}

exit 0
openSUSE Build Service is sponsored by