About

Starts an opentracker instance in the background. Debian does not provide an opentracker package, so we created an init script ourselves.

The configurable parameters are:

DAEMON=/usr/bin/opentracker
DAEMON_USER=torrent
DAEMON_CONFIGURATION=/etc/opentracker.conf

the DAEMON_CONFIGURATION variable has to be set to the opentracker configuration file. The DAEMON_USER parameter determines which user opentracker should run under.

Code

#! /bin/sh
### BEGIN INIT INFO
# Provides:          opentracker
# 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 opentracker.
# Description:       Starts the opentracker 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/bin/opentracker
DAEMON_USER=torrent
DAEMON_CONFIGURATION=/etc/opentracker.conf
 
# Get lsb functions
. /lib/lsb/init-functions
 
do_start () {
	log_begin_msg "Starting opentracker daemon..."
	HOMEDIR=`getent passwd $DAEMON_USER | cut -d: -f6`
	if [ -x $DAEMON ]; then
		HOME="$HOMEDIR" start-stop-daemon --start -c $DAEMON_USER --pidfile $HOMEDIR/opentracker.pid --make-pidfile --background --exec $DAEMON -d $HOMEDIR -- -f $DAEMON_CONFIGURATION
	fi
	log_end_msg $?
}
do_stop () {
	log_begin_msg "Stopping opentracker 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 -- -f $DAEMON_CONFIGURATION
	fi
	log_end_msg $?
}
 
status () {
	status_of_proc "$DAEMON" opentracker
}
 
case "$1" in
  start)
	do_start
	;;
  restart)
  	do_stop
  	do_start
  	;;
  status)
  	status
  	;;
  stop)
	do_stop
	;;
  *)
	echo "Usage: opentracker [start|stop|restart|status]" >&2
	exit 3
	;;
esac
 
exit 0