Auto Staring btsync (Bit Torrent Sync) / SyncApp on CentOS

I used to use this software, and wanted to share the init script I've been using:
#!/bin/bash
#
# Super ultra basic startup script for btsync
#
# chkconfig: 345 55 25
# description: bittorrent sync
# processname: btsync
# pidfile:
# config:

# Source function library
. /etc/init.d/functions

# Get network config
. /etc/sysconfig/network

if [ -f /etc/sysconfig/btsync ]; then
. /etc/sysconfig/btsync
fi

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 1

if [ ! -f $BIN ] ; then
echo "missing binary: $BIN"
exit 1;
fi

if [ ! -f $CONF ] ; then
echo "missing configuration: $CONF"
echo "run $BIN --dump-sample-config to create a default configuration"
exit 6;
fi

if [ -z $USER ] ; then
USER=root
fi

start() {
DIR=$(dirname "${PID}")
if [ ! -d "$DIR" ] ; then
mkdir $DIR
fi
daemon --pidfile $PID --user $USER $BIN --config $CONF
echo_success
}

stop() {
killproc -p $PID $BIN
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status -p $PID $BIN
;;
*)
echo "usage: $0 {start|stop|restart|status}"
;;
esac
exit 0;


And then the /etc/sysconfig/btsync
# SyncApp Settings
# USER=syncapp
CONF=/etc/btsync.conf
BIN=/usr/sbin/btsync
PID=/var/run/btsync/btsync.pid

Comments

Popular posts from this blog

Apple AirPort Express and Digital Jitter..

EIZO Colornavigator - Data Access Error

Using Borg backup across SSH with sshkeys