Setting Up Syncthink by Command Line on a Server

Props to this site for the info I based the following on!

First, install syncthing:

$ sudo apt-get update 

$ sudo apt-get install syncthing

$ syncthing


You will need to change the address of the web gui by editing the syncthing config.xml.

$ sudo nano ~/.config/syncthing/config.xml 

<gui enabled="true" tls="false">
<address>127.0.0.0:8384</address>

[to]:

<gui enabled="true" tls="false">
<address>192.168.1.119:8384</address>

systemd is a system and service manager for Linux that runs as PID 1 (Process ID 1) and starts the rest of the system. It uses a script file called a Unit for each service, they are located in /etc/systemd/system/multi-user.target.wants/ to get this to work you need to put this file into that directory.


This is the Unit text
***********************************************************************
[Unit]
Description=Syncthing - Open Source Continuous File Synchronization for %I
Documentation=http://docs.syncthing.net/
After=network.target
Wants=syncthing-inotify@.service
[Service]
User=%i
ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0
Restart=on-failure
SuccessExitStatus=3 4
RestartForceExitStatus=3 4
[Install]
WantedBy=multi-user.target
***********************************************************************
Copy this file into the etc/systemd/system/multi-user.target.wants directory and name it with the service username you login as:

$ sudo systemctl enable syncthing@username.service
$ sudo systemctl start syncthing@username.service


That's it, reboot your server to check syncthing starts and then you can start setting up the folders you want to sync from the webgui.
 

Comments

Popular posts from this blog

Base64 decode to file

Swiftboating from the Left - Paul Harris's "The Real McCain"