Created
January 18, 2021 17:14
-
-
Save zloeber/b0d43c8964e57ede1149f5bb3bd07f9a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Installs and configures a user syncthing deployment on Ubuntu | |
# Add the release PGP keys: | |
curl -s https://syncthing.net/release-key.txt | sudo apt-key add - | |
# Add the "stable" channel to your APT sources: | |
echo "deb https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list | |
# Update and install syncthing and xmlstarlet (to later change the default config) | |
sudo apt update | |
sudo apt install syncthing xmlstarlet | |
# Enable daemon for user | |
sudo systemctl enable syncthing@${USER}.service | |
# Start then stop the daemon to create a default configuration | |
sudo systemctl start syncthing@${USER}.service | |
sudo systemctl stop syncthing@${USER}.service | |
# Update some local syncthing settings | |
SYNCTHING_CONFIG=$HOME/.config/syncthing/config.xml | |
# Only listen on tcp4 by default | |
SYNCTHING_LISTEN_ADDR=tcp4://0.0.0.0:22000 | |
# This is suitable for an internal network or docker image | |
SYNCTHING_GUI_ADDR=0.0.0.0:8384 | |
# Personal preference | |
SYNCTHING_GUI_THEME=dark | |
# This keeps communication inside the network | |
SYNCTHING_GLOBAL_ANNOUNCE=false | |
if command -v xmlstarlet; then | |
xmlstarlet edit -L \ | |
--update "//configuration/options/listenAddress" \ | |
--value $SYNCTHING_LISTEN_ADDR \ | |
--update "//configuration/gui/address" \ | |
--value $SYNCTHING_GUI_ADDR \ | |
--update "//configuration/gui/theme" \ | |
--value $SYNCTHING_GUI_THEME \ | |
--update "//configuration/options/globalAnnounceEnabled" \ | |
--value $SYNCTHING_GLOBAL_ANNOUNCE \ | |
$SYNCTHING_CONFIG | |
else | |
echo 'Required command missing: xmlstarlet' | |
fi | |
# Restart the daemon for this user | |
sudo systemctl start syncthing@${USER}.service | |
echo 'GUI - http://localhost:8384/' | |
echo "Config File - $SYNCTHING_CONFIG" | |
echo 'Logs - journalctl -u syncthing@$USER.service' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment