QNAPedia Community Wiki

Skip to content

Transmission

From QNAPedia

Jump to: navigation, search

Transmission is a simple and lightweight BitTorrent client which runs nicely on even lower-end NAS and can be installed via the command line.

Contents

Installation

  1. You need to Install Optware IPKG
  2. Update ipkg: ipkg update
  3. Install transmission: ipkg install transmission
  4. Install nano as a texteditor ipkg install nano
  5. Install Coreutils ipkg install coreutils
  6. It is not advised to run a BitTorrent client as root. Therefore you should create a new user named transmission (which neither needs a homedirectory -H or a password: -D): adduser -DH transmission
  7. Now you can create a script to launch transmission. You can do this with echo 'file-content' > file-name. (Replace your-user-name and your-password with something. You'll need those to login to the webinterface or the commandline remote. PORT is the port used for connections, you might want to forward it on your router.)


echo '#!/bin/sh
#!/bin/sh
TORRENTFOLDER=/share/HDA_DATA/Qdownload
TRANSMISSION_BIN=/opt/bin/transmission-daemon
TRANSMISSION_HOME=/opt/etc/transmission
TRANSMISSION_USER=transmission
TRANSMISSION_PORT=6888

REMOTE_USER=your-user-name
REMOTE_PASS=your-password

echo -n "Starting Transmission Daemon..."
su $TRANSMISSION_USER -c "EVENT_NOEPOLL=0 $TRANSMISSION_BIN --blocklist --auth --username $REMOTE_USER --password $REMOTE_PASS --config-dir $TRANSMISSION_HOME --download-dir $TORRENTFOLDER"

#Wait a while till the daemon has started...
sleep 20

#Set a few settings
transmission-remote -n $REMOTE_USER:$REMOTE_PASS --portmap --port $TRANSMISSION_PORT --pex --encryption-preferred


' > transmission_start.sh

More advanced script see below (use nano as editor is more convenient)

You can also edit this file later with nano transmission_start.sh (or vi if you prefer).

  1. You need to setup the directories (if not already available) in order for this to run (used mkdir)
  2. Use chmod -R 777 'Directorynames' in order to give transmission read and write access
  3. You need to make the script executable. chmod +x transmission_start.sh
  4. Execute the script: ./transmission_start.sh The transmission-daemon (which is actually downloading the torrents) should now be running. You can connect to it to check on its status and give it order either with the webinterface or via the command-line.
  • Webinterface: direct your browser to your NAS at port 9091http://IP-of-your-NAS:9091 Enter the username/password you set in the launch file and ready you are!
  • Command-line:
    • Get help with: transmission-remote -h
    • Add torrent: transmission-remote -n your-username:your-password -a TORRENT_FILE
    • List torrents: transmission-remote -n your-username:your-password -l

Transmission on TS-201

Please see this guide: Category:BitTorrent / MLDonkey

Settings.json

If you get an error message about not being on the whitelist, you may need to change entries in the settings file which should be created on the initial startup. Otherwise create a settings.json in the $TRANSMISSION_HOME directory. Here's a template you can use, but beware, it's very permissive.

{
	"blocklist-enabled": 1,
	"blocklist-updates-enabled": 1,
	"download-limit": 200,
	"download-limit-enabled": 0,
	"encryption": 1,
	"lazy-bitfield-enabled": 1,
	"max-peers-global": 300,
	"max-peers-per-torrent": 100,
	"peer-port": 6881,
	"pex-enabled": 1,
	"port-forwarding-enabled": 1,
	"rpc-authentication-required": 0,
	"rpc-password": "",
	"rpc-port": 9091,
	"rpc-username": "",
	"rpc-whitelist": "*.*.*.*",
	"rpc-whitelist-enabled": 1,
	"upload-limit": 30,
	"upload-limit-enabled": 0
}

MORE ADVANCED SCRIPT

Can be used to setup operation with block list.

Example ./scrptname.sh restart will load blocklists and restart the transmission daemon.

!/bin/sh
#!/bin/sh

#
# PURPOSE - start and stop script for transmission bit torrent client with built in
#           retrieval of blocklists from bluetack.co.uk
#           Selection of block lists to be retrieved is configurable by variable BLOCK_FILES
#
#
# NOTE    - the block lists can be quite large and capacity of / can be exhausted.
#           I suggest to move ~/.config which is created by "transmission"
#           somewhere on the harddrive (/mnt/HDA_ROOT/)
#
################################################################################
#           if variable is not defined in environment, let's populate it
#-------------------------------------------------------------------------------
[ -z "$BLOCK_FILES" ] && BLOCK_FILES="level1 level2 Microsoft bogon edu iana-reserved"

TORRENTFOLDER=/share/Multimedia/Downloaded
WATCHFOLDER=/share/Download/Watchfolder
TRANSMISSION_BIN=/opt/bin/transmission-daemon
TRANSMISSION_HOME=/opt/etc/transmission
TRANSMISSION_USER=transmission
TRANSMISSION_PORT=6888

REMOTE_USER=bertibot
REMOTE_PASS=bertibot


#-------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
function update_blocklist
{
  cd /opt/etc/transmission/blocklists

  for f in $BLOCK_FILES; do
    echo "wget -q http://www.bluetack.co.uk/config/${f}.gz"
    wget -q http://www.bluetack.co.uk/config/${f}.gz
    EC=$?
    if [ -f ${f}.gz ] && [ $EC == 0 ]; then
       if [ -f ${f}.bin ]; then rm ${f}.bin; fi
       if [ -f "$f" ]; then rm "$f"; fi
       gunzip ${f}.gz
       chmod go+r "$f"
    fi
  done
}


function start_transmission
{
echo -n "Starting Transmission Daemon..."
su $TRANSMISSION_USER -c "EVENT_NOEPOLL=0 $TRANSMISSION_BIN --blocklist --auth --username $REMOTE_USER --password $REMOTE_PASS --config-dir $TRANSMISSION_HOME --download-dir $TORRENTFOLDER --watch-dir $WATCHFOLDER"
#Wait a while till the daemon has started...
sleep 20
#Set a few settings
transmission-remote -n $REMOTE_USER:$REMOTE_PASS --portmap --port $TRANSMISSION_PORT --pex --encryption-preferred
}


#===============================================================================
case "$1" in
  start)
        update_blocklist
        start_transmission
        ;;
  stop)
        if [ -n "`pidof transmission-daemon`" ]; then
           kill -9 `pidof transmission-daemon`
        fi
        ;;
  restart)                                                                                                                                           
        $0 stop
        $0 start
        ;;
  *)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
