From 520598766753175e0ad0e7cd8d7a2b4f42701776 Mon Sep 17 00:00:00 2001 From: Aleksei Sviridkin Date: Sat, 4 Apr 2026 21:57:50 +0300 Subject: [PATCH] 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 Signed-off-by: Aleksei Sviridkin --- readme-vars.yml | 1 + .../s6-rc.d/init-transmission-config/run | 34 +++++++++++-------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/readme-vars.yml b/readme-vars.yml index 102ab7bd..88e10334 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -106,6 +106,7 @@ init_diagram: | "transmission:latest" <- Base Images # changelog changelogs: + - {date: "04.04.26:", desc: "Read download, incomplete, and watch directory paths from settings.json instead of hardcoding them in init script."} - {date: "29.11.24:", desc: "Fix PEERPORT setting."} - {date: "07.10.23:", desc: "Install unrar from [linuxserver repo](https://github.com/linuxserver/docker-unrar)."} - {date: "10.08.23:", desc: "Bump unrar to 6.2.10."} 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 94eb82fc..6d78b1b2 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 @@ -47,23 +47,29 @@ if [[ -z ${LSIO_NON_ROOT_USER} ]]; then lsiown -R abc:abc \ /config - if grep -qe ' /downloads ' /proc/mounts; then - if [[ "$(stat -c '%U' /downloads)" != "abc" ]]; then - lsiown abc:abc /downloads - fi + if [[ -f /config/settings.json ]]; then + DOWNLOAD_DIR=$(jq -r '.["download-dir"] // "/downloads"' /config/settings.json) + INCOMPLETE_DIR=$(jq -r '.["incomplete-dir"] // "/downloads/incomplete"' /config/settings.json) + INCOMPLETE_ENABLED=$(jq -r '.["incomplete-dir-enabled"] // false' /config/settings.json) + WATCH_DIR=$(jq -r '.["watch-dir"] // "/watch"' /config/settings.json) + WATCH_ENABLED=$(jq -r '.["watch-dir-enabled"] // false' /config/settings.json) + else + DOWNLOAD_DIR="/downloads" + INCOMPLETE_DIR="/downloads/incomplete" + INCOMPLETE_ENABLED="true" + WATCH_DIR="/watch" + WATCH_ENABLED="true" + fi - if [[ "$(stat -c '%U' /downloads/complete)" != "abc" ]]; then - lsiown abc:abc /downloads/complete - fi + if [[ -d "${DOWNLOAD_DIR}" ]] && [[ "$(stat -c '%U' "${DOWNLOAD_DIR}")" != "abc" ]]; then + lsiown abc:abc "${DOWNLOAD_DIR}" + fi - if [[ "$(stat -c '%U' /downloads/incomplete)" != "abc" ]]; then - lsiown abc:abc /downloads/incomplete - fi + if [[ "${INCOMPLETE_ENABLED}" == "true" ]] && [[ -d "${INCOMPLETE_DIR}" ]] && [[ "$(stat -c '%U' "${INCOMPLETE_DIR}")" != "abc" ]]; then + lsiown abc:abc "${INCOMPLETE_DIR}" fi - if grep -qe ' /watch ' /proc/mounts; then - if [[ "$(stat -c '%U' /watch)" != "abc" ]]; then - lsiown abc:abc /watch - fi + if [[ "${WATCH_ENABLED}" == "true" ]] && [[ -d "${WATCH_DIR}" ]] && [[ "$(stat -c '%U' "${WATCH_DIR}")" != "abc" ]]; then + lsiown abc:abc "${WATCH_DIR}" fi fi