anubis.initd 1015 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/sbin/openrc-run
  2. # shellcheck shell=sh
  3. instance=${RC_SVCNAME#*.}
  4. description="Anubis HTTP defense proxy (instance ${instance})"
  5. supervisor="supervise-daemon"
  6. command="/usr/bin/anubis"
  7. command_args="\
  8. -bind ${ANUBIS_BIND_PORT:-/run/anubis_${instance?}/anubis.sock -bind-network unix} \
  9. -metrics-bind ${ANUBIS_METRICS_BIND_PORT:-/run/anubis_${instance?}/metrics.sock -metrics-bind-network unix} \
  10. -target ${ANUBIS_TARGET:-http://localhost:3923} \
  11. -difficulty ${ANUBIS_DIFFICULTY:-4} \
  12. ${ANUBIS_OPTS}
  13. "
  14. command_background=1
  15. pidfile="/run/anubis_${instance?}/anubis.pid"
  16. : "${command_user:=anubis:anubis}"
  17. depend() {
  18. use net firewall
  19. }
  20. start_pre() {
  21. if [ "${instance?}" = "${RC_SVCNAME?}" ]; then
  22. eerror "${RC_SVCNAME?} cannot be started directly. You must create"
  23. eerror "symbolic links to it for the services you want to start"
  24. eerror "and add those to the appropriate runlevels."
  25. return 1
  26. fi
  27. rm -rf "/run/anubis_${instance?}"
  28. checkpath -D -o "${command_user?}" "/run/anubis_${instance?}"
  29. }