Remove transmission scripts and add qbittorrent scripts

This commit is contained in:
Mark Newton 2018-02-02 19:56:08 -05:00
parent fdf83b25e9
commit cf15d41301
7 changed files with 3 additions and 258 deletions

View File

@ -16,6 +16,7 @@ RUN apt-get update \
# Add configuration and scripts
ADD openvpn/ /etc/openvpn/
ADD qbittorrent/ /etc/qbittorrent/
ENV OPENVPN_USERNAME=**None** \
OPENVPN_PASSWORD=**None** \
@ -24,4 +25,5 @@ ENV OPENVPN_USERNAME=**None** \
# Expose port and run
EXPOSE 8080
CMD ["/etc/openvpn/start.sh"]
CMD ["/usr/bin/qbittorrent-nox -d"]
CMD ["/etc/qbittorrent/start.sh"]
CMD ["/etc/qbittorrent/stop.sh"]

View File

@ -1,76 +0,0 @@
#! /bin/sh
export TRANSMISSION_HOME={{ .Env.TRANSMISSION_HOME }}
export TRANSMISSION_ALT_SPEED_DOWN={{ .Env.TRANSMISSION_ALT_SPEED_DOWN }}
export TRANSMISSION_ALT_SPEED_ENABLED={{ .Env.TRANSMISSION_ALT_SPEED_ENABLED }}
export TRANSMISSION_ALT_SPEED_TIME_BEGIN={{ .Env.TRANSMISSION_ALT_SPEED_TIME_BEGIN }}
export TRANSMISSION_ALT_SPEED_TIME_DAY={{ .Env.TRANSMISSION_ALT_SPEED_TIME_DAY }}
export TRANSMISSION_ALT_SPEED_TIME_ENABLED={{ .Env.TRANSMISSION_ALT_SPEED_TIME_ENABLED }}
export TRANSMISSION_ALT_SPEED_TIME_END={{ .Env.TRANSMISSION_ALT_SPEED_TIME_END }}
export TRANSMISSION_ALT_SPEED_UP={{ .Env.TRANSMISSION_ALT_SPEED_UP }}
export TRANSMISSION_BIND_ADDRESS_IPV4={{ .Env.TRANSMISSION_BIND_ADDRESS_IPV4 }}
export TRANSMISSION_BIND_ADDRESS_IPV6={{ .Env.TRANSMISSION_BIND_ADDRESS_IPV6 }}
export TRANSMISSION_BLOCKLIST_ENABLED={{ .Env.TRANSMISSION_BLOCKLIST_ENABLED }}
export TRANSMISSION_BLOCKLIST_URL={{ .Env.TRANSMISSION_BLOCKLIST_URL }}
export TRANSMISSION_CACHE_SIZE_MB={{ .Env.TRANSMISSION_CACHE_SIZE_MB }}
export TRANSMISSION_DHT_ENABLED={{ .Env.TRANSMISSION_DHT_ENABLED }}
export TRANSMISSION_DOWNLOAD_DIR={{ .Env.TRANSMISSION_DOWNLOAD_DIR }}
export TRANSMISSION_DOWNLOAD_LIMIT={{ .Env.TRANSMISSION_DOWNLOAD_LIMIT }}
export TRANSMISSION_DOWNLOAD_LIMIT_ENABLED={{ .Env.TRANSMISSION_DOWNLOAD_LIMIT_ENABLED }}
export TRANSMISSION_DOWNLOAD_QUEUE_ENABLED={{ .Env.TRANSMISSION_DOWNLOAD_QUEUE_ENABLED }}
export TRANSMISSION_DOWNLOAD_QUEUE_SIZE={{ .Env.TRANSMISSION_DOWNLOAD_QUEUE_SIZE }}
export TRANSMISSION_ENCRYPTION={{ .Env.TRANSMISSION_ENCRYPTION }}
export TRANSMISSION_IDLE_SEEDING_LIMIT={{ .Env.TRANSMISSION_IDLE_SEEDING_LIMIT }}
export TRANSMISSION_IDLE_SEEDING_LIMIT_ENABLED={{ .Env.TRANSMISSION_IDLE_SEEDING_LIMIT_ENABLED }}
export TRANSMISSION_INCOMPLETE_DIR={{ .Env.TRANSMISSION_INCOMPLETE_DIR }}
export TRANSMISSION_INCOMPLETE_DIR_ENABLED={{ .Env.TRANSMISSION_INCOMPLETE_DIR_ENABLED }}
export TRANSMISSION_LPD_ENABLED={{ .Env.TRANSMISSION_LPD_ENABLED }}
export TRANSMISSION_MAX_PEERS_GLOBAL={{ .Env.TRANSMISSION_MAX_PEERS_GLOBAL }}
export TRANSMISSION_MESSAGE_LEVEL={{ .Env.TRANSMISSION_MESSAGE_LEVEL }}
export TRANSMISSION_PEER_CONGESTION_ALGORITHM={{ .Env.TRANSMISSION_PEER_CONGESTION_ALGORITHM }}
export TRANSMISSION_PEER_ID_TTL_HOURS={{ .Env.TRANSMISSION_PEER_ID_TTL_HOURS }}
export TRANSMISSION_PEER_LIMIT_GLOBAL={{ .Env.TRANSMISSION_PEER_LIMIT_GLOBAL }}
export TRANSMISSION_PEER_LIMIT_PER_TORRENT={{ .Env.TRANSMISSION_PEER_LIMIT_PER_TORRENT }}
export TRANSMISSION_PEER_PORT={{ .Env.TRANSMISSION_PEER_PORT }}
export TRANSMISSION_PEER_PORT_RANDOM_HIGH={{ .Env.TRANSMISSION_PEER_PORT_RANDOM_HIGH }}
export TRANSMISSION_PEER_PORT_RANDOM_LOW={{ .Env.TRANSMISSION_PEER_PORT_RANDOM_LOW }}
export TRANSMISSION_PEER_PORT_RANDOM_ON_START={{ .Env.TRANSMISSION_PEER_PORT_RANDOM_ON_START }}
export TRANSMISSION_PEER_SOCKET_TOS={{ .Env.TRANSMISSION_PEER_SOCKET_TOS }}
export TRANSMISSION_PEX_ENABLED={{ .Env.TRANSMISSION_PEX_ENABLED }}
export TRANSMISSION_PORT_FORWARDING_ENABLED={{ .Env.TRANSMISSION_PORT_FORWARDING_ENABLED }}
export TRANSMISSION_PREALLOCATION={{ .Env.TRANSMISSION_PREALLOCATION }}
export TRANSMISSION_PREFETCH_ENABLED={{ .Env.TRANSMISSION_PREFETCH_ENABLED }}
export TRANSMISSION_QUEUE_STALLED_ENABLED={{ .Env.TRANSMISSION_QUEUE_STALLED_ENABLED }}
export TRANSMISSION_QUEUE_STALLED_MINUTES={{ .Env.TRANSMISSION_QUEUE_STALLED_MINUTES }}
export TRANSMISSION_RATIO_LIMIT={{ .Env.TRANSMISSION_RATIO_LIMIT }}
export TRANSMISSION_RATIO_LIMIT_ENABLED={{ .Env.TRANSMISSION_RATIO_LIMIT_ENABLED }}
export TRANSMISSION_RENAME_PARTIAL_FILES={{ .Env.TRANSMISSION_RENAME_PARTIAL_FILES }}
export TRANSMISSION_RPC_AUTHENTICATION_REQUIRED={{ .Env.TRANSMISSION_RPC_AUTHENTICATION_REQUIRED }}
export TRANSMISSION_RPC_BIND_ADDRESS={{ .Env.TRANSMISSION_RPC_BIND_ADDRESS }}
export TRANSMISSION_RPC_ENABLED={{ .Env.TRANSMISSION_RPC_ENABLED }}
export TRANSMISSION_RPC_PASSWORD={{ .Env.TRANSMISSION_RPC_PASSWORD }}
export TRANSMISSION_RPC_PORT={{ .Env.TRANSMISSION_RPC_PORT }}
export TRANSMISSION_RPC_URL={{ .Env.TRANSMISSION_RPC_URL }}
export TRANSMISSION_RPC_USERNAME={{ .Env.TRANSMISSION_RPC_USERNAME }}
export TRANSMISSION_RPC_WHITELIST={{ .Env.TRANSMISSION_RPC_WHITELIST }}
export TRANSMISSION_RPC_WHITELIST_ENABLED={{ .Env.TRANSMISSION_RPC_WHITELIST_ENABLED }}
export TRANSMISSION_SCRAPE_PAUSED_TORRENTS_ENABLED={{ .Env.TRANSMISSION_SCRAPE_PAUSED_TORRENTS_ENABLED }}
export TRANSMISSION_SCRIPT_TORRENT_DONE_ENABLED={{ .Env.TRANSMISSION_SCRIPT_TORRENT_DONE_ENABLED }}
export TRANSMISSION_SCRIPT_TORRENT_DONE_FILENAME={{ .Env.TRANSMISSION_SCRIPT_TORRENT_DONE_FILENAME }}
export TRANSMISSION_SEED_QUEUE_ENABLED={{ .Env.TRANSMISSION_SEED_QUEUE_ENABLED }}
export TRANSMISSION_SEED_QUEUE_SIZE={{ .Env.TRANSMISSION_SEED_QUEUE_SIZE }}
export TRANSMISSION_SPEED_LIMIT_DOWN={{ .Env.TRANSMISSION_SPEED_LIMIT_DOWN }}
export TRANSMISSION_SPEED_LIMIT_DOWN_ENABLED={{ .Env.TRANSMISSION_SPEED_LIMIT_DOWN_ENABLED }}
export TRANSMISSION_SPEED_LIMIT_UP={{ .Env.TRANSMISSION_SPEED_LIMIT_UP }}
export TRANSMISSION_SPEED_LIMIT_UP_ENABLED={{ .Env.TRANSMISSION_SPEED_LIMIT_UP_ENABLED }}
export TRANSMISSION_START_ADDED_TORRENTS={{ .Env.TRANSMISSION_START_ADDED_TORRENTS }}
export TRANSMISSION_TRASH_ORIGINAL_TORRENT_FILES={{ .Env.TRANSMISSION_TRASH_ORIGINAL_TORRENT_FILES }}
export TRANSMISSION_UMASK={{ .Env.TRANSMISSION_UMASK }}
export TRANSMISSION_UPLOAD_LIMIT={{ .Env.TRANSMISSION_UPLOAD_LIMIT }}
export TRANSMISSION_UPLOAD_LIMIT_ENABLED={{ .Env.TRANSMISSION_UPLOAD_LIMIT_ENABLED }}
export TRANSMISSION_UPLOAD_SLOTS_PER_TORRENT={{ .Env.TRANSMISSION_UPLOAD_SLOTS_PER_TORRENT }}
export TRANSMISSION_UTP_ENABLED={{ .Env.TRANSMISSION_UTP_ENABLED }}
export TRANSMISSION_WATCH_DIR={{ .Env.TRANSMISSION_WATCH_DIR }}
export TRANSMISSION_WATCH_DIR_ENABLED={{ .Env.TRANSMISSION_WATCH_DIR_ENABLED }}
# Transmission needs to know which VPN provider is used
export OPENVPN_PROVIDER={{ .Env.OPENVPN_PROVIDER }}

