#!/bin/bash
#
### BEGIN INIT INFO
# Provides:lsyncd
# Required-Start:
# Required-Stop:
# Default-Start:3 5
# Default-Stop:0 1 2 6
# Short-Description:Start lsyncd
# Description:Lsyncd uses rsync to synchronize local directories with a remote machine running rsyncd.
### END INIT INFO

config="/etc/lsyncd/lsyncd.conf"
lsyncd="/usr/bin/lsyncd"
prog="lsyncd"

. /etc/rc.status

[ -f /etc/sysconfig/lsyncd ] && . /etc/sysconfig/lsyncd

rc_reset

case "$1" in
	start)
		echo -n "Starting $prog: "
		$lsyncd  -log Exec $config ${OPTIONS}
		rc_status -v
	;;
	stop)
		echo -n "Shutting down $prog: "
		/bin/kill -9 `/sbin/pidof lsyncd`
		until [ -z $(/sbin/pidof lsyncd) ]; do :; done
		rc_status -v
	;;
	restart)
		$0 stop
		$0 start
		rc_status
	;;
	status)
		echo -n "$prog status:"
		rc_status -v
	;;
	*)
		echo "Usage: $0 {start|stop|restart|status}"
		exit 1
	;;
esac

rc_exit
