#! /bin/sh ### BEGIN INIT INFO # Provides: btsync # Required-Start: $local_fs $remote_fs $network $syslog $named $openvpn # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start btsync. # Description: Starts the btsync daemon. ### END INIT INFO ########################################################################### ## Copyright (C) Wizardry and Steamworks 2013 - License: GNU GPLv3 ## ## Please see: http://www.gnu.org/licenses/gpl.html for legal details, ## ## rights of fair usage, the disclaimer and warranty conditions. ## ########################################################################### PATH=/sbin:/usr/bin DAEMON=/usr/sbin/btsync DAEMON_USER=sync-data DAEMON_CONFIG=/etc/btsync.conf # Get lsb functions . /lib/lsb/init-functions do_start () { log_begin_msg "Starting btsync daemon..." HOMEDIR=`getent passwd $DAEMON_USER | cut -d: -f6` if [ -x $DAEMON ]; then HOME="$HOMEDIR" start-stop-daemon --start -c $DAEMON_USER -u $DAEMON_USER --background --exec $DAEMON -- --config $DAEMON_CONFIG fi log_end_msg $? } do_stop () { log_begin_msg "Stopping btsync daemon..." HOMEDIR=`getent passwd $DAEMON_USER | cut -d: -f6` if [ -x $DAEMON ]; then start-stop-daemon -o -c $DAEMON_USER -K -u $DAEMON_USER -x $DAEMON fi log_end_msg $? } status () { status_of_proc "$DAEMON" btsync } case "$1" in start) do_start ;; restart) do_stop /bin/sleep 1 do_start ;; status) status ;; stop) do_stop ;; *) echo "Usage: btsync [start|stop|restart|status]" >&2 exit 3 ;; esac exit 0