It has a syntax error.
Unknown stanza, which I fixed. Now init-checkconf says syntax fine and sudo service syncthing start returns that the process is running but when I try to access the gui via browser it will not find anything did I shut that off? How to tell if it is really running and how to configure it without browser being accessible. I use the static ip of the server and the port that I have specified in the config.xml in the home folder.
When you start a service via upstart the output will be logged under /var/log/upstart/service_name.log
Have a look at what is in the log.
Run ps -A | grep sync. This will list all of the running processes with sync in their title. If nothing is printed Syncthing is failing to start for some reason.
I would edit the the config.xml directly or search the forum for accessing remote Syncthing instances. I think it has been written about a few times.
That depends on your network setup but, in general, I think it’s unsafe. There are countless situations where your network might not be as private or trustworthy as you’d like. Many IPv6 implementations will expose your machine to the world by default. And what about your printer, or your friend’s obsolete Android smartphone? Do you update your router regularly in response to security disclosures? Et cetera.
The Error seems to suggest the /home/ben/.config/syncthing doesn’t exist.
Try:
# CHANGE BELOW TO MATCH YOUR REQUIREMENTS:
#----------------------------------------------------------------------#
env SYNCTHING_USER="ben"
env SYNCTHING_EXE="/usr/bin/syncthing"
#----------------------------------------------------------------------#
# set the name of the application
description "Syncthing"
# start once the filesystems are mounted and an interface other than loopback is up
start on (local-filesystems and net-device-up IFACE!=lo)
# when Upstart should stop Syncthing
stop on runlevel [!2345]
setuid ben
setgid ben
script
HOME=$(getent passwd "$SYNCTHING_USER" | cut -d: -f6)
export HOME
# the command Upstart is to execute
exec $SYNCTHING_EXE -no-browser
end script
# If Upstart detects Syncthing has failed it will restart it
respawn
Edit:
This exports the home variable. I use this when running things as a real user because a lot of user apps expect it. Unfortunately I am not an upstart guru so I don’t know how to set the user in one place. You can’t seem to use an environment variable with setuid and setgid so it has to be set in at least 3 places.
Haven’t tested this so please let me know if I made a typo.
This works perfectly, now if I would only really understand how I could have figured that out myself. I know you tried to point out the -home export but I just never really understood that part…still so much to learn.
I also changed the listening IP in the config.xml to my servers static ip : port.
I hope that addresses your security concerns with the global listening 0.0.0.0:port.
So the original approach used the syncthing flag that is made for this purpose. The error you were receiving indicates the directory didn’t exist which is something Syncthing requires when using this flag.
By default Syncthing uses the HOME variable to find the user’s home directory and creates the default configuration if it doesn’t exist. Since the user isn’t logged in the HOME variable isn’t set so my version looks up the user’s details and trims the sting to just have the location of the home directory. Then stores the variable as HOME and exports it so the Syncthing process can access it.
This will work for apps that don’t give you the option to pass a home as well.
P.S.
Sorry for the multiple posts, on the phone and I really struggle with the forum sometimes.
I see. That makes sense, so basically you Look up the information based on the user.
And no problem for the multiple posts with the phone. I am posting on the phone, too. I know how hard it is.
Can’t tell you how many times it took for some of my answers .