syncthing 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/sh
  2. #
  3. #
  4. # PROVIDE: syncthing
  5. # REQUIRE: DAEMON
  6. # KEYWORD: shutdown
  7. #
  8. # Add the following lines to /etc/rc.conf to enable this service:
  9. #
  10. # syncthing_enable: Set to NO by default. Set it to YES to enable it.
  11. # syncthing_home: Directory where syncthing configuration
  12. # data is stored.
  13. # Default: /usr/local/etc/syncthing
  14. # syncthing_log_file: Syncthing log file
  15. # Default: /var/log/syncthing.log
  16. # syncthing_user: The user account syncthing daemon runs as what
  17. # you want it to be.
  18. # Default: syncthing
  19. # syncthing_group: The group account syncthing daemon runs as what
  20. # you want it to be.
  21. # Default: syncthing
  22. . /etc/rc.subr
  23. name=syncthing
  24. rcvar=syncthing_enable
  25. start_cmd="${name}_start"
  26. load_rc_config $name
  27. : ${syncthing_enable:=NO}
  28. : ${syncthing_home=/usr/local/etc/syncthing}
  29. : ${syncthing_log_file=/var/log/syncthing.log}
  30. : ${syncthing_user:=syncthing}
  31. syncthing_group=${syncthing_group:-$syncthing_user}
  32. command=/usr/local/bin/syncthing
  33. pidfile=/var/run/syncthing.pid
  34. syncthing_cmd=serve
  35. syncthing_flags="${syncthing_home:+--home=${syncthing_home}} ${syncthing_log_file:+--logfile=${syncthing_log_file}}"
  36. syncthing_start() {
  37. echo "Starting syncthing"
  38. touch ${pidfile} && chown ${syncthing_user} ${pidfile}
  39. touch ${syncthing_log_file} && chown ${syncthing_user} ${syncthing_log_file}
  40. /usr/sbin/daemon -cf -p ${pidfile} -u ${syncthing_user} ${command} ${syncthing_cmd} ${syncthing_flags}
  41. }
  42. syncthing_cleanup() {
  43. [ -f ${pidfile} ] && rm ${pidfile}
  44. }
  45. run_rc_command $1