How to run and use autostart on the Centos 6

Notice: The thing is that systemd is missing from Centos 6. Mini howto (using the console via SSH) For example, the user from whose name will start synching will be “username” (to change at any). Create user by command :

adduser -s /bin/bash -r username

  • -r Create a system account with a UID less than 500 and without a home directory Next, enter the commands (the following is run from the username user):
su username
cd /home/username
wget https://github.com/syncthing/syncthing/releases/download/v0.14.44/syncthing-linux-386-v0.14.44.tar.gz
tar xvzf synct*
cd synct*
./syncthing

Waiting to generate keys and start the service, after you press Ctrl+C. Then (for convenience, rename):

cd /home/username
mv syncthing-linux-386-v0.14.44 syncthing
nano /home/username/.config/syncthing/config.xml

Looking for the string: <address>127.0.0.1:8384< / address> Change to:
<address>0.0.0.0:8384< / address> Save Ctrl+X This will allow you to manage remotely via the web interface. So far we have done everything from “username” user. Other actions are performed as root. enter the commands:

exit

Now we’re back under the root user. Create a script to run Syncthing:

touch /home/username/run_syncthing.sh
nano /home/username/run_syncthing.sh

Insert there this code:

#!/bin/sh
cd /home/username/syncthing/
./syncthing & > /dev/null

Save Ctrl+X Make it executable

cmod +X /home/username/run_syncthing.sh

Edit file /etc/rc.d/rc.local

nano /etc/rc.d/rc.local

At the end of the file insert the following line:

su username /home/username/run_syncthing.sh

Add rules to the firewall:

iptables -I INPUT -p tcp --dport 8384 -m state --state NEW -j ACCEPT
iptables -I INPUT -p tcp --dport 22000 -m state --state NEW -j ACCEPT
service iptables save
service iptables restart

Reboot the system. It should work. When you first log in through the web interface, you must specify a login and password. I will be glad if someone will help. P.S. I apologize for my English, but I hope it is clear.

Am not sure that compeltely understood you. However here is much simpler way to autostart Syncthing on any Linux distribution.

Add below to /home/user/.profile if logging in via a GUI

/syncthing-location/syncthing -no-browser

If logging in via a console/ SSH add this:

nohup /syncthing-location/syncthing > /dev/null 2>&1&

If logging in via console/ SSH and want to start Syncthing as another user add this:

sudo -u user nohup /syncthing-location/syncthing -home=/syncthing-data-folder-location > /dev/null 2>&1&

All is well, but on CentOS 6 (without the GUI, only the console) it does not work. And if I do not logging the system? How ?

I tried various options. The only one that worked I described. I specify this only for Centos 6 without GUI.

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