Skip to content

Commit 5205987

Browse files
committed
fix: read directory paths from settings.json instead of hardcoding
The init script previously hardcoded /downloads/complete and /downloads/incomplete for ownership checks, causing errors when users configure different paths in settings.json. Now reads download-dir, incomplete-dir, and watch-dir from settings.json, and only checks ownership when the corresponding feature is enabled (incomplete-dir-enabled, watch-dir-enabled). jq is already a dependency used earlier in the same script. Closes #34, closes #164 Assisted-By: Claude <[email protected]> Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent c1f9842 commit 5205987

2 files changed

Lines changed: 21 additions & 14 deletions

File tree

readme-vars.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ init_diagram: |
106106
"transmission:latest" <- Base Images
107107
# changelog
108108
changelogs:
109+
- {date: "04.04.26:", desc: "Read download, incomplete, and watch directory paths from settings.json instead of hardcoding them in init script."}
109110
- {date: "29.11.24:", desc: "Fix PEERPORT setting."}
110111
- {date: "07.10.23:", desc: "Install unrar from [linuxserver repo](https://github.com/linuxserver/docker-unrar)."}
111112
- {date: "10.08.23:", desc: "Bump unrar to 6.2.10."}

root/etc/s6-overlay/s6-rc.d/init-transmission-config/run

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,29 @@ if [[ -z ${LSIO_NON_ROOT_USER} ]]; then
4747
lsiown -R abc:abc \
4848
/config
4949

50-
if grep -qe ' /downloads ' /proc/mounts; then
51-
if [[ "$(stat -c '%U' /downloads)" != "abc" ]]; then
52-
lsiown abc:abc /downloads
53-
fi
50+
if [[ -f /config/settings.json ]]; then
51+
DOWNLOAD_DIR=$(jq -r '.["download-dir"] // "/downloads"' /config/settings.json)
52+
INCOMPLETE_DIR=$(jq -r '.["incomplete-dir"] // "/downloads/incomplete"' /config/settings.json)
53+
INCOMPLETE_ENABLED=$(jq -r '.["incomplete-dir-enabled"] // false' /config/settings.json)
54+
WATCH_DIR=$(jq -r '.["watch-dir"] // "/watch"' /config/settings.json)
55+
WATCH_ENABLED=$(jq -r '.["watch-dir-enabled"] // false' /config/settings.json)
56+
else
57+
DOWNLOAD_DIR="/downloads"
58+
INCOMPLETE_DIR="/downloads/incomplete"
59+
INCOMPLETE_ENABLED="true"
60+
WATCH_DIR="/watch"
61+
WATCH_ENABLED="true"
62+
fi
5463

55-
if [[ "$(stat -c '%U' /downloads/complete)" != "abc" ]]; then
56-
lsiown abc:abc /downloads/complete
57-
fi
64+
if [[ -d "${DOWNLOAD_DIR}" ]] && [[ "$(stat -c '%U' "${DOWNLOAD_DIR}")" != "abc" ]]; then
65+
lsiown abc:abc "${DOWNLOAD_DIR}"
66+
fi
5867

59-
if [[ "$(stat -c '%U' /downloads/incomplete)" != "abc" ]]; then
60-
lsiown abc:abc /downloads/incomplete
61-
fi
68+
if [[ "${INCOMPLETE_ENABLED}" == "true" ]] && [[ -d "${INCOMPLETE_DIR}" ]] && [[ "$(stat -c '%U' "${INCOMPLETE_DIR}")" != "abc" ]]; then
69+
lsiown abc:abc "${INCOMPLETE_DIR}"
6270
fi
6371

64-
if grep -qe ' /watch ' /proc/mounts; then
65-
if [[ "$(stat -c '%U' /watch)" != "abc" ]]; then
66-
lsiown abc:abc /watch
67-
fi
72+
if [[ "${WATCH_ENABLED}" == "true" ]] && [[ -d "${WATCH_DIR}" ]] && [[ "$(stat -c '%U' "${WATCH_DIR}")" != "abc" ]]; then
73+
lsiown abc:abc "${WATCH_DIR}"
6874
fi
6975
fi

0 commit comments

Comments
 (0)