Changes between Initial Version and Version 1 of HeadlessUsageGentoo


Ignore:
Timestamp:
Oct 27, 2008, 7:56:08 PM (14 years ago)
Author:
theCrank
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • HeadlessUsageGentoo

    v1 v1  
     1= Running Transmission on a headless machine (Gentoo) =
     2
     3A successfull installation entails three parts: package installation, configuration, and use.  We'll re-visit each part with a focus on Gentoo Linux[http://www.gentoo.org/].
     4
     5The following information is current as of October 5, 2008.  As things change all the time details could become incorrect or obsolete, take that into account.
     6
     7What is accomplished by these notes?  The current distribution of Transmission on Gentoo has several errors and lacks functionality.  A start script as the one above is a much better alternative; the instructions below show how to adjust the installation and the script under Gentoo.
     8
     9==== Installation ====
     10The usual command line is used, but we add a couple of environment options to get exactly what we want:
     11{{{
     12ACCEPT_KEYWORDS="~amd64" USE="-X -gtk" emerge -av transmission
     13or
     14ACCEPT_KEYWORDS="~x86"   USE="-X -gtk" emerge -av transmission
     15}}}
     16Let's dissect the above line:
     17
     18 * ACCEPT_KEYWORDS is used to allow selection of "masked" packages for your processor (use amd64 for all 64-bit Intel or AMD processors, use x86 for 32-bit processors).  It really means that we're accepting untested / unstable / non-working packages, so use carefully (also with the dependencies included, you could install the stable version of those first, then transmission); in transmission's case is just untested and this happens with all new versions of packages.
     19With Transmission we usually need it to select the __very__ latest version; also, for those using 64-bit processors, most packages are left untested or at least takes longer.
     20 * USE adds a couple of options, in fact substracts them, meaning that we want to install all of Transmission except those parts that depend on X windows and gtk.  The Web client is not affected and we get the daemon and the command line tools; we don't get the desktop application.
     21 * emerge options just make it easy to check exactly what we are installing, it shows all the dependencies and the package with versions, stopping to ask if it is what we want.
     22
     23Now, currently Gentoo does not list the latest Transmission (i.e. shows several available versions up to 1.33 but the current version is 1.34), what can we do? See below, under "Advanced Topics".
     24
     25==== Configuration ====
     26Following best practices we leave the configurable parameters in one file, which is the only one you'll need to change to fine tune the installation to your needs, and adjust the startup script accordingly.
     27
     28We're not going to touch, or use, the script left by the Gentoo installation: /etc/init.d/transmission-daemon.  Currently it has a couple of errors so it doesn't even work right.
     29
     30'''/etc/conf.d/transmission'''
     31{{{
     32# For information on options, see the transmission-daemon(1) man page.
     33#
     34# The commented variables in this file are the defaults that are used
     35# in the init-script.  You don't need to uncomment them except to
     36# customize them to different values.
     37
     38#
     39# ----- MAIN CONFIGURATION -----
     40#
     41
     42# The folder where Transmission stores its config and .torrent files
     43# TR_HOME=/var/transmission/config
     44 
     45# The folder where Transmission stores downloads
     46# TR_DOWNLOAD=/var/transmission/downloads
     47
     48# The port Transmission uses to connect to other peers
     49# TR_PORT=54318
     50
     51# The name of the user that runs transmission-daemon and owns the files
     52# TR_USERNAME=nobody
     53
     54# Login credentials for the Web- and the RPC-interface
     55# - default: leave commented/empty to disable access authentication
     56# REMOTE_USER=""
     57# REMOTE_PASS=""
     58# - alternative: set a user name and password
     59# REMOTE_USER=admin
     60# REMOTE_PASS=password
     61
     62#
     63# ----- ADVANCED OPTIONS -----
     64#
     65
     66# Acces control lists
     67# (machines/networks allowed/denied to control transmission -- comma separated)
     68# TR_ACL="+127.0.0.1"
     69
     70# Enable use of block lists
     71# (read the Wiki about what else needs to be done)
     72# TR_BLOCK=no
     73
     74# Control port used
     75# (only privileged users can use ports < 1024, this applies to REMOTE_USER)
     76# CTL_PORT=9091
     77
     78# Initial speed limits (in K/s)
     79# default: no limits? 100/100 seems to be the hardcoded default
     80# TR_UP_SPEED=unlimited
     81# TR_DN_SPEED=unlimited
     82
     83# Peer exchange
     84# TR_PX=no
     85
     86# Port mapping using NAT/UPnP
     87# TR_PMAP=no
     88
     89# Encryption
     90# Any of :
     91# TR_ENCRYPT=tolerated
     92# TR_ENCRYPT=prefered
     93# TR_ENCRYPT=required
     94}}}
     95
     96You can add extra dependencies to transmission by adding some variables to this file, for instance:
     97    RC_NEED="nfs"
     98
     99You'll have to create the directories used, if they don't exist (this is something the Gentoo installation should have done, but since it installs for transmission running as root, its not).  Adjust paths as necessary to be the same as your configuration.
     100
     101{{{
     102mkdir -p /var/transmission/config
     103mkdir -p /var/transmission/downloads
     104chown -R nobody:nogroup /var/transmission
     105}}}
     106
     107And the startup script, which uses automagically the options file:
     108
     109'''/etc/init.d/transmission'''
     110{{{
     111#!/sbin/runscript
     112#
     113
     114# DO NOT EDIT!
     115# ------------
     116# All configurable options are set in /etc/conf.d/transmission
     117
     118NAME=transmission-daemon
     119declare -a OPTIONS
     120OPTIONS+=" -a ${TR_ACL:=+127.0.0.1}"
     121if [ -z "$TR_BLOCK" -o "$TR_BLOCK" = "no" ]; then
     122   OPTIONS+=" -B"
     123else
     124   OPTIONS+=" -b"
     125fi
     126OPTIONS+=" -g ${TR_HOME:-/var/transmission/config}"
     127OPTIONS+=" -p ${CTL_PORT:-9091}"
     128if [ -z "$REMOTE_USER" -o -z "$REMOTE_PASS" ]; then
     129   OPTIONS+=" -T"
     130else
     131   OPTIONS+=" -t"
     132   OPTIONS+=" -u $REMOTE_USER"
     133   OPTIONS+=" -v $REMOTE_PASS"
     134fi
     135OPTIONS+=" -w ${TR_DOWNLOAD:-/var/transmission/downloads}"
     136declare -a EXTRA_OPT
     137if [ -z "$TR_UP_SPEED" -o "$TR_UP_SPEED" = "unlimited" ]; then
     138   EXTRA_OPT+=" -U"
     139else
     140   EXTRA_OPT+=" -u $TR_UP_SPEED"
     141fi
     142if [ -z "$TR_DN_SPEED" -o "$TR_DN_SPEED" = "unlimited" ]; then
     143   EXTRA_OPT+=" -D"
     144else
     145   EXTRA_OPT+=" -d $TR_DN_SPEED"
     146fi
     147if [ -z "$TR_PX" -o "$TR_PX" = "no" ]; then
     148  EXTRA_OPT+=" -X"
     149else
     150  EXTRA_OPT+=" -x"
     151fi
     152if [ -z "$TR_PMAP" -o "$TR_PMAP" = "no" ]; then
     153  EXTRA_OPT+=" -M"
     154else
     155  EXTRA_OPT+=" -m"
     156fi
     157if [ -z "$TR_ENCRYPT" -o "$TR_ENCRYPT" = "tolerated" ]; then
     158  EXTRA_OPT+=" -et"
     159elif [ "$TR_ENCRYPT" = "prefered" ]; then
     160  EXTRA_OPT+=" -ep"
     161elif [ "$TR_ENCRYPT" = "required" ]; then
     162  EXTRA_OPT+=" -er"
     163else
     164  EXTRA_OPT+=" -et"
     165fi
     166E_MSG="ERROR starting transmission, check configuration."
     167
     168depend() {
     169   need net
     170}
     171
     172start() {
     173   ebegin "Starting transmission daemon"
     174   start-stop-daemon --start --quiet \
     175      --chuid ${TR_USERNAME:-nobody} \
     176      --exec /usr/bin/transmission-daemon -- ${OPTIONS[@]} \
     177   || { eerror $E_MSG; eend 1; return 1; }
     178   sleep 1
     179   transmission-remote ${CTL_PORT:-9091} \
     180      ${REMOTE_PASS:+-n $REMOTE_USER:$REMOTE_PASS} \
     181      --port ${TR_PORT:-54318} ${EXTRA_OPT[@]} > /dev/null
     182   eend $?
     183}
     184
     185stop() {
     186   ebegin "Stopping transmission daemon"
     187   start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
     188      --name $NAME
     189   eend $?
     190}
     191
     192# vim: set ft=gentoo-init-d ts=3 sw=3 et:
     193}}}
     194
     195Make the script executable:
     196{{{
     197chmod +x /etc/init.d/transmission
     198}}}
     199==== Use ====
     200 * Activate the use of the script (starts the daemon at boot time, stops it at shutdown)
     201
     202{{{
     203rc-update add transmission default
     204}}}
     205 * Manual start / stop / restart / status
     206
     207Once you installed everything you can start the daemon without rebooting, for instance, as root:
     208{{{
     209/etc/init.d/transmission start
     210}}}
     211Similarly you can stop it and, every time you change the configuration parameters, use restart which is just a combination of stop and start.
     212 * Web client
     213
     214Remember to use the port configured as control port, 9091 if you didn't change it:
     215{{{
     216http://your.server.ip:9091/
     217}}}
     218
     219==== Advanced Topics ====
     220 * !MoBlock
     221
     222Here's a good reference on setting up !MoBlock on Gentoo [http://gentoo-wiki.com/Moblock].
     223
     224After setting ''!MoBlock'' as a service, you can link its database to be the one used by Transmission:
     225{{{
     226ln -s /var/db/moblock/guarding.p2p /var/transmission/config/blocklists/
     227}}}
     228That means !MoBlock will take care of updating the data base.  It also means !MoBlock will be blocking access using the firewall (iptables) and Transmission will not try to connect to blocked addresses (connections that will be blocked anyway by !MoBlock).
     229
     230 * Local ebuild
     231
     232The procedure is not difficult but involves more work: create a local emerge repository structure, copy the contents from the current transmission branch, inside your local copy duplicate the file transmission-1.33.ebuild into transmission-1.34.ebuild, change the configuration in /etc/make.conf adding 'PORTDIR_OVERLAY="/usr/local/portage"', rebuild the package (2 ebuild commands), and emerge will show it as an option.