esac


One more script

This script could be placed where you want transmission.sh

#!/bin/sh

umask 0000
ulimit -n 65535
. /etc/init.d/functions
# See how we were called.
TORRENTFOLDER=/share/MD0_DATA
TRANSMISSION_BIN=/opt/bin/transmission-daemon
TRANSMISSION_REMOTE=/opt/bin/transmission-remote
TRANSMISSION_HOME=/opt/etc/transmission
TRANSMISSION_USER=transmission
TRANSMISSION_PORT=9091
TRANSMISSION_SEEDPORT=8888
REMOTE_USER=torrents
REMOTE_PASS=asdx

case "$1" in
  start)
        test -f $TRANSMISSION_BIN || (echo "$TRANSMISSION_BIN doesn't exists" && exit 0)
        echo "Starting torrent services:"

        $TRANSMISSION_BIN --blocklist --auth --username $REMOTE_USER --password $REMOTE_PASS --config-dir $TRANSMISSION_HOME --download-dir $TORRENTFOLDER
        echo -n "transmission-daemon..."
        tdpids=`pidof transmission-daemon`
        while [[ "$tdpids" == "" ]]
        do
            tdpids=`pidof transmission-daemon`
        done
        pidof -s transmission-daemon > /var/run/transmission.pid
        echo " done."
        echo -n "transmission-remote..."
        $TRANSMISSION_REMOTE -n $REMOTE_USER:$REMOTE_PASS --portmap --port $TRANSMISSION_PORT --pex --encryption-preferred 2>/dev/null 1>/dev/null
        echo " done."
        ;;
  stop)
        echo "Shutting down torrent services:"

        echo -n "transmission-daemon..."
        tdpids=`pidof transmission-daemon`
        while [[ "$tdpids" != "" ]]
        do
            for pid in $tdpids
            do
                /bin/kill -TERM $pid 2>/dev/null 1>/dev/null
                # DEBUG
                # echo /bin/kill -TERM $pid
            done
            tdpids=`pidof transmission-daemon`
        done
        rm -f /var/run/transmission.pid
        echo " done."
        echo -n "transmission-remote..."
        trpids=`pidof transmission-remote`
        for pid in $trpids; do
            /bin/kill -TERM $pid 2>/dev/null 1>/dev/null
        done
        echo " done."
        ;;
  restart)
        echo "Restarting torrent services:"
        $0 stop
        $0 start
        echo "done."
        ;;
  *)
        echo "Usage: transmission.sh {start|stop|restart}"
        exit 1
        ;;
esac

Personal tools
Language