View File

@ -1,8 +0,0 @@
#!/bin/sh
while [ 1 ]
do
sleep 1m
/etc/transmission/updatePort.sh
sleep 1h
done

View File

@ -1,74 +0,0 @@
{
"alt-speed-down": {{ .Env.TRANSMISSION_ALT_SPEED_DOWN }},
"alt-speed-enabled": {{ .Env.TRANSMISSION_ALT_SPEED_ENABLED }},
"alt-speed-time-begin": {{ .Env.TRANSMISSION_ALT_SPEED_TIME_BEGIN }},
"alt-speed-time-day": {{ .Env.TRANSMISSION_ALT_SPEED_TIME_DAY }},
"alt-speed-time-enabled": {{ .Env.TRANSMISSION_ALT_SPEED_TIME_ENABLED }},
"alt-speed-time-end": {{ .Env.TRANSMISSION_ALT_SPEED_TIME_END }},
"alt-speed-up": {{ .Env.TRANSMISSION_ALT_SPEED_UP }},
"bind-address-ipv4": "{{ .Env.TRANSMISSION_BIND_ADDRESS_IPV4 }}",
"bind-address-ipv6": "{{ .Env.TRANSMISSION_BIND_ADDRESS_IPV6 }}",
"blocklist-enabled": {{ .Env.TRANSMISSION_BLOCKLIST_ENABLED }},
"blocklist-url": "{{ .Env.TRANSMISSION_BLOCKLIST_URL }}",
"cache-size-mb": {{ .Env.TRANSMISSION_CACHE_SIZE_MB }},
"dht-enabled": {{ .Env.TRANSMISSION_DHT_ENABLED }},
"download-dir": "{{ .Env.TRANSMISSION_DOWNLOAD_DIR }}",
"download-limit": {{ .Env.TRANSMISSION_DOWNLOAD_LIMIT }},
"download-limit-enabled": {{ .Env.TRANSMISSION_DOWNLOAD_LIMIT_ENABLED }},
"download-queue-enabled": {{ .Env.TRANSMISSION_DOWNLOAD_QUEUE_ENABLED }},
"download-queue-size": {{ .Env.TRANSMISSION_DOWNLOAD_QUEUE_SIZE }},
"encryption": {{ .Env.TRANSMISSION_ENCRYPTION }},
"idle-seeding-limit": {{ .Env.TRANSMISSION_IDLE_SEEDING_LIMIT }},
"idle-seeding-limit-enabled": {{ .Env.TRANSMISSION_IDLE_SEEDING_LIMIT_ENABLED }},
"incomplete-dir": "{{ .Env.TRANSMISSION_INCOMPLETE_DIR }}",
"incomplete-dir-enabled": {{ .Env.TRANSMISSION_INCOMPLETE_DIR_ENABLED }},
"lpd-enabled": {{ .Env.TRANSMISSION_LPD_ENABLED }},
"max-peers-global": {{ .Env.TRANSMISSION_MAX_PEERS_GLOBAL }},
"message-level": {{ .Env.TRANSMISSION_MESSAGE_LEVEL }},
"peer-congestion-algorithm": "{{ .Env.TRANSMISSION_PEER_CONGESTION_ALGORITHM }}",
"peer-id-ttl-hours": {{ .Env.TRANSMISSION_PEER_ID_TTL_HOURS }},
"peer-limit-global": {{ .Env.TRANSMISSION_PEER_LIMIT_GLOBAL }},
"peer-limit-per-torrent": {{ .Env.TRANSMISSION_PEER_LIMIT_PER_TORRENT }},
"peer-port": {{ .Env.TRANSMISSION_PEER_PORT }},
"peer-port-random-high": {{ .Env.TRANSMISSION_PEER_PORT_RANDOM_HIGH }},
"peer-port-random-low": {{ .Env.TRANSMISSION_PEER_PORT_RANDOM_LOW }},
"peer-port-random-on-start": {{ .Env.TRANSMISSION_PEER_PORT_RANDOM_ON_START }},
"peer-socket-tos": "{{ .Env.TRANSMISSION_PEER_SOCKET_TOS }}",
"pex-enabled": {{ .Env.TRANSMISSION_PEX_ENABLED }},
"port-forwarding-enabled": {{ .Env.TRANSMISSION_PORT_FORWARDING_ENABLED }},
"preallocation": {{ .Env.TRANSMISSION_PREALLOCATION }},
"prefetch-enabled": {{ .Env.TRANSMISSION_PREFETCH_ENABLED }},
"queue-stalled-enabled": {{ .Env.TRANSMISSION_QUEUE_STALLED_ENABLED }},
"queue-stalled-minutes": {{ .Env.TRANSMISSION_QUEUE_STALLED_MINUTES }},
"ratio-limit": {{ .Env.TRANSMISSION_RATIO_LIMIT }},
"ratio-limit-enabled": {{ .Env.TRANSMISSION_RATIO_LIMIT_ENABLED }},
"rename-partial-files": {{ .Env.TRANSMISSION_RENAME_PARTIAL_FILES }},
"rpc-authentication-required": {{ .Env.TRANSMISSION_RPC_AUTHENTICATION_REQUIRED }},
"rpc-bind-address": "{{ .Env.TRANSMISSION_RPC_BIND_ADDRESS }}",
"rpc-enabled": {{ .Env.TRANSMISSION_RPC_ENABLED }},
"rpc-password": "{{ .Env.TRANSMISSION_RPC_PASSWORD }}",
"rpc-port": {{ .Env.TRANSMISSION_RPC_PORT }},
"rpc-url": "{{ .Env.TRANSMISSION_RPC_URL }}",
"rpc-username": "{{ .Env.TRANSMISSION_RPC_USERNAME }}",
"rpc-whitelist": "{{ .Env.TRANSMISSION_RPC_WHITELIST }}",
"rpc-whitelist-enabled": {{ .Env.TRANSMISSION_RPC_WHITELIST_ENABLED }},
"scrape-paused-torrents-enabled": {{ .Env.TRANSMISSION_SCRAPE_PAUSED_TORRENTS_ENABLED }},
"script-torrent-done-enabled": {{ .Env.TRANSMISSION_SCRIPT_TORRENT_DONE_ENABLED }},
"script-torrent-done-filename": "{{ .Env.TRANSMISSION_SCRIPT_TORRENT_DONE_FILENAME }}",
"seed-queue-enabled": {{ .Env.TRANSMISSION_SEED_QUEUE_ENABLED }},
"seed-queue-size": {{ .Env.TRANSMISSION_SEED_QUEUE_SIZE }},
"speed-limit-down": {{ .Env.TRANSMISSION_SPEED_LIMIT_DOWN }},
"speed-limit-down-enabled": {{ .Env.TRANSMISSION_SPEED_LIMIT_DOWN_ENABLED }},
"speed-limit-up": {{ .Env.TRANSMISSION_SPEED_LIMIT_UP }},
"speed-limit-up-enabled": {{ .Env.TRANSMISSION_SPEED_LIMIT_UP_ENABLED }},
"start-added-torrents": {{ .Env.TRANSMISSION_START_ADDED_TORRENTS }},
"trash-original-torrent-files": {{ .Env.TRANSMISSION_TRASH_ORIGINAL_TORRENT_FILES }},
"umask": {{ .Env.TRANSMISSION_UMASK }},
"upload-limit": {{ .Env.TRANSMISSION_UPLOAD_LIMIT }},
"upload-limit-enabled": {{ .Env.TRANSMISSION_UPLOAD_LIMIT_ENABLED }},
"upload-slots-per-torrent": {{ .Env.TRANSMISSION_UPLOAD_SLOTS_PER_TORRENT }},
"utp-enabled": {{ .Env.TRANSMISSION_UTP_ENABLED }},
"watch-dir": "{{ .Env.TRANSMISSION_WATCH_DIR }}",
"watch-dir-enabled": {{ .Env.TRANSMISSION_WATCH_DIR_ENABLED }}
}

