# Syncthing A very simple way to setup/run Syncthing in a container. This approach will also update to the latest syncthing releases if available. ## Inspiration / Sources - [https://github.com/syncthing/syncthing/releases](https://github.com/syncthing/syncthing/releases) - [https://docs.syncthing.net/users/autostart.html#linux](https://docs.syncthing.net/users/autostart.html#linux) ## Dependencies We need one utility to ensure we can find the latest releases. Install it. ``` bash apt update apt install jq ``` ## Preflight Configuration Setup basic config / storage areas ahead of install ```bash mkdir -p /var/syncthing/.config/syncthing groupadd syncthing useradd -s /usr/sbin/nologin -d /var/syncthing -g syncthing syncthing cat > /var/syncthing/.config/syncthing/config.xml < false true false false 10 /tank/syncthing EOF chown syncthing -R /var/syncthing chgrp syncthing -R /var/syncthing ``` ## Install Syncthing Grab the latest release of syncthing, drop it in place, setup system service. ``` bash RELEASE=`curl -s https://api.github.com/repos/syncthing/syncthing/releases/latest | jq -r .tag_name` ARCH=`arch` if [ $ARCH == "aarch64" ] then ARCH="arm64" else ARCH="arm" fi gpg --keyserver keyserver.debian.com --recv-key D26E6ED000654A3E mkdir -p /tmp/syncthing cd /tmp/syncthing curl -sLO https://github.com/syncthing/syncthing/releases/download/${RELEASE}/syncthing-linux-${ARCH}-${RELEASE}.tar.gz curl -sLO https://github.com/syncthing/syncthing/releases/download/${RELEASE}/sha256sum.txt.asc gpg --verify sha256sum.txt.asc grep syncthing-linux-${ARCH} sha256sum.txt.asc | sha256sum tar -zxf syncthing-linux-${ARCH}-${RELEASE}.tar.gz mv syncthing-linux-${ARCH}-${RELEASE}/syncthing /usr/bin/syncthing chmod a+x /usr/bin/syncthing mv syncthing-linux-${ARCH}-${RELEASE}/etc/linux-systemd/system/syncthing@.service /etc/systemd/system systemctl daemon-reload cd ~ rm -rf /tmp/syncthing ``` ## Adjust firewall to allow syncthing on internal network(s) ``` bash firewall-cmd --permanent --zone=internal --add-port 22000/tcp --add-port 21027/udp # Allow GUI from docker containers (it'll be proxied by the main web proxy container for ssl purposes) firewall-cmd --permanent --zone=trusted --add-port 22000/tcp --add-port 21027/udp --add-port 8384/tcp firewall-cmd --reload ``` ## Run Syncthing Via systemd Service ``` bash systemctl enable syncthing@syncthing.service systemctl start syncthing@syncthing.service ``` ## Setup Update Script Syncthing has an auto update mechanism. Script it so it can be run at any point to get updates. ``` bash cat > /root/update_syncthing.sh < /etc/unbound/local_zone/syncthing.conf < /etc/caddy/services/syncthing.conf <