Created
April 26, 2013 13:45
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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