Automatically starting Syncthing in Debian stretch

Hi all,

I’m at my wits end, which may not be far compared to many of you.

I don’t succeed in getting Syncthing to start automatically on my Banana Pi.

I’ve read through this: https://docs.syncthing.net/users/autostart.html#linux over and over again, but I don’t understand it. Mainly because “systemctl” isn’t on my system and as far as I understood so far, it has been replaced by system.d - both of which I don’t really understand either.

The stable branch of Syncthing is installed with this method: https://apt.syncthing.net I haven’t done any customising (other than https GUI and a password) on the local install.

Can someone please help me?

systemctl is the command line utility of systemd, so if your system is stretch and isn’t heavily modified, it should have systemctl.

Thank you for helping!

systemctl always gives the error “not installed” (don’t know the exact wording atm)

So the first question that comes up, that I can’t solve is:

The following is from the Syncthing documentation:

Copy the Syncthing/etc/linux-systemd/system/syncthing@.service file into the load path of the system instance

I would like to run Syncthing as a system service, because I want it to run whether a user is logged in or not.

So, to which folder exactly do I copy syncthing@.service?

You don’t need to copy anything as you installed from apt.syncthing.net. You need to find out how your system/distribution handles startup scripts/what’s up with your systemd/ctl

It turns out that systemctl was not installed. Strange. Shouldn’t that be part of a standard install (which I did over 2 years ago on this machine…).

Anyway, so that’s installed and the commands under 3) of the Syncthing documentation sort of work.

When I now do

ps aux | grep syncthing

I see that there is a running syncthing process. However, it is not running under the user that I told it to run under. Which means I can’t connect to it through the GUI (or any other machines).

I can’t say because I don’t know what you have installed. If it is “pure” debian stretch, then yes, it should be installed by default.

What commands did you use to enable/start the service? Information about the running instance can be obtained with the commands systemctl status syncthing@... and journalctl -u syncthing@... for logs (replacing … with the appropriate user).

I used these commands as per the documentation: (I ran everything with sudo)

systemctl enable syncthing@myuser.service

systemctl start syncthing@myuser.service

And to check the status:

systemctl status syncthing@myuser

results in:

Failed to get properties: Launch helper exited with unknown return code 1

I assume you replaced “myuser” with the actual username. Did the first two commands succeed? The error from the third is pretty weird, it doesn’t sound like systemd. What system are you running? In general it sounds like your questions would be better suited (i.e. you’d get better help) for a support forum dedicated to your system/platform.

I appreciate your help. Yes, I ran the commands with the username of the account where syncthing should be running.

This is the system version: Linux version 3.4.113-bananian

It was installed about 2 years ago from the standard Bananian image (jessie at the time) and about 4 months ago I upgraded it to stretch.

I’ll try in the Raspberry Pi forum as well… I’m sure people will refer me back here pretty soon. :slight_smile:

The added challenge is of course, that the machine is headless, which means I also have to use ssh -L 9090:127.0.0.1:8384 myuser@mymachine to access the GUI. Which had worked all day and still does when I started Syncthing by simply typing syncthing in the terminal.

Now I see Syncthing is running under my username (not root) but I can’t access the GUI.

I probably thoroughly messed up somewhere…

When referring you to Bananian I was thinking about the systemd issues - because those are not only not Syncthing related, they are about a specific system of which I and probably most others in this forum know not much/nothing about.

Look at the logs (journalctl -u syncthing@...) and look for a line containing INFO: GUI and API listening on for information about where to access the web UI or any obvious errors.

@hanshafner hope figured it out but if not you are welcome to try a simpler approach. Forget about systemmd, systemctl or running as an actual service.

Add below to .profile file in your home folder (location/ username change necessary relative to your setup):

sudo -u USER nohup /home/USER/syncthing/syncthing -home=/home/OTHER-USER/syncthing > /dev/null 2>&1&

If running Syncthing as yourself don’t need “sudo -u USER” and “-home=/home/OTHER-USER/syncthing.” Probably less secure and a little more simple to run as yourself.

The end result is Syncthing will automatically start as soon as login via SSH. This may not be an issue because most probably login once via SSH to make sure a headless machine restarted okay anyways.

Thank you!

Yes, that makes total sense, what a simple solution. There is hardly ever a restart of the little machine that I don’t trigger myself and follow up with logging in. Tried it now and this solution works!

Thank you for your helpe and have a nice weekend @imsodin and @schnappi !!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.