Skip to content

Commit

Permalink
Merge pull request #5 from haugene/dev
Browse files Browse the repository at this point in the history
looks good! i agree
  • Loading branch information
dan1el committed May 8, 2015
2 parents c58b487 + cc46422 commit b4e4e19
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 36 deletions.
24 changes: 7 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Transmission and OpenVPN
#
# Version 0.9
# Version 1.0

FROM phusion/baseimage:0.9.15
FROM ubuntu:14.04
MAINTAINER Kristian Haugene

VOLUME /data
Expand All @@ -21,34 +21,24 @@ RUN apt-get install -y transmission-common
RUN apt-get install -y transmission-daemon
RUN apt-get install -y openvpn
RUN apt-get install -y curl
RUN apt-get install -y screen

# Transmission service
RUN mkdir -p /etc/service/transmission/
ADD transmission/run.sh /etc/service/transmission/run

# Transmission port updater
RUN mkdir -p /etc/service/portupdater/
ADD transmission/runUpdates.sh /etc/service/portupdater/run

# OpenVPN service
RUN mkdir -p /etc/service/openvpn/
ADD runOpenVpn.sh /etc/service/openvpn/run

VOLUME /config

# Add configuration and scripts
ADD piaconfig/config.ovpn /etc/openvpn/config.ovpn
ADD piaconfig/ca.crt /etc/openvpn/ca.crt
ADD piaconfig/crl.pem /etc/openvpn/crl.pem
ADD runOpenVpn.sh /etc/openvpn/start.sh
ADD transmission/defaultSettings.json /etc/transmission-daemon/settings.json
ADD transmission/updateTransmissionPort.sh /etc/transmission-daemon/updatePort.sh
ADD transmission/periodicUpdates.sh /etc/transmission-daemon/periodicUpdates.sh
ADD transmission/run.sh /etc/transmission-daemon/start.sh
ADD transmission/runUpdates.sh /etc/transmission-daemon/startPortUpdates.sh
ADD transmission/down.sh /etc/transmission-daemon/stop.sh
ADD runOpenVpn.sh /etc/openvpn/start.sh

# Expose port and run. Use baseimage-docker's init system
EXPOSE 9091
CMD ["/sbin/my_init"]
CMD ["/etc/openvpn/start.sh"]

# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
29 changes: 13 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This Docker container lets you run Transmission with WebUI while connecting to P
The container is available from the Docker registry and this is the simplest way to get it. To run the container use this command:

```
docker run --privileged -d -v /your/storage/path/:/data -v /your/config/path/:/config -p 9091:9091 haugene/transmission-openvpn
$ docker run --privileged -d -v /your/storage/path/:/data -v /your/config/path/:/config -p 9091:9091 haugene/transmission-openvpn
```

As you can see, the container expects two volumes to be mounted. One is used for storing your downloads from Transmission, and the other provides configurations. The container comes with a default Transmission settings.json file that expects the folders "completed, incomplete and watch" to be present in /your/storage/path (aka /data). This is where Transmission will store your downloads, incomplete downloads and a watch directory to look for new .torrent files.
Expand All @@ -20,12 +20,12 @@ To build this container, clone the repository and cd into it.

### Build it:
```
cd /repo/location/docker-transmission-openvpn
docker build -t="docker-transmission-openvpn" .
$ cd /repo/location/docker-transmission-openvpn
$ docker build -t="docker-transmission-openvpn" .
```
### Run it:
```
docker run --privileged -d -v /your/storage/path/:/data -v /your/config/path/:/config -p 9091:9091 docker-transmission-openvpn
$ docker run --privileged -d -v /your/storage/path/:/data -v /your/config/path/:/config -p 9091:9091 docker-transmission-openvpn
```

As described in the "Run container from Docker registry" section, this will start a container with default settings. This means that you should have the folders "completed, incomplete and watch" in /your/storage/path, and pia-credentials.txt in /your/config/path.
Expand All @@ -47,7 +47,7 @@ This is because the VPN is active, and since docker is running in a different ip
There are several ways to fix this. You can pipe and do fancy iptables or ip route configurations on the host and in the Docker image. But I found that the simplest solution is just to proxy my traffic. Start a Nginx container like this:

```
docker run -d -v /path/to/nginx.conf:/etc/nginx.conf:ro -p 8080:80 nginx
$ docker run -d -v /path/to/nginx.conf:/etc/nginx.conf:ro -p 8080:80 nginx
```
Where /path/to/nginx.conf has this content:

Expand All @@ -69,21 +69,18 @@ Your Transmission WebUI should now be avaliable at "your.host.ip.addr:8080/trans
Change the port in the docker run command if 8080 is not suitable for you.

### What if I want to run the container interactively.
If you want do have access inside the container while running, do like this.
If you want do have access inside the container while running you have two choices. To have a look inside an already running container, use docker exec to get a terminal inside the container.

```
docker run --privileged -v /mnt/disk1/Torrents/:/data -v /your/config/path/:/config -p 9091:9091 -it --entrypoint=/bin/bash docker-transmission-openvpn
$ docker ps | grep transmission-openvpn | awk '{print $1}' // Prints container id
$ af4dd385916d
$ docker exec -it af4dd bash
```

This will start the container and give you a bash shell to work from. The container has screen installed, so you can use screen to start the init system which starts openVPN and Transmission. Then you can detach from screen and continue to use bash inside the running container. If you're unfamiliar with screen, read up on it. The commands are as follows:
If you want to start the container without it starting OpenVPN on boot, then run the image without daemonizing and use bash as entrypoint.

```
screen
```
Accept the terms, then run my_init and detach.

```
/sbin/my_init
CTRL+A + d
$ docker run --privileged -it transmission-openvpn bash
```
You should now be detached and both services should be running.

From there you can start the service yourself, or do whatever (probably developer-related) you came to do.
5 changes: 4 additions & 1 deletion piaconfig/config.ovpn
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ verb 1
reneg-sec 0
crl-verify /etc/openvpn/crl.pem


# OpenVPN control startup and shut down of transmission
script-security 2
up /etc/transmission-daemon/start.sh
down /etc/transmission-daemon/stop.sh
3 changes: 3 additions & 0 deletions transmission/down.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/bash

kill $(ps aux | grep transmission-daemon | grep -v grep | awk '{print $2}')
8 changes: 6 additions & 2 deletions transmission/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
if [ -f /config/transmission/settings.json ];
then
echo "STARTING TRANSMISSION: Using custom config directory /config/transmission"
exec /usr/bin/transmission-daemon -f -g /config/transmission/
exec /usr/bin/transmission-daemon -g /config/transmission/ &
else
echo "STARTING TRANSMISSION: No configuration provided, using defaults"
exec /usr/bin/transmission-daemon -f -g /etc/transmission-daemon/
exec /usr/bin/transmission-daemon -g /etc/transmission-daemon/ &
fi

exec /etc/transmission-daemon/startPortUpdates.sh &

echo "STARTED PORT UPDATER"

0 comments on commit b4e4e19

Please sign in to comment.