Skip to content

Instantly share code, notes, and snippets.

@ricco386
Created April 26, 2013 13:45
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricco386/5467477 to your computer and use it in GitHub Desktop.
Save ricco386/5467477 to your computer and use it in GitHub Desktop.
Linux Daemon for BitTorrent Sync. This shell script takes care of starting and stopping btsync. Written in Fedora, can be used in /etc/init.d/ to start btsync at boot.
#!/bin/bash
#
# btsync This shell script takes care of starting and stopping btsync
#
# chkconfig: 2345 20 80
# description: btsync is BitTorrent Sync program which allows you \
# to synchronize directories between computers.
# processname: btsync
# Source function library.
. /etc/rc.d/init.d/functions
prog=btsync
prog_path=${BTSYNC-/usr/local/bin}
pidfile=${prog_path}/.sync/sync.pid
config=
bt=${prog_path}/${prog}
STOP_TIMEOUT=${STOP_TIMEOUT-5}
RETVAL=0
start() {
echo -n $"Starting $prog: "
if [[ -n "$config" ]]; then
daemon $bt --config ${config}
else
daemon $bt
fi
RETVAL=$?
echo
[ $RETVAL = 0 ]
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d ${STOP_TIMEOUT} $bt
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${pidfile}
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $bt
RETVAL=$?
;;
restart)
stop
start
;;
*)
echo $"Usage: $prog {start|stop|status|restart|help}"
RETVAL=2
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment