About

The following script is an init script that can be placed at /etc/init.d/btsync, made executable with chmod +x /etc/init.d/btsync and then by issuing service start btsync will start the btsync daemon.

The script starts the btsync daemon under the user sync-data configurable by changing the DAEMON_USER variable at the top of the script. Additionally, the script assumes that the configuration file is placed at /etc/btsync.conf (also configurable by changing the DAEMON_CONFIG variable at the top of the script).

Code

btsync
#! /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

assets/systemv/init_scripts/btsync.txt ยท Last modified: 2024/11/02 02:39 by office

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.