From 93be50c45158b758e1a3173f5c761c114c7e0909 Mon Sep 17 00:00:00 2001 From: SunFlowerOwl <85146049+SunFlowerOwl@users.noreply.github.com> Date: Wed, 15 Oct 2025 03:02:25 -0400 Subject: [PATCH] Create docker-transmission-openvpn application (#866) * Create docker-transmission-openvpn application * Partially addressed review 1 * Fix: Avoid .env generation error * Add execute right on image scripts * Fix: Force transmission home var * Fix: unsupported custom app path * Review: Make .env generation simpler * Fix: Change cron command causing error due to crlf * Review: Rework fetching WebUI * Improve cleaning up * Add warning message to setup vpn provider * Rework update function * Fix: Change var_tun default value to yes * Review: Remove Healthcheck cron job * Review: Directly deploy WebUI to /opt/transmission-ui/ * Make custom config persistent when updating * Fix: fetch WebUI from correct URL (old one was invalid) * Fix: resolve conflicting Privoxy instance * Fix: align binary path when fetching branch vs release * Security: Remove old and deprecated WebUI for security reasons * Review: drop unnecessary packages and optimize implementations * Review: Implement local network dynamic detection * CR, OS: Migrate to Debian 13 * Use quiet mode for several commands as recommended * Review: Replace hard coding app name instead of using var $APP * Review: Reduce amount of msg_blocks * refactor * refactor --------- Co-authored-by: Tobias <96661824+CrazyWolf13@users.noreply.github.com> --- ct/transmission-openvpn.sh | 86 +++++++++++ .../public/json/transmission-openvpn.json | 40 +++++ install/transmission-openvpn-install.sh | 140 ++++++++++++++++++ 3 files changed, 266 insertions(+) create mode 100644 ct/transmission-openvpn.sh create mode 100644 frontend/public/json/transmission-openvpn.json create mode 100644 install/transmission-openvpn-install.sh diff --git a/ct/transmission-openvpn.sh b/ct/transmission-openvpn.sh new file mode 100644 index 000000000..647339241 --- /dev/null +++ b/ct/transmission-openvpn.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: SunFlowerOwl +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/haugene/docker-transmission-openvpn + +APP="transmission-openvpn" +var_tags="${var_tags:-torrent;vpn}" +var_cpu="${var_cpu:-1}" +var_ram="${var_ram:-512}" +var_disk="${var_disk:-8}" +var_os="${var_os:-debian}" +var_version="${var_version:-13}" +var_unprivileged="${var_unprivileged:-1}" +var_tun="${var_tun:-yes}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + if [[ ! -d /opt/transmission-openvpn/ ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + msg_info "Updating Dependencies" + $STD apt-get update + $STD apt-get -y upgrade + msg_ok "Updated Dependencies" + + if check_for_gh_release "docker-transmission-openvpn" "haugene/docker-transmission-openvpn"; then + msg_info "Stopping Service" + systemctl stop openvpn-custom + msg_ok "Stopped Service" + + msg_info "Creating Backup" + mv /etc/openvpn/custom /opt/transmission-openvpn/ + rm -f /opt/transmission-openvpn/config-failure.sh + msg_ok "Created Backup" + + fetch_and_deploy_gh_release "docker-transmission-openvpn" "haugene/docker-transmission-openvpn" "tarball" "latest" "/opt/docker-transmission-openvpn" + + msg_info "Configuring transmission-openvpn" + rm -rf /etc/openvpn/* /etc/transmission/* /etc/scripts/* /opt/privoxy/* + cp -r /opt/docker-transmission-openvpn/openvpn/* /etc/openvpn/ + cp -r /opt/docker-transmission-openvpn/transmission/* /etc/transmission/ + cp -r /opt/docker-transmission-openvpn/scripts/* /etc/scripts/ + cp -r /opt/docker-transmission-openvpn/privoxy/scripts/* /opt/privoxy/ + chmod +x /etc/openvpn/*.sh + chmod +x /etc/scripts/*.sh + chmod +x /opt/privoxy/*.sh + msg_ok "Configured transmission-openvpn" + + msg_info "Restoring Backup" + cp -r /opt/transmission-openvpn/custom/* /etc/openvpn/custom/ + msg_ok "Restored Backup" + + msg_info "Starting Service" + systemctl start openvpn-custom + msg_ok "Started Service" + fi + + msg_info "Cleaning up" + $STD apt -y autoremove + $STD apt -y autoclean + $STD apt -y clean + rm -rf /opt/docker-transmission-openvpn + msg_ok "Cleaned" + + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:9091${CL}" diff --git a/frontend/public/json/transmission-openvpn.json b/frontend/public/json/transmission-openvpn.json new file mode 100644 index 000000000..965122f8e --- /dev/null +++ b/frontend/public/json/transmission-openvpn.json @@ -0,0 +1,40 @@ +{ + "name": "Transmission-Openvpn", + "slug": "transmission-openvpn", + "categories": [ + 11 + ], + "date_created": "2025-09-04", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 9091, + "documentation": "https://haugene.github.io/docker-transmission-openvpn/", + "config_path": "/opt/transmission-openvpn/", + "website": "https://github.com/haugene/docker-transmission-openvpn", + "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/transmission.webp", + "description": "This project runs Transmission + OpenVPN natively in an LXC container, using the popular docker-transmission-openvpn image as a base. It ensures all torrent traffic is securely routed through a VPN tunnel, supports a wide range of VPN providers, and offers flexible configuration options", + "install_methods": [ + { + "type": "default", + "script": "ct/transmission-openvpn.sh", + "resources": { + "cpu": 1, + "ram": 512, + "hdd": 8, + "os": "Debian", + "version": "13" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [ + { + "text": "This application requires a VPN provider to work. Please refer to your VPN provider’s documentation for setting up OpenVPN.", + "type": "warning" + } + ] +} diff --git a/install/transmission-openvpn-install.sh b/install/transmission-openvpn-install.sh new file mode 100644 index 000000000..7eeeb422c --- /dev/null +++ b/install/transmission-openvpn-install.sh @@ -0,0 +1,140 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: SunFlowerOwl +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/haugene/docker-transmission-openvpn + +# Import Functions und Setup +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt install -y \ + dnsutils \ + iputils-ping \ + ufw \ + iproute2 +mkdir -p /etc/systemd/system-preset +echo "disable *" > /etc/systemd/system-preset/99-no-autostart.preset +$STD apt install -y \ + transmission-daemon \ + privoxy +rm -f /etc/systemd/system-preset/99-no-autostart.preset +$STD systemctl preset-all +$STD systemctl disable --now transmission-daemon +$STD systemctl mask transmission-daemon +$STD systemctl disable --now privoxy +$STD systemctl mask privoxy +$STD apt install -y openvpn +msg_ok "Installed Dependencies" + +fetch_and_deploy_gh_release "docker-transmission-openvpn" "haugene/docker-transmission-openvpn" "tarball" "latest" "/opt/docker-transmission-openvpn" + +msg_info "Configuring transmission-openvpn" +$STD useradd -u 911 -U -d /config -s /usr/sbin/nologin abc +mkdir -p /etc/openvpn /etc/transmission /etc/scripts /opt/privoxy +cp -r /opt/docker-transmission-openvpn/openvpn/* /etc/openvpn/ +cp -r /opt/docker-transmission-openvpn/transmission/* /etc/transmission/ +cp -r /opt/docker-transmission-openvpn/scripts/* /etc/scripts/ +cp -r /opt/docker-transmission-openvpn/privoxy/scripts/* /opt/privoxy/ +chmod +x /etc/openvpn/*.sh +chmod +x /etc/scripts/*.sh +chmod +x /opt/privoxy/*.sh +$STD ln -s /usr/bin/transmission-daemon /usr/local/bin/transmission-daemon +$STD update-alternatives --set iptables /usr/sbin/iptables-legacy +$STD update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy +msg_ok "Configured transmission-openvpn" + +msg_info "Creating Service" +LOCAL_SUBNETS=$( + ip -o -4 addr show \ + | awk '!/127.0.0.1/ { + split($4, a, "/"); ip=a[1]; mask=a[2]; + split(ip, o, "."); + if (mask < 8) { + print "*.*.*.*"; + } else if (mask < 16) { + print o[1]".*.*.*"; + } else if (mask < 24) { + print o[1]"."o[2]".*.*"; + } else { + print o[1]"."o[2]"."o[3]".*"; + } + }' \ + | sort -u | paste -sd, - +) +TRANSMISSION_RPC_WHITELIST="127.0.0.*,${LOCAL_SUBNETS}" +mkdir -p /opt/transmission-openvpn +cat < "/opt/transmission-openvpn/.env" +OPENVPN_USERNAME="username" +OPENVPN_PASSWORD="password" +OPENVPN_PROVIDER="PIA" +OPENVPN_CONFIG=france +OPENVPN_OPTS="--inactive 3600 --ping 10 --ping-exit 60 --mute-replay-warnings" +CUSTOM_OPENVPN_CONFIG_DIR="/opt/transmission-openvpn" +GLOBAL_APPLY_PERMISSIONS="true" +TRANSMISSION_HOME="/config/transmission-home" +TRANSMISSION_RPC_PORT="9091" +TRANSMISSION_RPC_USERNAME="" +TRANSMISSION_RPC_PASSWORD="" +TRANSMISSION_DOWNLOAD_DIR="/data/complete" +TRANSMISSION_INCOMPLETE_DIR="/data/incomplete" +TRANSMISSION_WATCH_DIR="/data/watch" +TRANSMISSION_WEB_UI="" +TRANSMISSION_UMASK="2" +TRANSMISSION_RATIO_LIMIT_ENABLED="true" +TRANSMISSION_RATIO_LIMIT="0" +TRANSMISSION_RPC_WHITELIST_ENABLED="false" +TRANSMISSION_RPC_WHITELIST="${TRANSMISSION_RPC_WHITELIST}" +CREATE_TUN_DEVICE="false" +ENABLE_UFW="false" +UFW_ALLOW_GW_NET="false" +UFW_EXTRA_PORTS="" +UFW_DISABLE_IPTABLES_REJECT="false" +PUID="911" +PGID="" +PEER_DNS="true" +PEER_DNS_PIN_ROUTES="true" +DROP_DEFAULT_ROUTE="" +WEBPROXY_ENABLED="true" +WEBPROXY_PORT="8118" +WEBPROXY_BIND_ADDRESS="" +WEBPROXY_USERNAME="" +WEBPROXY_PASSWORD="" +LOG_TO_STDOUT="false" +HEALTH_CHECK_HOST="google.com" +SELFHEAL="false" +EOF +cat < /etc/systemd/system/openvpn-custom.service +[Unit] +Description=Custom OpenVPN start service +After=network.target + +[Service] +Type=simple +ExecStart=/etc/openvpn/start.sh +Restart=on-failure +RestartSec=5 +EnvironmentFile=/opt/transmission-openvpn/.env + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable --now -q openvpn-custom.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt -y autoremove +$STD apt -y autoclean +$STD apt -y clean +rm -rf /opt/docker-transmission-openvpn +msg_ok "Cleaned"