You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.4 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2020 Martin Pecka, 3-clause BSD license (see LICENSE file)
  3. START=95
  4. USE_PROCD=1
  5. RUNDIR=/var/run/fail2ban
  6. CONFDIR=/etc/fail2ban
  7. RUNCONFDIR=/var/etc/fail2ban
  8. RUNCONF="${RUNCONFDIR}/fail2ban.conf"
  9. service_triggers() {
  10. procd_add_reload_trigger fail2ban
  11. }
  12. init_config() {
  13. mkdir -m 0755 -p "${RUNCONFDIR}"
  14. rm -f "${RUNCONF}"
  15. config_load fail2ban
  16. config_get dbfile fail2ban dbfile /var/lib/fail2ban/fail2ban.sqlite3
  17. echo "[Definition]" > "${RUNCONF}"
  18. echo -n "dbfile = " >> "${RUNCONF}"
  19. echo $dbfile >> "${RUNCONF}"
  20. }
  21. start_service() {
  22. init_config
  23. mkdir -m 0755 -p "${RUNDIR}"
  24. procd_open_instance
  25. procd_set_param file ${CONFDIR}/action.d/*.conf
  26. procd_set_param file ${CONFDIR}/action.d/*.local
  27. procd_set_param file ${CONFDIR}/filter.d/*.conf
  28. procd_set_param file ${CONFDIR}/filter.d/*.local
  29. procd_set_param file ${CONFDIR}/jail.d/*.conf
  30. procd_set_param file ${CONFDIR}/jail.d/*.local
  31. procd_set_param file ${CONFDIR}/fail2ban.d/*.conf
  32. procd_set_param file ${CONFDIR}/fail2ban.d/*.local
  33. procd_set_param file ${CONFDIR}/*.conf
  34. procd_set_param file ${CONFDIR}/*.local
  35. procd_set_param command /usr/bin/fail2ban-server -xf -p "${RUNDIR}/fail2ban.pid" -s "${RUNDIR}/fail2ban.sock" start
  36. procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
  37. procd_close_instance
  38. }
  39. reload_service()
  40. {
  41. stop
  42. start
  43. }