Ubuntu 14.04 LTS server syncthing problem installation and autostart

Ok, sudo Service syncthing Start returns unknown service.

The [quote=“kluppy, post:9, topic:7867”] Check the upstart config with init-checkconf [/quote]

Asks for a config name and when I say syncthing it says no such config exists.

Do not know what exactly you referring to with the home flag part

Tell the command the path to the config file e.g. init-checkconf /path/to/file

Path to the file in /etc/init ?

Yes, I think the file is named wrong if the service cannot be found. it is based on the name of the config file.

syncthing.conf would be triggered with sudo service syncthing start

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.

It says Fatal error no home directory found set $home$[quote=“kluppy, post:16, topic:7867”] Dear users of Syncthing,

By default, the web GUI only listens for connections from localhost (127.0.0.1 or ::1 for ipv6).

If you decide to change this to make it listen to the whole world (for example, 0.0.0.0), then make sure you set up a username, password and HTTPS.

Otherwise, anybody can connect to your server [/quote]

But only from within mynetwork, right? It is still behind the router with no ports forwarded or what would you suggest that I use?

Thank you!

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.

I understand so what to change it to? To the servers static ip?

So Syncthing is failing to start because it can’t find where the configuration is supposed to be kept.

What is your exec line? does it still have -home=? Does the directory this option points to exist?

If you have checked all of this and still can’t get it I will upload a version that should work.

This is my execution line:

exec $SYNCTHING_EXE -no-browser -home="$SYNCTHING_CONF"

With

env SYNCTHING_CONF="/home/ben/.config/syncthing"

Being set before.

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.

Thank you a lot!

Last question what settings should I apply for good security and only local network syncing?

The default settings have good security.

I’m not sure about restricting to the local network — I’ll leave that question for someone else to answer.

Disable global discovery. If you have assigned the server a static address use that address on the other devices instead of “dynamic”.

Disable Relays, they aren’t required if you only want to sync on the LAN.

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.

Ok, done that.

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 :slight_smile:.

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