From c20f33dad4757e06d28ef19b77eab4211b53224e Mon Sep 17 00:00:00 2001 From: Salim B Date: Mon, 1 Jan 2024 15:39:07 +0100 Subject: [PATCH 1/9] [syncthing] Improve configuration Use environment variables instead of CLI arguments where possible and properly separate config and database/state directories. --- syncthing/Dockerfile | 9 ++++++++- .../root/etc/s6-overlay/s6-rc.d/syncthing/run | 16 +++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/syncthing/Dockerfile b/syncthing/Dockerfile index c2cee5ed..0ca4f18c 100644 --- a/syncthing/Dockerfile +++ b/syncthing/Dockerfile @@ -4,6 +4,13 @@ FROM $BUILD_FROM RUN apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community \ "syncthing=1.25.0-r1" +COPY root / + +ENV STCONFDIR=/config \ + STDATADIR=/data \ + STNODEFAULTFOLDER=1 \ + STNORESTART=1 \ + STNOUPGRADE=1 + ENTRYPOINT [ "/init" ] CMD [] -COPY root / diff --git a/syncthing/root/etc/s6-overlay/s6-rc.d/syncthing/run b/syncthing/root/etc/s6-overlay/s6-rc.d/syncthing/run index 825c7f93..19e6d772 100644 --- a/syncthing/root/etc/s6-overlay/s6-rc.d/syncthing/run +++ b/syncthing/root/etc/s6-overlay/s6-rc.d/syncthing/run @@ -2,19 +2,17 @@ # shellcheck shell=bash set -e -export STNOUPGRADE=1 - -bashio::log.info 'Setup config' -mkdir -p /data/config +bashio::log.info 'Intializing Syncthing' ip=$(ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{sub("addr:",""); print $2}' | head -n 1) if [ -z "$ip" ] then - ip=0.0.0.0 + ip=0.0.0.0 + bashio::log.info "Couldn't detect IP address. Falling back to: $ip" +else + bashio::log.info "Detected IP address: $ip" fi -bashio::log.info "Detected IP Address: $ip" - -bashio::log.info 'Start syncthing' -syncthing --no-browser --no-restart --home=/data/config --gui-address="$ip:8384" +bashio::log.info 'Starting Syncthing' +syncthing --gui-address="$ip:8384" --no-browser From 51bb8ffec7708722da7234c25c406b80fbdfba20 Mon Sep 17 00:00:00 2001 From: Salim B Date: Mon, 1 Jan 2024 15:45:51 +0100 Subject: [PATCH 2/9] [syncthing] Update changelog --- syncthing/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/syncthing/CHANGELOG.md b/syncthing/CHANGELOG.md index b15f45ca..6ad5e52e 100644 --- a/syncthing/CHANGELOG.md +++ b/syncthing/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.18.0 - 2024-?-? + +* 🔨 Configure Syncthing via environment variables instead of CLI arguments where possible and properly separate config and database/state directories (thanks @salim-b | #450) + ## 1.17.0 - 2023-10-13 * 🔨 Set gui-address to first IP in container (thanks @reedy | #426) From 422a215ec2400e3c7fdfc8f6ab94d8bc10f7ccdb Mon Sep 17 00:00:00 2001 From: Salim B Date: Tue, 2 Jan 2024 00:30:06 +0100 Subject: [PATCH 3/9] [syncthing] Update addon version --- syncthing/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syncthing/config.yaml b/syncthing/config.yaml index 561bbbac..dfa30a39 100644 --- a/syncthing/config.yaml +++ b/syncthing/config.yaml @@ -1,5 +1,5 @@ name: Syncthing -version: "1.17.0" +version: "1.18.0" slug: syncthing description: "Syncthing is a continuous file synchronization program in a de-centralized way" From 4ce27a82b599b886f0219cdce3884165ef917f64 Mon Sep 17 00:00:00 2001 From: Salim B Date: Tue, 2 Jan 2024 00:31:20 +0100 Subject: [PATCH 4/9] [syncthing] Use addon_config --- syncthing/config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/syncthing/config.yaml b/syncthing/config.yaml index dfa30a39..67bd4a5b 100644 --- a/syncthing/config.yaml +++ b/syncthing/config.yaml @@ -26,9 +26,9 @@ ingress_port: 8384 panel_title: Syncthing panel_icon: mdi:sync map: - - share:rw - - config:rw - - backup:rw + - addon_config:rw - addons:rw - - ssl:rw + - backup:rw - media:rw + - share:rw + - ssl:rw From 0f44d463088821e7d95f237b1d3c96b02eadb01f Mon Sep 17 00:00:00 2001 From: Salim B Date: Tue, 2 Jan 2024 00:42:29 +0100 Subject: [PATCH 5/9] [syncthing] Fix whitespace --- syncthing/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syncthing/Dockerfile b/syncthing/Dockerfile index 0ca4f18c..d1b0dc52 100644 --- a/syncthing/Dockerfile +++ b/syncthing/Dockerfile @@ -9,7 +9,7 @@ COPY root / ENV STCONFDIR=/config \ STDATADIR=/data \ STNODEFAULTFOLDER=1 \ - STNORESTART=1 \ + STNORESTART=1 \ STNOUPGRADE=1 ENTRYPOINT [ "/init" ] From 40dd4cb6303c03c949c2c4eb8bb38d3b3b59f804 Mon Sep 17 00:00:00 2001 From: Salim B Date: Tue, 2 Jan 2024 01:28:18 +0100 Subject: [PATCH 6/9] [syncthing] Set HOME env var as folder path fallback --- syncthing/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/syncthing/Dockerfile b/syncthing/Dockerfile index d1b0dc52..91470c56 100644 --- a/syncthing/Dockerfile +++ b/syncthing/Dockerfile @@ -6,7 +6,8 @@ RUN apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/c COPY root / -ENV STCONFDIR=/config \ +ENV HOME=/share \ + STCONFDIR=/config \ STDATADIR=/data \ STNODEFAULTFOLDER=1 \ STNORESTART=1 \ From 6740352345495c5a72a29acffb6cd6ec8a9aa8a8 Mon Sep 17 00:00:00 2001 From: Salim B Date: Tue, 2 Jan 2024 02:01:35 +0100 Subject: [PATCH 7/9] [syncthing] Update changelog --- syncthing/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/syncthing/CHANGELOG.md b/syncthing/CHANGELOG.md index 6ad5e52e..48948670 100644 --- a/syncthing/CHANGELOG.md +++ b/syncthing/CHANGELOG.md @@ -1,6 +1,7 @@ ## 1.18.0 - 2024-?-? * 🔨 Configure Syncthing via environment variables instead of CLI arguments where possible and properly separate config and database/state directories (thanks @salim-b | #450) +* 🔨 Set `/share` as default folder path fallback (fixes #447, @salim-b). ## 1.17.0 - 2023-10-13 From be7e67c276c821be84e072cb5c6bf414d580d4c2 Mon Sep 17 00:00:00 2001 From: Salim B Date: Tue, 2 Jan 2024 12:24:10 +0100 Subject: [PATCH 8/9] [syncthing] Update docs --- syncthing/DOCS.md | 1 - 1 file changed, 1 deletion(-) diff --git a/syncthing/DOCS.md b/syncthing/DOCS.md index d845ebcb..63558e72 100644 --- a/syncthing/DOCS.md +++ b/syncthing/DOCS.md @@ -19,7 +19,6 @@ When using this add-on to permanently hold your data, put the synced folders ins - `/data` - `/media` - `/share` -- `/config` - `/ssl` - `/addons` From 289da16e3212ddd25febf57f695c7059480b3e65 Mon Sep 17 00:00:00 2001 From: Salim B Date: Thu, 4 Jan 2024 11:55:22 +0100 Subject: [PATCH 9/9] [syncthing] Add config and database/state migration logic --- syncthing/root/etc/s6-overlay/s6-rc.d/syncthing/run | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/syncthing/root/etc/s6-overlay/s6-rc.d/syncthing/run b/syncthing/root/etc/s6-overlay/s6-rc.d/syncthing/run index 19e6d772..e3ef7865 100644 --- a/syncthing/root/etc/s6-overlay/s6-rc.d/syncthing/run +++ b/syncthing/root/etc/s6-overlay/s6-rc.d/syncthing/run @@ -4,6 +4,7 @@ set -e bashio::log.info 'Intializing Syncthing' +# determine IP address to serve Syncthing's GUI on ip=$(ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{sub("addr:",""); print $2}' | head -n 1) if [ -z "$ip" ] @@ -14,5 +15,15 @@ else bashio::log.info "Detected IP address: $ip" fi +# move config and DB state from old to new locations if necessary, cf. https://github.com/Poeschl/Hassio-Addons/pull/450 +if [ -d /data/config ] +then + for CONF_FILE in config.xml cert.pem key.pem https-cert.pem https-key.pem + do + [ -f "/data/config/${CONF_FILE}" ] && mv -fu "/data/config/${CONF_FILE}" /config/ && rm -f "/data/config/${CONF_FILE}" + done + mv -fu /data/config/* /data/ && rm -f /data/config +fi + bashio::log.info 'Starting Syncthing' syncthing --gui-address="$ip:8384" --no-browser