From c20f33dad4757e06d28ef19b77eab4211b53224e Mon Sep 17 00:00:00 2001 From: Salim B Date: Mon, 1 Jan 2024 15:39:07 +0100 Subject: [PATCH] [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