View File

@ -1,32 +0,0 @@
#!/bin/sh
# Source our persisted env variables from container startup
. /etc/transmission/environment-variables.sh
tun0ip=$(ifconfig tun0 | sed -n '2 p' | awk '{print $2}' | cut -d: -f2)
echo "Updating TRANSMISSION_BIND_ADDRESS_IPV4 to tun0 ip: ${tun0ip}"
export TRANSMISSION_BIND_ADDRESS_IPV4=${tun0ip}
echo "Generating transmission settings.json from env variables"
# Ensure TRANSMISSION_HOME is created
mkdir -p ${TRANSMISSION_HOME}
dockerize -template /etc/transmission/settings.tmpl:${TRANSMISSION_HOME}/settings.json /bin/true
if [ ! -e "/dev/random" ]; then
# Avoid "Fatal: no entropy gathering module detected" error
echo "INFO: /dev/random not found - symlink to /dev/urandom"
ln -s /dev/urandom /dev/random
fi
echo "STARTING TRANSMISSION"
exec /usr/bin/transmission-daemon -g ${TRANSMISSION_HOME} --logfile ${TRANSMISSION_HOME}/transmission.log &
if [ "$OPENVPN_PROVIDER" = "PIA" ]
then
echo "STARTING PORT UPDATER"
exec /etc/transmission/periodicUpdates.sh &
else
echo "NO PORT UPDATER FOR THIS PROVIDER"
fi
echo "Transmission startup script complete."

