How to autostart Syncthing (ARM) on OpenWRT?

Hello Syncthers.

First of all, sorry If I should post this on the OpenWRT forum instead of the Syncthing one, as I cannot address the origin of the issue.

I have downloaded latest (0.14.49) Syncthing ARM from official site, installed to my LEDE 17.01.05 Linksys WRT1900ACS router, launched from SSH console, configured it via config.xml to be accesible from any IP address (0.0.0.0:8384) and everything works great.

Now, I would like to make it to autostart everytime the router gets rebooted, so I found an autostart script from a repository at “https://github.com/brglng/syncthing-openwrt”, placed on “/etc/init.d/” and launched the command “/etc/init.d/syncthing enable”.

The problem is that now whenever I reboot, the GUI cannot be accessed at port 8384 (it gives a 404 error) like when I manually launch it. And when I try to launch it manually, it stops because it detects that the service is already in use (?):

09:10:25 FATAL: Starting API/GUI: listen tcp 0.0.0.0:8384: bind: address already in use 09:10:25 INFO: Syncthing exited: exit status 1

I have to manually delete the autostart script and disable it so I can manualy launch Syncthing again from SSH console.

I guess the autostart script is outdated (+3 years ago) and there is some conflict but my UNIX knowledge is very poor as you can see. The code seems pretty simple, though:

START=99 STOP=99

start() { service_start /usr/bin/syncthing 2>&1 | logger -t syncthing & }

stop() { service_stop /usr/bin/syncthing }

Is any other way to make it to autostart whenever the router is on?

Thanks in advance.

Here is a script that will autostart Syncthing (download ARM binary manually and put in non-RAM location):

sudo -u USER nohup /LOCATION/syncthing > /dev/null 2>&1&

“sudo” and “-u USER” can probably be removed as “root” is likely the only SSH user in LEDE, like in Tomato.

In Tomato there is a cron area and a “run at startup” section in the GUI to enter any given commands or scripts. Look for something similar in LEDE to put above script in. If LEDE has a home folder that isn’t in RAM one can also put the script in a file called “/home/USER/.profile” or “/root/.profile” (for root user) and it will run at every SSH login (which is basically almost equivalent to auto-starting).

If still need help auto-starting script on LEDE post here: https://forum.lede-project.org/

They are very helpful.

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