Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
scripts-and-compose:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- name: Install validation tools
run: |
Expand Down
414 changes: 180 additions & 234 deletions README.md

Large diffs are not rendered by default.

745 changes: 209 additions & 536 deletions install_media.sh
100644 → 100755

Large diffs are not rendered by default.

816 changes: 380 additions & 436 deletions media_stack.sh
100644 → 100755

Large diffs are not rendered by default.

189 changes: 71 additions & 118 deletions proxmox_lxc.sh
100644 → 100755

Large diffs are not rendered by default.

83 changes: 43 additions & 40 deletions sync_transmission_port.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env bash

set -Eeuo pipefail
umask 077

Expand All @@ -14,73 +13,77 @@ flock -n 9 || exit 0
TR_USER_FILE="$STACK_DIR/secrets/transmission_user"
TR_PASS_FILE="$STACK_DIR/secrets/transmission_password"
[[ -s "$TR_USER_FILE" && -s "$TR_PASS_FILE" ]] || {
echo "Missing Transmission credential files in $STACK_DIR/secrets." >&2
exit 1
echo "Missing Transmission credentials." >&2
exit 1
}
TR_USER=$(<"$TR_USER_FILE")
TR_PASS=$(<"$TR_PASS_FILE")
cd "$STACK_DIR"