View File

@ -1,3 +0,0 @@
#! /bin/sh
kill $(ps aux | grep transmission-daemon | grep -v grep | awk '{print $2}')

View File

@ -1,64 +0,0 @@
#! /bin/sh
# Source our persisted env variables from container startup
. /etc/transmission/environment-variables.sh
# Settings
PIA_PASSWD_FILE=/config/openvpn-credentials.txt
TRANSMISSION_PASSWD_FILE=/config/transmission-credentials.txt
pia_username=$(head -1 $PIA_PASSWD_FILE)
pia_passwd=$(tail -1 $PIA_PASSWD_FILE)
transmission_username=$(head -1 $TRANSMISSION_PASSWD_FILE)
transmission_passwd=$(tail -1 $TRANSMISSION_PASSWD_FILE)
local_vpn_ip=$(ip addr show tun0 | grep "inet " | awk '{ print $2 }')
pia_client_id_file=/etc/transmission/pia_client_id
transmission_settings_file=${TRANSMISSION_HOME}/settings.json
port_assignment_url=https://www.privateinternetaccess.com/vpninfo/port_forward_assignment
#
# First get a port from PIA
#
new_client_id() {
head -n 100 /dev/urandom | md5sum | tr -d " -" | tee $pia_client_id_file
}
pia_client_id="$(cat $pia_client_id_file 2>/dev/null)"
if [ -z ${pia_client_id} ]; then
echo "Generating new client id for PIA"
pia_client_id=$(new_client_id)
fi
# Get the port
pia_response=$(curl -d "user=$pia_username&pass=$pia_passwd&client_id=$pia_client_id&local_ip=$local_vpn_ip" $port_assignment_url)
new_port=$(echo $pia_response | grep -oE "[0-9]+")
echo "Got new port $new_port from pia"
#
# Now, set port in Transmission
#
# Check if transmission remote is set up with authentication
auth_enabled=$(grep 'rpc-authentication-required\"' $transmission_settings_file | grep -oE 'true|false')
if [ "true" = "$auth_enabled" ]
then
echo "transmission auth required"
myauth="--auth $transmission_username:$transmission_passwd"
else
echo "transmission auth not required"
myauth=""
fi
# get current listening port
transmission_peer_port=$(transmission-remote $myauth -si | grep Listenport | grep -oE '[0-9]+')
if [ "$new_port" != "$transmission_peer_port" ]
then
transmission-remote $myauth -p "$new_port"
echo "Checking port..."
sleep 10 && transmission-remote $myauth -pt
else
echo "No action needed, port hasn't changed"
fi