Skip to content

Commit

Permalink
add optional vars for custom complete/incomplete paths
Browse files Browse the repository at this point in the history
closes #265
  • Loading branch information
cartfisk committed Dec 5, 2023
1 parent 6bfae65 commit 5e3b7ad
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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 \
Expand Down Expand Up @@ -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. |
Expand Down
8 changes: 8 additions & 0 deletions readme-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)."}
Expand Down
29 changes: 22 additions & 7 deletions root/etc/s6-overlay/s6-rc.d/init-transmission-config/run
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5e3b7ad

Please sign in to comment.