removed supervisord, using baseimage-docker init system. added automatic port updates.
This commit is contained in:
8
transmission/periodicUpdates.sh
Executable file
8
transmission/periodicUpdates.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
while [ 1 ]
|
||||
do
|
||||
sleep 1m
|
||||
/etc/transmission-daemon/updatePort.sh
|
||||
sleep 1m
|
||||
done
|
||||
2
transmission/run.sh
Executable file
2
transmission/run.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exec /usr/bin/transmission-daemon -f -g /etc/transmission-daemon/
|
||||
3
transmission/runUpdates.sh
Executable file
3
transmission/runUpdates.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
exec /etc/transmission-daemon/periodicUpdates.sh
|
||||
74
transmission/transmissionSettings.json
Normal file
74
transmission/transmissionSettings.json
Normal file
@@ -0,0 +1,74 @@
|
||||
{
|
||||
"alt-speed-down": 50,
|
||||
"alt-speed-enabled": false,
|
||||
"alt-speed-time-begin": 540,
|
||||
"alt-speed-time-day": 127,
|
||||
"alt-speed-time-enabled": false,
|
||||
"alt-speed-time-end": 1020,
|
||||
"alt-speed-up": 50,
|
||||
"bind-address-ipv4": "0.0.0.0",
|
||||
"bind-address-ipv6": "::",
|
||||
"blocklist-enabled": false,
|
||||
"blocklist-url": "http://www.example.com/blocklist",
|
||||
"cache-size-mb": 4,
|
||||
"dht-enabled": true,
|
||||
"download-dir": "/data/completed",
|
||||
"download-limit": 100,
|
||||
"download-limit-enabled": 0,
|
||||
"download-queue-enabled": true,
|
||||
"download-queue-size": 5,
|
||||
"encryption": 1,
|
||||
"idle-seeding-limit": 30,
|
||||
"idle-seeding-limit-enabled": false,
|
||||
"incomplete-dir": "/data/incomplete",
|
||||
"incomplete-dir-enabled": true,
|
||||
"lpd-enabled": false,
|
||||
"max-peers-global": 200,
|
||||
"message-level": 2,
|
||||
"peer-congestion-algorithm": "",
|
||||
"peer-id-ttl-hours": 6,
|
||||
"peer-limit-global": 200,
|
||||
"peer-limit-per-torrent": 50,
|
||||
"peer-port": 51413,
|
||||
"peer-port-random-high": 65535,
|
||||
"peer-port-random-low": 49152,
|
||||
"peer-port-random-on-start": false,
|
||||
"peer-socket-tos": "default",
|
||||
"pex-enabled": true,
|
||||
"port-forwarding-enabled": false,
|
||||
"preallocation": 1,
|
||||
"prefetch-enabled": 1,
|
||||
"queue-stalled-enabled": true,
|
||||
"queue-stalled-minutes": 30,
|
||||
"ratio-limit": 2,
|
||||
"ratio-limit-enabled": false,
|
||||
"rename-partial-files": true,
|
||||
"rpc-authentication-required": false,
|
||||
"rpc-bind-address": "0.0.0.0",
|
||||
"rpc-enabled": true,
|
||||
"rpc-password": "{425745bf3914984c2abcc013276f40e8fa5d84ecC5.df8oF",
|
||||
"rpc-port": 9091,
|
||||
"rpc-url": "/transmission/",
|
||||
"rpc-username": "username",
|
||||
"rpc-whitelist": "127.0.0.1",
|
||||
"rpc-whitelist-enabled": false,
|
||||
"scrape-paused-torrents-enabled": true,
|
||||
"script-torrent-done-enabled": false,
|
||||
"script-torrent-done-filename": "",
|
||||
"seed-queue-enabled": false,
|
||||
"seed-queue-size": 10,
|
||||
"speed-limit-down": 100,
|
||||
"speed-limit-down-enabled": false,
|
||||
"speed-limit-up": 100,
|
||||
"speed-limit-up-enabled": false,
|
||||
"start-added-torrents": true,
|
||||
"trash-original-torrent-files": false,
|
||||
"umask": 2,
|
||||
"upload-limit": 100,
|
||||
"upload-limit-enabled": 0,
|
||||
"upload-slots-per-torrent": 14,
|
||||
"utp-enabled": true,
|
||||
"watch-dir": "/data/watch",
|
||||
"watch-dir-enabled": true
|
||||
}
|
||||
|
||||
58
transmission/updateTransmissionPort.sh
Executable file
58
transmission/updateTransmissionPort.sh
Executable file
@@ -0,0 +1,58 @@
|
||||
#/bin/bash
|
||||
|
||||
# Settings
|
||||
PIA_PASSWD_FILE=/etc/openvpn/credentials.txt
|
||||
|
||||
username=$(head -1 $PIA_PASSWD_FILE)
|
||||
passwd=$(tail -1 $PIA_PASSWD_FILE)
|
||||
local_vpn_ip=$(ip addr show tun0 | grep inet | awk '{ print $2 }')
|
||||
pia_client_id_file=/etc/transmission-daemon/pia_client_id
|
||||
transmission_settings_file=/etc/transmission-daemon/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=$username&pass=$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 username:password"
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user