read_forwarded_port() {
local json port
json=$(docker compose exec -T gluetun wget -qO- -T 5 http://127.0.0.1:8000/v1/portforward 2>/dev/null || true)
if [[ -n "$json" ]]; then
port=$(jq -r '.port // (.ports[0] // empty)' <<<"$json" 2>/dev/null || true)
if [[ "$port" =~ ^[0-9]+$ ]] && ((port >= 1 && port <= 65535)); then
printf '%s' "$port"
return 0
fi
fi

# Compatibility fallback for Gluetun v3. The status file is deprecated in v4.
port=$(docker compose exec -T gluetun cat /tmp/gluetun/forwarded_port 2>/dev/null || true)
port=${port//$'\r'/}
port=${port//$'\n'/}
[[ "$port" =~ ^[0-9]+$ ]] && ((port >= 1 && port <= 65535)) || return 1
printf '%s' "$port"
}

cd "$STACK_DIR" || exit 1
forwarded_port=$(docker compose exec -T gluetun cat /tmp/gluetun/forwarded_port 2>/dev/null || true)
forwarded_port=${forwarded_port//$'\r'/}
forwarded_port=${forwarded_port//$'\n'/}
if [[ ! "$forwarded_port" =~ ^[0-9]+$ ]] || ((forwarded_port < 1 || forwarded_port > 65535)); then
echo "ProtonVPN has not assigned a valid forwarded port yet; the timer will retry."
exit 0
forwarded_port=$(read_forwarded_port || true)
if [[ -z "$forwarded_port" ]]; then
echo "ProtonVPN has not assigned a valid forwarded port yet; the timer will retry."
exit 0
fi

temp_dir=$(mktemp -d)
trap 'rm -rf -- "$temp_dir"' EXIT
headers="$temp_dir/headers"
response="$temp_dir/response.json"

# Transmission deliberately answers the first unauthenticated-session request
# with HTTP 409 and returns the session token in a response header.
http_code=$(curl --silent --show-error --max-time 10 \
-u "$TR_USER:$TR_PASS" \
-D "$headers" \
-o /dev/null \
-X POST \
-w '%{http_code}' \
"$RPC_URL")
-u "$TR_USER:$TR_PASS" -D "$headers" -o /dev/null -X POST \
-w '%{http_code}' "$RPC_URL")
[[ "$http_code" == 409 || "$http_code" == 200 ]] || {
echo "Transmission RPC returned HTTP $http_code while requesting a session token." >&2
exit 1
echo "Transmission RPC returned HTTP $http_code while requesting a session token." >&2
exit 1
}

session_id=$(awk -F ':[[:space:]]*' '
tolower($1) == "x-transmission-session-id" {
gsub(/\r/, "", $2)
print $2
}
tolower($1) == "x-transmission-session-id" {gsub(/\r/, "", $2); print $2}
' "$headers" | tail -n1)
[[ -n "$session_id" ]] || {
echo "Transmission did not return an RPC session ID." >&2
exit 1
echo "Transmission did not return an RPC session ID." >&2
exit 1
}

rpc() {
local payload=$1
curl --fail --silent --show-error --max-time 10 \
-u "$TR_USER:$TR_PASS" \
-H "X-Transmission-Session-Id: $session_id" \
-H "Content-Type: application/json" \
--data "$payload" \
"$RPC_URL" > "$response"
jq -e '.result == "success"' "$response" >/dev/null
local payload=$1
curl --fail --silent --show-error --max-time 10 \
-u "$TR_USER:$TR_PASS" \
-H "X-Transmission-Session-Id: $session_id" \
-H 'Content-Type: application/json' \
--data "$payload" "$RPC_URL" >"$response"
jq -e '.result == "success"' "$response" >/dev/null
}

rpc '{"method":"session-get","arguments":{"fields":["peer-port"]}}'
current_port=$(jq -r '.arguments["peer-port"] // empty' "$response")
if [[ "$current_port" == "$forwarded_port" ]]; then
echo "Transmission peer port is already synchronized to $forwarded_port."
exit 0
echo "Transmission peer port is already synchronized to $forwarded_port."
exit 0
fi

payload=$(jq -cn --argjson port "$forwarded_port" '{
method: "session-set",
arguments: {"peer-port": $port, "peer-port-random-on-start": false}
}')
payload=$(jq -cn --argjson port "$forwarded_port" '{method:"session-set",arguments:{"peer-port":$port,"peer-port-random-on-start":false}}')
rpc "$payload"
rpc '{"method":"session-get","arguments":{"fields":["peer-port"]}}'
jq -e --argjson port "$forwarded_port" '.arguments["peer-port"] == $port' "$response" >/dev/null
Expand Down
145 changes: 21 additions & 124 deletions templates/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ x-linuxserver: &linuxserver
networks:
media:
driver: bridge
socket-proxy:
driver: bridge
internal: true

secrets:
transmission_user:
Expand All @@ -39,6 +36,7 @@ services:
VPN_PORT_FORWARDING: "on"
VPN_PORT_FORWARDING_PROVIDER: protonvpn
VPN_PORT_FORWARDING_STATUS_FILE: /tmp/gluetun/forwarded_port
HTTP_CONTROL_SERVER_AUTH_CONFIG_FILEPATH: /gluetun/auth/config.toml
FIREWALL_INPUT_PORTS: "9091"
UPDATER_PERIOD: 480h
TZ: ${TZ:?TZ is required}
Expand Down Expand Up @@ -95,14 +93,12 @@ services:

flaresolverr:
image: ghcr.io/flaresolverr/flaresolverr:latest
profiles:
- flaresolverr
profiles: [flaresolverr]
restart: unless-stopped
environment:
TZ: ${TZ:?TZ is required}
LOG_LEVEL: info
networks:
- media
networks: [media]
security_opt:
- no-new-privileges:true
logging: *default-logging
Expand All @@ -117,15 +113,10 @@ services:
UMASK: "002"
volumes:
- ./config/prowlarr:/config
networks:
- media
networks: [media]
ports:
- target: 9696
published: "9696"
host_ip: 127.0.0.1
- target: 9696
published: "9696"
host_ip: ${LAN_IP:?LAN_IP is required}
- {target: 9696, published: "9696", host_ip: 127.0.0.1}
- {target: 9696, published: "9696", host_ip: "${LAN_IP:?LAN_IP is required}"}
healthcheck:
test: [CMD-SHELL, "curl -fsS --max-time 5 http://127.0.0.1:9696/ping >/dev/null || exit 1"]
start_period: 30s
Expand All @@ -144,15 +135,10 @@ services:
volumes:
- ./config/sonarr:/config
- ./data:/data
networks:
- media
networks: [media]
ports:
- target: 8989
published: "8989"
host_ip: 127.0.0.1
- target: 8989
published: "8989"
host_ip: ${LAN_IP:?LAN_IP is required}
- {target: 8989, published: "8989", host_ip: 127.0.0.1}
- {target: 8989, published: "8989", host_ip: "${LAN_IP:?LAN_IP is required}"}
healthcheck:
test: [CMD-SHELL, "curl -fsS --max-time 5 http://127.0.0.1:8989/ping >/dev/null || exit 1"]
start_period: 30s
Expand All @@ -171,15 +157,10 @@ services:
volumes:
- ./config/radarr:/config
- ./data:/data
networks:
- media
networks: [media]
ports:
- target: 7878
published: "7878"
host_ip: 127.0.0.1
- target: 7878
published: "7878"
host_ip: ${LAN_IP:?LAN_IP is required}
- {target: 7878, published: "7878", host_ip: 127.0.0.1}
- {target: 7878, published: "7878", host_ip: "${LAN_IP:?LAN_IP is required}"}
healthcheck:
test: [CMD-SHELL, "curl -fsS --max-time 5 http://127.0.0.1:7878/ping >/dev/null || exit 1"]
start_period: 30s
Expand All @@ -198,15 +179,10 @@ services:
volumes:
- ./config/bazarr:/config
- ./data:/data
networks:
- media
networks: [media]
ports:
- target: 6767
published: "6767"
host_ip: 127.0.0.1
- target: 6767
published: "6767"
host_ip: ${LAN_IP:?LAN_IP is required}
- {target: 6767, published: "6767", host_ip: 127.0.0.1}
- {target: 6767, published: "6767", host_ip: "${LAN_IP:?LAN_IP is required}"}
healthcheck:
test: [CMD-SHELL, "curl -fsS --max-time 5 http://127.0.0.1:6767/ >/dev/null || exit 1"]
start_period: 45s
Expand All @@ -225,22 +201,10 @@ services:
volumes:
- ./config/jellyfin:/config
- ./data:/data
networks:
- media
networks: [media]
ports:
- target: 8096
published: "8096"
host_ip: 127.0.0.1
- target: 8096
published: "8096"
host_ip: ${LAN_IP:?LAN_IP is required}
labels:
pangolin.public-resources.jellyfin.name: Jellyfin
pangolin.public-resources.jellyfin.full-domain: jellyfin.${PUBLIC_DOMAIN:?PUBLIC_DOMAIN is required}
pangolin.public-resources.jellyfin.mode: http
pangolin.public-resources.jellyfin.targets[0].method: http
pangolin.public-resources.jellyfin.targets[0].hostname: jellyfin
pangolin.public-resources.jellyfin.targets[0].port: "8096"
- {target: 8096, published: "8096", host_ip: 127.0.0.1}
- {target: 8096, published: "8096", host_ip: "${LAN_IP:?LAN_IP is required}"}
healthcheck:
test: [CMD-SHELL, "curl -fsS --max-time 5 http://127.0.0.1:8096/System/Info/Public >/dev/null || exit 1"]
start_period: 45s
Expand All @@ -257,23 +221,10 @@ services:
PORT: "5055"
volumes:
- ./config/seerr:/app/config
networks:
- media
networks: [media]
ports:
- target: 5055
published: "5055"
host_ip: 127.0.0.1
- target: 5055
published: "5055"
host_ip: ${LAN_IP:?LAN_IP is required}
labels:
pangolin.public-resources.seerr.name: Seerr
pangolin.public-resources.seerr.full-domain: seerr.${PUBLIC_DOMAIN:?PUBLIC_DOMAIN is required}
pangolin.public-resources.seerr.mode: http
pangolin.public-resources.seerr.auth.sso-enabled: "true"
pangolin.public-resources.seerr.targets[0].method: http
pangolin.public-resources.seerr.targets[0].hostname: seerr
pangolin.public-resources.seerr.targets[0].port: "5055"
- {target: 5055, published: "5055", host_ip: 127.0.0.1}
- {target: 5055, published: "5055", host_ip: "${LAN_IP:?LAN_IP is required}"}
healthcheck:
test: [CMD-SHELL, "wget -q --spider http://127.0.0.1:5055/api/v1/settings/public || exit 1"]
start_period: 30s
Expand All @@ -286,57 +237,3 @@ services:
security_opt:
- no-new-privileges:true
logging: *default-logging

socket-proxy:
image: lscr.io/linuxserver/socket-proxy:latest
profiles:
- pangolin
restart: unless-stopped
environment:
CONTAINERS: "1"
EVENTS: "1"
INFO: "1"
NETWORKS: "1"
PING: "1"
VERSION: "1"
POST: "0"
ALLOW_RESTARTS: "0"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
networks:
- socket-proxy
read_only: true
tmpfs:
- /run:size=16m,mode=0755
security_opt:
- no-new-privileges:true
logging: *default-logging

newt:
image: fosrl/newt:latest
profiles:
- pangolin
restart: unless-stopped
depends_on:
- socket-proxy
environment:
CONFIG_FILE: /config/config.json
DOCKER_SOCKET: tcp://socket-proxy:2375
DOCKER_ENFORCE_NETWORK_VALIDATION: "true"
HEALTH_FILE: /tmp/healthy
volumes:
- ./config/newt:/config
networks:
- media
- socket-proxy
tmpfs:
- /tmp:size=16m,mode=1777
healthcheck:
test: [CMD-SHELL, "test -f /tmp/healthy"]
start_period: 30s
interval: 20s
timeout: 3s
retries: 3
security_opt:
- no-new-privileges:true
logging: *default-logging
Loading