Skip to content

Instantly share code, notes, and snippets.

@srounet
Created November 19, 2012 15:11
Show Gist options
  • Save srounet/4111191 to your computer and use it in GitHub Desktop.
Save srounet/4111191 to your computer and use it in GitHub Desktop.
Lsyncd init.d script
#!/bin/bash
#
# lsyncd: Starts the lsync Daemon
#
# description: Lsyncd uses rsync to synchronize local directories with a remote
# machine running rsyncd. Lsyncd watches multiple directories
# trees through inotify. The first step after adding the watches
# is to, rsync all directories with the remote host, and then sync
# single file buy collecting the inotify events.
# . /etc/rc.d/init.d/functions
config="/etc/default/lsyncd.lua"
lsyncd="/usr/local/bin/lsyncd"
lockfile="/var/lock/lsyncd"
prog="lsyncd" RETVAL=0
RETVAL=0
start() {
if [ -f $lockfile ]; then
echo -n $"$prog is already running: "
echo
else
echo -n $"Starting $prog: "
$lsyncd $config
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch $lockfile
return $RETVAL
fi
}
stop() {
echo -n $"Stopping $prog: "
killall $lsyncd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f $lockfile
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status $lsyncd
;;
*)
echo "Usage: lsyncd {start|stop|restart|status}"
exit 1
esac
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment