Hi, i've install Syncthing on my SME. It works great
This is what i've done if it helps someone... I don't know how to build a RPM from this but maybe someone else if it's woth it?
InstallAdd user specific for Syncthing
[root@server ~]#useradd syncthing
Add log folder
[root@server ~]#mkdir /home/syncthing/log
Add bin folder for syncthing
[root@server ~]#mkdir /home/syncthing/bin
To download Syncthing, go to the website
https://github.com/syncthing/syncthing/releases/latest then copy/past the right link for your server arch (here, linux 64 bits)
Then, download from server:
[root@server ~]# wget https://github.com/syncthing/syncthing/releases/download/v0.9.10/syncthing-linux-amd64-v0.9.10.tar.gz
Extrat it:
[root@server ~]# tar -zxvf syncthing-linux-amd64-v0.9.10.tar.gz
Copy syncthing to the bin folder
[root@server ~]# cp syncthing-linux-amd64-v0.9.10/syncthing /home/syncthing/bin/
Change right to able syncthing user to launch it (and, later, upgrade it directly from web interface)
[root@server ~]#chown syncthing:syncthing -Rf /home/syncthing/*
Set Syncthing as a serviceSME Script
[root@server ~]#nano /etc/rc.d/init.d/syncthing
Copy/past this lines.
Note:
- bin folder: SCRIPT=/home/syncthing/bin/syncthing
- syncthing user: RUNAS=syncthing
- service name: NAME=syncthing
- log files folder: LOGFILE=/home/syncthing/log/$NAME.log
#!/bin/sh
### BEGIN INIT INFO
# Provides: Syncthing
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Syncthing to sync folders
### END INIT INFO
SCRIPT=/home/syncthing/bin/syncthing
RUNAS=syncthing
NAME=syncthing
PIDFILE=/var/run/$NAME.pid
LOGFILE=/home/syncthing/log/$NAME.log
start() {
if [ -f $PIDFILE ] && kill -0 $(cat $PIDFILE); then
echo 'Service already running' >&2
return 1
fi
echo 'Starting serviceā¦' >&2
local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!"
su -c "$CMD" $RUNAS > "$PIDFILE"
echo 'Service started' >&2
}
stop() {
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
echo 'Service not running' >&2
return 1
fi
echo 'Stopping serviceā¦' >&2
kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
echo 'Service stopped' >&2
}
uninstall() {
echo -n "Are you really sure you want to uninstall this service? That cannot be undone. [yes|No] "
local SURE
read SURE
if [ "$SURE" = "yes" ]; then
stop
rm -f "$PIDFILE"
echo "Notice: log file is not be removed: '$LOGFILE'" >&2
update-rc.d -f <NAME> remove
rm -fv "$0"
fi
}
status() {
printf "%-50s" "Checking $NAME..."
if [ -f $PIDFILE ]; then
PID=$(cat $PIDFILE)
if [ -z "$(ps axf | grep ${PID} | grep -v grep)" ]; then
printf "%s\n" "The process appears to be dead but pidfile still exists"
else
echo "Running, the PID is $PID"
fi
else
printf "%s\n" "Service not running"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
uninstall)
uninstall
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|status|restart|uninstall}"
esac
Script launchable
[root@server ~]#chmod u+x /etc/rc.d/init.d/syncthing
Add service
[root@server ~]#chkconfig syncthing --add
link for init 7 of SME
[root@server ~]#ln -f -s /etc/rc.d/init.d/e-smith-service /etc/rc7.d/S99syncthing
service Syncthing active in SME configuration
[root@server ~]#db configuration set syncthing service status enabled
Syncthing service configurationTo allow local network to access syncthing server:
[root@server ~]#db configuration setprop syncthing access private
Or for private+public acces:
[root@server ~]#db configuration setprop syncthing access public
Syncthing needs to open these ports:
[root@server ~]#db configuration setprop syncthing TCPPort 8080
[root@server ~]#db configuration setprop syncthing TCPPorts 8080,22000
[root@server ~]#db configuration setprop syncthing UDPPort 21025
Apply changes
[root@server ~]#signal-event remoteaccess-update
Then launch the service
[root@server ~]#service syncthing start
Syncthing configurationConfig files are in the folder /home/syncthing/.config/syncthing/
we gonna change config.xml
[root@server ~]#nano /home/syncthing/.config/syncthing/config.xml
Check these lignes:
<gui enabled="true" tls="false">
<address>127.0.0.1:8080</address>
Here, we can only web interface from host server and unsecured.
Change these lignes like this to allow access from computer part of the network allowed above in service configuration, and force encrypted connexions
<gui enabled="true" tls="true">
<address>0.0.0.0:8080</address>
Save and restart service
[root@server ~]#service syncthing restart
Syncthing configuration from the web interfaceWith your browser,
https://ip_server:8080Edit > Configuration, define a user with password allowed to access web interface for more secure.
You can know add folder and nodes. Folders will be added in /home/syncthing