Using Transmission - Entware/Entware GitHub Wiki

Introduction

There is several BitTorrent clients, provided by Entware: btpd, deluge, rtorrent, but Transmission is most popular of them.

Requirements

Optionally, you can open ports on your device to simplify connection between peers:

iptables -I INPUT -p tcp --destination-port 51413 -j ACCEPT
iptables -I INPUT -p udp --destination-port 51413 -j ACCEPT

Installation

opkg install transmission-web transmission-daemon-openssl nano

Create the data directories (adjust as desired):

mkdir /opt/Torrent/
mkdir /opt/Torrent/Incomplete
mkdir /opt/Torrent/Watch
mkdir /opt/Torrent/Completed

Make sure Transmission isn't already running, then edit its configuration:

/opt/etc/init.d/S88transmission stop
nano -w /opt/etc/transmission/settings.json

You will want to adjust the following paths:

"download-dir": "/opt/Torrent/Completed",
"watch-dir": "/opt/Torrent/Watch",
"incomplete-dir": "/opt/Torrent/Incomplete",

It's also recommended to password-protect the Web UI. Set the following parameters:

"rpc-authentication-required": true,
"rpc-username": "admin",
"rpc-password": "yourpassword",

Your password will be hashed the first time Transmission runs, so it's safe to enter it as clear text there.

Using Transmission

Everything is now configured. You can manually start it immediately (it will automatically start at boot time):

/opt/etc/init.d/S88transmission start

Access it through

http://<Your device IP>:9091/

Adding more trackers

Since 2.90, we've implemented a script execution right after torrent added. Script below will help to add more trackers to every new torrent, it can be handy when there's no peers on main tracker. Stop transmission:

/opt/etc/init.d/S88transmission stop

Add following strings to /opt/etc/transmission/settings.json:

"script-torrent-added-enabled": true,
"script-torrent-added-filename": "/opt/etc/transmission/tr_added.sh",

Make new script /opt/etc/transmission/tr_added.sh with this content:

#!/bin/sh

base_url='https://torrentz2.eu'
pattern='announcelist_[0-9]+'

if [ -z "$TR_TORRENT_HASH" ] ; then
    echo 'This script should be called from transmission-daemon.'
    exit 1
fi

announce_list=`wget --no-check-certificate -qO - ${base_url}/$TR_TORRENT_HASH | grep -Eo "${pattern}"`

if [ -z "$announce_list" ] ; then
    logger -t $(basename $0) "No additional trackers found for $TR_TORRENT_NAME, sorry."
    exit 1
fi

for tracker in $(wget -qO - ${base_url}/${announce_list}) ; do
  logger -t $(basename $0) "Adding ${tracker} to $TR_TORRENT_NAME"
  transmission-remote -t $TR_TORRENT_HASH -td ${tracker}
done

an alternative to torrent2.eu since their implementation of cloudflare is to use newtrack.org instead

#!/bin/sh
TRANSMISSION_REMOTE='/opt/bin/transmission-remote'
AUTH='username:password'
ID="$TRANSMISSION_REMOTE --auth=$AUTH --list"
IDLIST="/tmp/id.list"
TRACKERLIST="/tmp/trackers.list"
TRACKERS="curl -# https://newtrackon.com/api/stable -o $TRACKERLIST"

get_trackerlist () {
    $TRACKERS; sed -i '/^$/d' $TRACKERLIST; if [ ! -f $TRACKERLIST ]; then get_trackerlist; fi
}

add_trackers () {
    cat $TRACKERLIST | while read TRACKER; do $TRANSMISSION_REMOTE --auth=$AUTH --torrent $TORRENT --tracker-add $TRACKER; logger -t "added $TRACKER"; done
}

check_name () {
    logger -t "Updated $($TRANSMISSION_REMOTE --auth=$AUTH --torrent $TORRENT --info | grep Name | awk '{ print $2 }') with $(cat $TRACKERLIST | wc -l) additional trackers."
}

id_torrent () {
    $ID | grep -vE 'Seeding|Stopped' | sed -e '1d;$d;s/^ *//' | cut --only-delimited --delimiter=' ' --fields=1 | grep -oE '[0-9]{1,3}'> $IDLIST
    for TORRENT in $(cat $IDLIST); do add_trackers $TORRENT; check_name $TORRENT; done
}

cleanup () {
    rm $TRACKERLIST; if [ -f $TRACKERLIST ]; then cleanup; fi; rm $IDLIST; if [ -f $IDLIST ]; then cleanup; fi
}

get_trackerlist
id_torrent
cleanup

Make it executable and start transmission again:

chmod +x /opt/etc/transmission/tr_added.sh
opkg install ca-certificates
/opt/etc/init.d/S88transmission start

Check syslog after adding new torrent too see what trackers was added.

Links