With a NAS system running 24/7 I want to help spreading different linux distributions via bittorrent. To have a comfortable control about those torrents, I prefer a webgui which is accessible from the whole network. On my debian server, I installed transmission, which is quite easy via apt-get. There is a package for OpenSolaris too, but it’s missing some basics like a dedicated user or a Solaris Service Manifest.

So, in the following post, I want to explain how to install the bittorrent client (transmission) from the OpenSolaris Package Directory, set it up and configure it as a service which can be administered with svcadm.

Basic installation

First, we need to install the transmission package with pkg. The package has a lot of dependencies and therefore the download is nearly 60MB.

root@test:~# pkg install transmission
               Packages to install:    59
           Create boot environment:    No
               Services to restart:     9
DOWNLOAD                                  PKGS       FILES    XFER (MB)
Completed                                59/59   7203/7203    56.9/56.9

PHASE                                        ACTIONS
Install Phase                            10131/10131

PHASE                                          ITEMS
Package State Update Phase                     59/59
Image State Update Phase                         2/2

As we don’t want transmission to run as root, we create a new user torrentd.

root@test:~# mkdir -p /export/home/torrentd
root@test:~#
root@test:~# cd /export/home/
root@test:/export/home# useradd -d /export/home/torrentd -s /bin/false torrentd
root@test:/export/home# chown torrentd:other torrentd/
root@test:/export/home# ls -la
total 9
drwxr-xr-x   3 root     root           3 Jul 23 23:58 .
drwxr-xr-x   3 root     root           3 Jul 23 23:57 ..
drwxr-xr-x   2 torrentd other           2 Jul 23 23:58 torrentd

The storage folder for torrents has to be created too. Most likely you want to put it into a ZFS pool.

root@test:~# mkdir -p /my/storage/torrentfolder
root@test:~# chown torrentd:other /my/storage/torrentfolder

Configuration

After those basics, we need to create the config-files for transmission. The easiest way to get those files is to run the transmission-daemon and let it create the configs.
Usually those configs would be generated in the current user’s home directory. This is ok for multiuser environments but we want to place the configs in /var/transmission.

root@test:~# mkdir /var/transmission/
root@test:~# transmission-daemon --config-dir /var/transmission -f
[00:02:09.260] Transmission 1.93 (10621) started (session.c:609)
[00:02:09.261] RPC Server Adding address to whitelist: 127.0.0.1 (rpc-server.c:772)
[00:02:09.261] RPC Server Serving RPC and Web requests on port 9091 (rpc-server.c:945)
[00:02:09.261] RPC Server Whitelist enabled (rpc-server.c:949)
[00:02:09.261] DHT Generating new id (tr-dht.c:369)
[00:02:09.261] Using settings from "/var/transmission" (daemon.c:425)
[00:02:09.261] Saved "/var/transmission/settings.json" (bencode.c:1651)
[00:02:09.261] Port Forwarding (NAT-PMP) initnatpmp succeeded (0) (natpmp.c:67)
[00:02:09.261] Port Forwarding (NAT-PMP) sendpublicaddressrequest succeeded (2) (natpmp.c:67)
[00:02:11.261] Port Forwarding (UPnP) Found Internet Gateway Device
"http://192.168.1.1:49000/upnp/control/WANIPConn1" (upnp.c:103)
[00:02:11.262] Port Forwarding (UPnP) Local Address is "192.168.1.240" (upnp.c:106)
[00:02:11.262] Port Forwarding (UPnP) Port forwarding through
"http://192.168.1.1:49000/upnp/control/WANIPConn1", service
"urn:schemas-upnp-org:service:WANIPConnection:1".  (local address: 192.168.1.240:51413) (upnp.c:190)
[00:02:11.262] Port Forwarding State changed from "Not forwarded" to "Starting" (port-forwarding.c:85)

Now kill the transmission-daemon by pressing CTRL-C twice. As you see, the daemon created some files which are used to config your torrent client.

root@test:~# cd /var/transmission/
root@test:/var/transmission# ls -la
total 18
drwxr-xr-x   5 root     root           6 Jul 24 00:02 .
drwxr-xr-x  33 root     sys           33 Jul 24 00:01 ..
drwxr-xr-x   2 root     root           2 Jul 24 00:02 blocklists
drwxr-xr-x   2 root     root           2 Jul 24 00:02 resume
-rw-------   1 root     root        1681 Jul 24 00:02 settings.json
drwxr-xr-x   2 root     root           2 Jul 24 00:02 torrents

The most important file is settings.json. Here we have to set the download-directory and whitelist the local network (192.168.1.*).

One note to the settings-file: You can always edit this file, but if the transmission-daemon is running, it will be overwritten when the daemon stops. Thus you should stop it before editing.

    "download-dir": "/my/storage/torrentfolder",
    ...
    "rpc-authentication-required": false,
    "rpc-bind-address": "0.0.0.0",
    "rpc-enabled": true,
    "rpc-password": "------------",
    "rpc-port": 9091,
    "rpc-username": "",
    "rpc-whitelist": "127.0.0.1,192.168.1.*",
    "rpc-whitelist-enabled": true,

Further information about the config can be found here:
https://trac.transmissionbt.com/wiki/EditConfigFiles

Now we have to chown the config-folder.

root@test:/var/transmission# chown -R torrentd:other /var/transmission

Transmission as Solaris Service

The final step is to integrate transmission into Solaris’ Service Management Facility (smf). This requires a XML config file which describes the transmission-service.

A basic XML config can be found at 4amlunch.net. As some of the folders have to be set in the config-file, I modified it in accordance to this guide. The new files can be found here:
transmission.zip

The installation is quite straight forward with wget.

root@test:/var/transmission# cd /tmp/
root@test:/tmp# wget http://www.dev-eth0.de/wp-content/uploads/2011/07/transmission.zip
--2011-07-24 00:18:12--  http://www.dev-eth0.de/wp-content/uploads/2011/07/transmission.zip
idn_decode failed (9): `System iconv failed'
Resolving www.dev-eth0.de... 87.238.193.118
idn_decode failed (9): `System iconv failed'
Connecting to www.dev-eth0.de|87.238.193.118|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1759 (1.7K) [application/zip]
Saving to: `transmission.zip'

100%[====================================================>] 1,759       --.-K/s   in 0s

2011-07-24 00:18:12 (3.81 MB/s) - `transmission.zip' saved [1759/1759]

root@test:/tmp# unzip transmission.zip
Archive:  transmission.zip
inflating: transmission-daemon
inflating: transmission-daemon.xml

root@test:/tmp# mv transmission-daemon /lib/svc/method/
root@test:/tmp# chmod +x /lib/svc/method/transmission-daemon
root@test:/tmp# chown root:bin /lib/svc/method/transmission-daemon
root@test:/tmp# svccfg import -V transmission-daemon.xml

Now we have installed transmission-daemon as a Solaris Service and can start and stop it with the svcadm command and check it’s status with svcs

Commands:

svcadm enable transmission-daemon
svcadm disable transmission-daemon
svcadm restart transmission-daemon

The following steps will enable transmission and check it’s status.

root@test:/tmp# svcadm enable transmission-daemon
root@test:/tmp# svcs -x transmission-daemon
svc:/application/transmission-daemon:default (Transmission BitTorrent Client (Daemon))
State: online since Sun Jul 24 00:34:27 2011
See: transmission-daemon(1)
See: http://www.transmissionbt.org
See: /var/svc/log/application-transmission-daemon:default.log
Impact: None.

That’s it, the service is up and running, now we can access the WebGui on Port 9091:

http://yourServer:9091/


Related Posts



Eine Antwort schreiben