syncthing.initd 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/openrc-run
  2. # Copyright 1999-2017 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. SYNCTHING_USER="${SYNCTHING_USER:-root}"
  5. SYNCTHING_GROUP="${SYNCTHING_GROUP:-root}"
  6. SYNCTHING_HOMEDIR="${SYNCTHING_HOMEDIR:-/var/lib/syncthing/.config/syncthing}"
  7. SYNCTHING_LOGDIR="${SYNCTHING_LOGDIR:-/var/log/syncthing}"
  8. SYNCTHING_LOGFILE="${SYNCTHING_LOGFILE:-${SYNCTHING_LOGDIR}/syncthing.log}"
  9. SYNCTHING_UMASK="${SYNCTHING_UMASK:-007}"
  10. SYNCTHING_IONICE="${SYNCTHING_IONICE:-0}"
  11. SYNCTHING_NICE="${SYNCTHING_NICE:-0}"
  12. description="Syncthing is an open, trustworthy and decentralized cloud storage system"
  13. pidfile="/run/syncthing.pid"
  14. supervisor=supervise-daemon
  15. command="/usr/bin/syncthing"
  16. command_args="-no-browser -home=${SYNCTHING_HOMEDIR} ${SYNCTHING_OPTS}"
  17. command_user="${SYNCTHING_USER}:${SYNCTHING_GROUP}"
  18. output_log="$SYNCTHING_LOGFILE"
  19. error_log="$output_log"
  20. supervisor_daemon_args=" --umask ${SYNCTHING_UMASK} \
  21. --ionice ${SYNCTHING_IONICE} \
  22. --nicelevel ${SYNCTHING_NICE}"
  23. depend() {
  24. need localmount net
  25. }
  26. start_pre() {
  27. if [ ! -d "$SYNCTHING_HOMEDIR" ]; then
  28. install -d "$SYNCTHING_HOMEDIR"
  29. chown "$command_user" "$SYNCTHING_HOMEDIR"
  30. fi
  31. checkpath -d -o "$command_user" "$SYNCTHING_LOGDIR"
  32. checkpath -f -o "$command_user" "$SYNCTHING_LOGFILE"
  33. }