aboutsummaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorMatteo Ruina <matteo.ruina@gmail.com>2017-10-08 17:29:51 +0000
committerJakob Borg <jakob@kastelo.net>2017-10-08 17:29:51 +0000
commit6ffb95f6c81b76ba62e8cf742e722c5deac4fe1d (patch)
tree3e043b711af6980565fb8db49d83a72b0a6b94a5 /etc
parent0b5c11bf936567dc521163430991d8eb7911c1b9 (diff)
downloadsyncthing-6ffb95f6c81b76ba62e8cf742e722c5deac4fe1d.tar.gz
syncthing-6ffb95f6c81b76ba62e8cf742e722c5deac4fe1d.zip
etc: Add FreeBSD rc.d script
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4408
Diffstat (limited to 'etc')
-rw-r--r--etc/freebsd-rc/README.md16
-rw-r--r--etc/freebsd-rc/syncthing54
2 files changed, 70 insertions, 0 deletions
diff --git a/etc/freebsd-rc/README.md b/etc/freebsd-rc/README.md
new file mode 100644
index 000000000..3c62ddacf
--- /dev/null
+++ b/etc/freebsd-rc/README.md
@@ -0,0 +1,16 @@
+This directory contains an example for running Syncthing with a `rc.d` script in FreeBSD.
+
+* Install `syncthing` in `/usr/local/bin/syncthing`.
+* Copy the `syncthing` rc.d script in `/usr/local/etc/rc.d/syncthing`.
+* To automatically start `syncthing` at boot time, add the following line to `/etc/rc.conf`:
+```
+syncthing_enable=YES
+```
+* Optional configuration options are:
+```
+syncthing_home=</path/to/syncthing/config/dir>
+syncthing_log_file=</path/to/syncthing/log/file>
+syncthing_user=<syncthing_user>
+syncthing_group=<syncthing_group>
+```
+See the rc.d script for more informations. \ No newline at end of file
diff --git a/etc/freebsd-rc/syncthing b/etc/freebsd-rc/syncthing
new file mode 100644
index 000000000..64c5d2cc6
--- /dev/null
+++ b/etc/freebsd-rc/syncthing
@@ -0,0 +1,54 @@
+#!/bin/sh
+#
+#
+# PROVIDE: syncthing
+# REQUIRE: DAEMON
+# KEYWORD: shutdown
+#
+# Add the following lines to /etc/rc.conf to enable this service:
+#
+# syncthing_enable: Set to NO by default. Set it to YES to enable it.
+# syncthing_home: Directory where syncthing configuration
+# data is stored.
+# Default: /usr/local/etc/syncthing
+# syncthing_log_file: Syncthing log file
+# Default: /var/log/syncthing.log
+# syncthing_user: The user account syncthing daemon runs as what
+# you want it to be.
+# Default: syncthing
+# syncthing_group: The group account syncthing daemon runs as what
+# you want it to be.
+# Default: syncthing
+
+. /etc/rc.subr
+
+name=syncthing
+rcvar=syncthing_enable
+
+start_cmd="${name}_start"
+
+load_rc_config $name
+
+: ${syncthing_enable:=NO}
+: ${syncthing_home=/usr/local/etc/syncthing}
+: ${syncthing_log_file=/var/log/syncthing.log}
+: ${syncthing_user:=syncthing}
+syncthing_group=${syncthing_group:-$syncthing_user}
+
+
+command=/usr/local/bin/syncthing
+pidfile=/var/run/syncthing.pid
+syncthing_flags="${syncthing_home:+-home=${syncthing_home}} ${syncthing_log_file:+-logfile=${syncthing_log_file}}"
+
+syncthing_start() {
+ echo "Starting syncthing"
+ touch ${pidfile} && chown ${syncthing_user} ${pidfile}
+ touch ${syncthing_log_file} && chown ${syncthing_user} ${syncthing_log_file}
+ /usr/sbin/daemon -cf -p ${pidfile} -u ${syncthing_user} ${command} ${syncthing_flags}
+}
+
+syncthing_cleanup() {
+ [ -f ${pidfile} ] && rm ${pidfile}
+}
+
+run_rc_command $1