diff --git a/README.md b/README.md index 7bf76d80..7baf009b 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,12 @@ Use `HOST_WHITELIST` to enable an list of dns names as host-whitelist. This enab Use `PEERPORT` to specify the port(s) Transmission should listen on. This disables random port selection. This should be the same as the port mapped in your docker configuration. +## Use alternative Transmission folder paths + +Use `COMPLETE_PATH` to specify a custom path for completed downloads. + +Use `INCOMPLETE_PATH` to specify a custom path for in-progress downloads. + ## Usage To help you get started creating a container from this image you can either use docker-compose or the docker cli. @@ -106,6 +112,8 @@ services: - WHITELIST= #optional - PEERPORT= #optional - HOST_WHITELIST= #optional + - COMPLETE_PATH=/downloads/complete #optional + - INCOMPLETE_PATH=/downloads/incomplete #optional volumes: - /path/to/data:/config - /path/to/downloads:/downloads @@ -131,6 +139,8 @@ docker run -d \ -e WHITELIST= `#optional` \ -e PEERPORT= `#optional` \ -e HOST_WHITELIST= `#optional` \ + -e COMPLETE_PATH=/downloads/complete `#optional` \ + -e INCOMPLETE_PATH=/downloads/incomplete `#optional` \ -p 9091:9091 \ -p 51413:51413 \ -p 51413:51413/udp \ @@ -159,6 +169,8 @@ Containers are configured using parameters passed at runtime (such as those abov | `-e WHITELIST=` | Specify an optional list of comma separated ip whitelist. Fills rpc-whitelist setting. | | `-e PEERPORT=` | Specify an optional port for torrent TCP/UDP connections. Fills peer-port setting. | | `-e HOST_WHITELIST=` | Specify an optional list of comma separated dns name whitelist. Fills rpc-host-whitelist setting. | +| `-e COMPLETE_PATH=/downloads/complete` | Custom path for completed downloads | +| `-e INCOMPLETE_PATH=/downloads/incomplete` | Custom path for incomplete downloads | | `-v /config` | Where transmission should store config files and logs. | | `-v /downloads` | Local path for downloads. | | `-v /watch` | Watch folder for torrent files. | diff --git a/readme-vars.yml b/readme-vars.yml index 69e0d001..9e0767bc 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -45,6 +45,8 @@ opt_param_env_vars: - { env_var: "WHITELIST", env_value: "", desc: "Specify an optional list of comma separated ip whitelist. Fills rpc-whitelist setting."} - { env_var: "PEERPORT", env_value: "", desc: "Specify an optional port for torrent TCP/UDP connections. Fills peer-port setting."} - { env_var: "HOST_WHITELIST", env_value: "", desc: "Specify an optional list of comma separated dns name whitelist. Fills rpc-host-whitelist setting."} + - { env_var: "COMPLETE_PATH", env_value: "/downloads/complete", desc: "Custom path for completed downloads" } + - { env_var: "INCOMPLETE_PATH", env_value: "/downloads/incomplete", desc: "Custom path for incomplete downloads" } opt_param_usage_include_vols: false opt_param_usage_include_ports: false opt_param_device_map: false @@ -78,6 +80,12 @@ app_setup_block: | Use `PEERPORT` to specify the port(s) Transmission should listen on. This disables random port selection. This should be the same as the port mapped in your docker configuration. + ## Use alternative Transmission folder paths + + Use `COMPLETE_PATH` to specify a custom path for completed downloads. + + Use `INCOMPLETE_PATH` to specify a custom path for in-progress downloads. + # changelog changelogs: - { date: "07.10.23:", desc: "Install unrar from [linuxserver repo](https://github.com/linuxserver/docker-unrar)."} diff --git a/root/etc/s6-overlay/s6-rc.d/init-transmission-config/run b/root/etc/s6-overlay/s6-rc.d/init-transmission-config/run index 4a69343f..f66abcf7 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-transmission-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-transmission-config/run @@ -1,15 +1,30 @@ #!/usr/bin/with-contenv bash # shellcheck shell=bash -# make folders -mkdir -p \ - /downloads/{complete,incomplete} /watch # copy config if [[ ! -f /config/settings.json ]]; then cp /defaults/settings.json /config/settings.json fi +# make folders, optionally set paths in config +mkdir -p /watch + +INIT_COMPLETE_PATH="/downloads/complete" +INIT_INCOMPLETE_PATH="/downloads/incomplete" + +if [[ -n "$COMPLETE_PATH" ]]; then + INIT_COMPLETE_PATH="$COMPLETE_PATH" + sed -i "/\"download-dir\"/c\ \"download-dir\": \"$COMPLETE_PATH\"," /config/settings.json +fi +mkdir -p "$INIT_COMPLETE_PATH" + +if [[ -n "$INCOMPLETE_PATH" ]]; then + INIT_INCOMPLETE_PATH="$INCOMPLETE_PATH" + sed -i "/\"incomplete-dir\"/c\ \"incomplete-dir\": \"$INCOMPLETE_PATH\"," /config/settings.json +fi +mkdir -p "$INIT_INCOMPLETE_PATH" + if [[ -n "$USER" ]] && [[ -n "$PASS" ]]; then sed -i '/rpc-authentication-required/c\ "rpc-authentication-required": true,' /config/settings.json sed -i "/rpc-username/c\ \"rpc-username\": \"$USER\"," /config/settings.json @@ -53,12 +68,12 @@ if [[ "$(stat -c '%U' /downloads)" != "abc" ]]; then lsiown abc:abc /downloads fi -if [[ "$(stat -c '%U' /downloads/complete)" != "abc" ]]; then - lsiown abc:abc /downloads/complete +if [[ "$(stat -c '%U' "$INIT_COMPLETE_PATH")" != "abc" ]]; then + lsiown abc:abc "$INIT_COMPLETE_PATH" fi -if [[ "$(stat -c '%U' /downloads/incomplete)" != "abc" ]]; then - lsiown abc:abc /downloads/incomplete +if [[ "$(stat -c '%U' "$INIT_INCOMPLETE_PATH")" != "abc" ]]; then + lsiown abc:abc "$INIT_INCOMPLETE_PATH" fi if [[ "$(stat -c '%U' /watch)" != "abc" ]]; then