wiki:transmission

Example of how to run a transmission web daemon

transmission-daemon allows you to run transmission on a server in the background, which comes handy if:

  • You want your files stored on a server instead of a desktop computer
  • You don't want your desktop computer left running just to wait for a download to complete.

If running, transmission-daemon is accessible via a web-frontend that

  • can/should be protected by a username/password
  • can be restricted to only be accessible for certain computers
  • should not be run as root but instead another user

The following example allows you to define some relevant stuff in /etc/sysconfig/transmission-web, which is then processed by an init script transmission-web, to run transmission-daemon according to your settings.

Example /etc/sysconfig/transmission-web

# uncoment and set these to enable the init script transmission-web
#TMWEB_PORT=9091
#TMWEB_USER=torrent
#TMWEB_ALLOWED=192.168.219.*
#TMWEB_AUTH_USER=torrent
#TMWEB_AUTH_PASS=p1ratebay
#TMWEB_PIDFILE=/run/transmission-daemon-${TMWEB_PORT}.pid
# if TMWEB_LOGFILE is undefined, transmission-daemon will log to syslog
#TMWEB_LOGFILE=/var/log/transmission.log

  • TMWEB_PORT specifies the port on which transmission-daemon should run. Must be over 1000 for non-root users.
  • TMWEB_USER specifies the server's operating system user under which transmission-daemon should run. The user has to already exist.
  • TMWEB_ALLOWED specifies what computes may access the web interface of transmission-daemon
  • TMWEB_AUTH_USER and TMWEB_AUTH_PASS specify the Userid and Password needed to authenticate to transmission-daemon
  • TMWEB_PIDFILE specifies the pidfile for the transmission-daemon process
  • if TMWEB_LOGFILE is specified, transmission-daemon will log to this file, otherwise to syslog. It logs a lot.

Example /etc/rc.d/init.d/transmission-web

The following init script can be used to start and stop transmission-daemon using the info from the sysconfig:

#!/bin/sh
########################################################################
# Begin transmission-web
#
# Description : Start the transmission-daemon
#
# Author      : DJ Lucas - dj@linuxfromscratch.org
#               Bruce Dubbs - bdubbs@linuxfromscratch.org
#               Tim Tassonis - stuff@decentral.ch
#
# Version     : 1.0
#
########################################################################

### BEGIN INIT INFO
# Provides:            transmission-web
# Required-Start:      $network
# Required-Stop:       $network
# Default-Start:       3 4 5
# Default-Stop:        0 1 2 6
# Short-Description:   
# Description:         transmission-web - run the transmission daemon
### END INIT INFO

. /lib/lsb/init-functions

unset TMWEB_PORT TMWEB_USER TMWEB_ALLOWED TMWEB_AUTH_USER TMWEB_AUTH_PASS TMWEB_PIDFILE TMWEB_LOGFILE
if [ -f /etc/sysconfig/transmission-web ]
then
. /etc/sysconfig/transmission-web
fi
if [ "x$TMWEB_PORT" = "x" ] 
then
	log_warning_msg "TMWEB_PORT undefined, define to use transmission-web"
	exit 0
fi
if [ "x$TMWEB_USER" = "x" ] 
then
	log_warning_msg "TMWEB_USER undefined, define to use transmission-web"
	exit 0
fi
if [ "x$TMWEB_ALLOWED" = "x" ] 
then
	log_warning_msg "TMWEB_ALLOWED undefined, define to use transmission-web"
	exit 0
fi
if [ "x$TMWEB_AUTH_USER" = "x" ] 
then
	log_warning_msg "TMWEB_AUTH_USER undefined, define to use transmission-web"
	exit 0
fi
if [ "x$TMWEB_AUTH_PASS" = "x" ] 
then
	log_warning_msg "TMWEB_AUTH_PASS undefined, define to use transmission-web"
	exit 0
fi
if [ "x$TMWEB_PIDFILE" = "x" ] 
then
	TMWEB_PIDFILE=/run/transmission-daemon-${TMWEB_PORT}.pid
fi
if [ "x$TMWEB_LOGFILE" = "x" ] 
then
	TMWEB_LOGDEST=""
else
	TMWEB_LOGDEST="-e $TMWEB_LOGFILE"
	if [ ! -f "$TMWEB_LOGFILE" ]
	then
		touch "$TMWEB_LOGFILE"
	fi
	chown $TMWEB_USER:adm "$TMWEB_LOGFILE"
	chmod u=rw,g=r $TMWEB_LOGFILE
fi
PIDFILE=$TMWEB_PIDFILE


case "$1" in
   start)

      log_info_msg "Starting transmission-web..."
      su - $TMWEB_USER -c "/usr/bin/transmission-daemon -p ${TMWEB_PORT} --allowed ${TMWEB_ALLOWED} -t -u ${TMWEB_AUTH_USER} -v ${TMWEB_AUTH_PASS} --pid-file=${TMWEB_PIDFILE} ${TMWEB_LOGDEST}"
      evaluate_retval
      ;;

   stop)
      log_info_msg "Stopping transmission-web..."
      killproc -p ${TMWEB_PIDFILE} /usr/bin/transmission-daemon
      sleep 2
      evaluate_retval
      ;;

   restart)
      $0 stop
      sleep 1
      $0 start
      ;;

   status)
      statusproc /usr/bin/transmission-daemon
      ;;

   *)
      echo "Usage: $0 {start|stop|restart|status}"
      exit 1
      ;;
esac

# End transmission-web

Last modified 15 months ago Last modified on 02/11/2023 09:19:08 PM
Note: See TracWiki for help on using the wiki.