`syncthing` headless

syncthing headless

ubuntu 18.04 hw2018 server syncthing systemd

syncthing is a FOSS decentralized file sync software, and is even available for most proprietary operating system.

Let’s see how to install it as a systemd user service.

Setup

  1. Enable systemd service for the user running syncthing:

     sudo loginctl enable-linger pim
    
  2. Add the package (borrowed from https://apt.syncthing.net/) :

     # 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:
     sudo apt-get update
     sudo apt-get install syncthing
    
  3. Create the user service :

     # make sure the systemd user directory exists
     mkdir -p ~/.config/systemd/user
    
     # create the service file
     cat >~/.config/systemd/user/syncthing <<EOL
     [Unit]
     Description=Syncthing - Open Source Continuous File Synchronization
     Documentation=man:syncthing(1)
    
     [Service]
     ExecStart=/usr/bin/syncthing -no-browser -logflags=0
     Restart=on-failure
     SuccessExitStatus=3 4
     RestartForceExitStatus=3 4
     Nice=19
     IOSchedulingClass=idle
    
     [Install]
     WantedBy=default.target
     EOL
    
  4. Enable and start the service

     systemctl --user enable syncthing
     systemctl --user start syncthing
    

Web interface

The web interface is available at http://localhost:8384

Listening ports

syncthing will work behind a NAT, but will use public relays. For faster operation, have a look at the syncthing documentation about firewalls.

Details

For more details, here is a post about user services.

~~~

Question, remark, bug? Don't hesitate to contact me or report a bug.