1 | | Example of how to run a transmission web daemon |
| 1 | == Example of how to run a transmission web daemon == |
| 2 | |
| 3 | transmission-daemon allows you to run transmission on a server in the background, which comes handy if: |
| 4 | |
| 5 | * You want your files stored on a server instead of a desktop computer |
| 6 | * You don't want your desktop computer left running just to wait for a download to complete. |
| 7 | |
| 8 | |
| 9 | If running, transmission-daemon is accessible via a web-frontend that |
| 10 | |
| 11 | * can/should be protected by a username/password |
| 12 | * can be restricted to only be accessible for certain computers |
| 13 | * should not be run as root but instead another user |
| 14 | |
| 15 | 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. |
| 16 | |
| 17 | === Example /etc/sysconfig/transmission-web === |
| 18 | |
| 19 | {{{ |
| 20 | |
| 21 | # uncoment and set these to enable the init script transmission-web |
| 22 | #TMWEB_PORT=9091 |
| 23 | #TMWEB_USER=torrent |
| 24 | #TMWEB_ALLOWED=192.168.219.* |
| 25 | #TMWEB_AUTH_USER=torrent |
| 26 | #TMWEB_AUTH_PASS=p1ratebay |
| 27 | #TMWEB_PIDFILE=/run/transmission-daemon-${TMWEB_PORT}.pid |
| 28 | # if TMWEB_LOGFILE is undefined, transmission-daemon will log to syslog |
| 29 | #TMWEB_LOGFILE=/var/log/transmission.log |
| 30 | |
| 31 | }}} |
| 32 | |
| 33 | * TMWEB_PORT specifies the port on which transmission-daemon should run. Must be over 1000 for non-root users. |
| 34 | * TMWEB_USER specifies the server's operating system user under which transmission-daemon should run. The user has to already exist. |
| 35 | * TMWEB_ALLOWED specifies what computes may access the web interface of transmission-daemon |
| 36 | * TMWEB_AUTH_USER and TMWEB_AUTH_PASS specify the Userid and Password needed to authenticate to transmission-daemon |
| 37 | * TMWEB_PIDFILE specifies the pidfile for the transmission-daemon process |
| 38 | * if TMWEB_LOGFILE is specified, transmission-daemon will log to this file, otherwise to syslog. It logs a lot. |
| 39 | |
| 40 | |
| 41 | === Example /etc/rc.d/init.d/transmission-web === |
| 42 | |
| 43 | The following init script can be used to start and stop transmission-daemon using the info from the sysconfig: |
| 44 | |
| 45 | {{{ |
| 46 | |
| 47 | #!/bin/sh |
| 48 | ######################################################################## |
| 49 | # Begin transmission-web |
| 50 | # |
| 51 | # Description : Start the transmission-daemon |
| 52 | # |
| 53 | # Author : DJ Lucas - dj@linuxfromscratch.org |
| 54 | # Bruce Dubbs - bdubbs@linuxfromscratch.org |
| 55 | # Tim Tassonis - stuff@decentral.ch |
| 56 | # |
| 57 | # Version : 1.0 |
| 58 | # |
| 59 | ######################################################################## |
| 60 | |
| 61 | ### BEGIN INIT INFO |
| 62 | # Provides: transmission-web |
| 63 | # Required-Start: $network |
| 64 | # Required-Stop: $network |
| 65 | # Default-Start: 3 4 5 |
| 66 | # Default-Stop: 0 1 2 6 |
| 67 | # Short-Description: |
| 68 | # Description: transmission-web - run the transmission daemon |
| 69 | ### END INIT INFO |
| 70 | |
| 71 | . /lib/lsb/init-functions |
| 72 | |
| 73 | unset TMWEB_PORT TMWEB_USER TMWEB_ALLOWED TMWEB_AUTH_USER TMWEB_AUTH_PASS TMWEB_PIDFILE TMWEB_LOGFILE |
| 74 | if [ -f /etc/sysconfig/transmission-web ] |
| 75 | then |
| 76 | . /etc/sysconfig/transmission-web |
| 77 | fi |
| 78 | if [ "x$TMWEB_PORT" = "x" ] |
| 79 | then |
| 80 | log_warning_msg "TMWEB_PORT undefined, define to use transmission-web" |
| 81 | exit 0 |
| 82 | fi |
| 83 | if [ "x$TMWEB_USER" = "x" ] |
| 84 | then |
| 85 | log_warning_msg "TMWEB_USER undefined, define to use transmission-web" |
| 86 | exit 0 |
| 87 | fi |
| 88 | if [ "x$TMWEB_ALLOWED" = "x" ] |
| 89 | then |
| 90 | log_warning_msg "TMWEB_ALLOWED undefined, define to use transmission-web" |
| 91 | exit 0 |
| 92 | fi |
| 93 | if [ "x$TMWEB_AUTH_USER" = "x" ] |
| 94 | then |
| 95 | log_warning_msg "TMWEB_AUTH_USER undefined, define to use transmission-web" |
| 96 | exit 0 |
| 97 | fi |
| 98 | if [ "x$TMWEB_AUTH_PASS" = "x" ] |
| 99 | then |
| 100 | log_warning_msg "TMWEB_AUTH_PASS undefined, define to use transmission-web" |
| 101 | exit 0 |
| 102 | fi |
| 103 | if [ "x$TMWEB_PIDFILE" = "x" ] |
| 104 | then |
| 105 | TMWEB_PIDFILE=/run/transmission-daemon-${TMWEB_PORT}.pid |
| 106 | fi |
| 107 | if [ "x$TMWEB_LOGFILE" = "x" ] |
| 108 | then |
| 109 | TMWEB_LOGDEST="" |
| 110 | else |
| 111 | TMWEB_LOGDEST="-e $TMWEB_LOGFILE" |
| 112 | if [ ! -f "$TMWEB_LOGFILE" ] |
| 113 | then |
| 114 | touch "$TMWEB_LOGFILE" |
| 115 | fi |
| 116 | chown $TMWEB_USER:adm "$TMWEB_LOGFILE" |
| 117 | chmod u=rw,g=r $TMWEB_LOGFILE |
| 118 | fi |
| 119 | PIDFILE=$TMWEB_PIDFILE |
| 120 | |
| 121 | |
| 122 | case "$1" in |
| 123 | start) |
| 124 | |
| 125 | log_info_msg "Starting transmission-web..." |
| 126 | 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}" |
| 127 | evaluate_retval |
| 128 | ;; |
| 129 | |
| 130 | stop) |
| 131 | log_info_msg "Stopping transmission-web..." |
| 132 | killproc -p ${TMWEB_PIDFILE} /usr/bin/transmission-daemon |
| 133 | sleep 2 |
| 134 | evaluate_retval |
| 135 | ;; |
| 136 | |
| 137 | restart) |
| 138 | $0 stop |
| 139 | sleep 1 |
| 140 | $0 start |
| 141 | ;; |
| 142 | |
| 143 | status) |
| 144 | statusproc /usr/bin/transmission-daemon |
| 145 | ;; |
| 146 | |
| 147 | *) |
| 148 | echo "Usage: $0 {start|stop|restart|status}" |
| 149 | exit 1 |
| 150 | ;; |
| 151 | esac |
| 152 | |
| 153 | # End transmission-web |
| 154 | |
| 155 | }}} |
| 156 | |
| 157 | |
| 158 | |
| 159 | |