diff --git a/Dockerfile b/Dockerfile index d646d77..f616512 100644 --- a/Dockerfile +++ b/Dockerfile @@ -241,6 +241,7 @@ RUN apk --update --no-cache add \ php82-zip \ python3 \ py3-pip \ + screen \ shadow \ sox \ tar \ diff --git a/README.md b/README.md index 40ba1ff..2b1e56f 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ ___ * [WAN IP address](#wan-ip-address) * [Configure rTorrent session saving](#configure-rtorrent-session-saving) * [Configure rTorrent tracker scrape](#rtorrent-tracker-scrape-patch) + * [Configure rTorrent launch mode](#rtorrent-launch-mode) * [Upgrade](#upgrade) * [Contributing](#contributing) * [License](#license) @@ -139,6 +140,7 @@ Image: crazymax/rtorrent-rutorrent:latest * `RT_TRACKER_DELAY_SCRAPE`: Delay tracker announces at startup (default `true`) * `RT_DHT_PORT`: DHT UDP port (`dht.port.set`, default `6881`) * `RT_INC_PORT`: Incoming connections (`network.port_range.set`, default `50000`) +* `RT_DAEMON_MODE`: Run rTorrent in daemon mode (default `true`) ### ruTorrent @@ -355,6 +357,13 @@ The default value is `true`. There are two main benefits to keeping this feature 1) Software Stability: rTorrent will not crash or time-out with tens of thousands of trackers. 2) Immediate Access: ruTorrent can be accessed immediately after rTorrent is started. +## rTorrent launch mode +`RT_DAEMON_MODE` when set to `true` will run rTorrent in the background using daemon mode. +The default value is true for daemon mode. This will disable the rTorrent ncurses interface. + +`RT_DAEMON_MODE` when set to `false` will run rTorrent in the foreground using a linux screen. +The name of the linux screen is `rtorrent`. This feature may be required for graceful exit. + ## Upgrade To upgrade, pull the newer image and launch the container: diff --git a/rootfs/etc/cont-init.d/03-config.sh b/rootfs/etc/cont-init.d/03-config.sh index 75912e4..ad8e65b 100644 --- a/rootfs/etc/cont-init.d/03-config.sh +++ b/rootfs/etc/cont-init.d/03-config.sh @@ -26,6 +26,7 @@ RT_LOG_EXECUTE=${RT_LOG_EXECUTE:-false} RT_LOG_XMLRPC=${RT_LOG_XMLRPC:-false} RT_SESSION_SAVE_SECONDS=${RT_SESSION_SAVE_SECONDS:-3600} RT_TRACKER_DELAY_SCRAPE=${RT_TRACKER_DELAY_SCRAPE:-true} +RT_DAEMON_MODE=${RT_DAEMON_MODE:-true} RU_REMOVE_CORE_PLUGINS=${RU_REMOVE_CORE_PLUGINS:-httprpc} RU_HTTP_USER_AGENT=${RU_HTTP_USER_AGENT:-Mozilla/5.0 (Windows NT 6.0; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0} diff --git a/rootfs/etc/cont-init.d/04-create-services.sh b/rootfs/etc/cont-init.d/04-create-services.sh index f00c3e0..467d2f9 100644 --- a/rootfs/etc/cont-init.d/04-create-services.sh +++ b/rootfs/etc/cont-init.d/04-create-services.sh @@ -25,12 +25,14 @@ cat > /etc/services.d/rtorrent/run <> /etc/services.d/rtorrent/run + +[[ -z "${WAN_IP}" ]] && wan="" || wan="-i ${WAN_IP}" +if [ "$RT_DAEMON_MODE" = false ]; then + echo "screen -D -m -S rtorrent s6-setuidgid ${PUID}:${PGID} rtorrent -D -o import=/etc/rtorrent/.rtlocal.rc ${wan}" >> /etc/services.d/rtorrent/run else - echo "rtorrent -D -o import=/etc/rtorrent/.rtlocal.rc -i ${WAN_IP}" >> /etc/services.d/rtorrent/run + echo "s6-setuidgid ${PUID}:${PGID}" >> /etc/services.d/rtorrent/run + echo "rtorrent -D -o import=/etc/rtorrent/.rtlocal.rc ${wan}" >> /etc/services.d/rtorrent/run fi chmod +x /etc/services.d/rtorrent/run diff --git a/rootfs/tpls/etc/rtorrent/.rtlocal.rc b/rootfs/tpls/etc/rtorrent/.rtlocal.rc index eadd727..c586248 100644 --- a/rootfs/tpls/etc/rtorrent/.rtlocal.rc +++ b/rootfs/tpls/etc/rtorrent/.rtlocal.rc @@ -1,5 +1,5 @@ # Launch as a daemon -system.daemon.set = true +system.daemon.set = @RT_DAEMON_MODE@ # Instance layout method.insert = cfg.basedir, private|const|string, (cat,"/data/rtorrent/") diff --git a/test/rtorrent-rutorrent.env b/test/rtorrent-rutorrent.env index 3af8182..c02450a 100644 --- a/test/rtorrent-rutorrent.env +++ b/test/rtorrent-rutorrent.env @@ -21,6 +21,7 @@ WEBDAV_AUTHBASIC_STRING=WebDAV restricted access RT_LOG_LEVEL=info RT_LOG_EXECUTE=false RT_LOG_XMLRPC=false +RT_DAEMON_MODE=true RU_REMOVE_CORE_PLUGINS=httprpc RU_HTTP_USER_AGENT=Mozilla/5.0 (Windows NT 6.0; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0