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.

28 lines
799 B

  1. #!/bin/sh
  2. # log service to trace suspicious logins and conditionally refresh banIP
  3. # Copyright (c) 2019-2021 Dirk Brenken (dev@brenken.org)
  4. # This is free software, licensed under the GNU General Public License v3.
  5. # (s)hellcheck exceptions
  6. # shellcheck disable=3040
  7. export LC_ALL=C
  8. export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
  9. set -o pipefail
  10. ban_search="${1}"
  11. ban_logger_cmd="$(command -v logger)"
  12. ban_logread_cmd="$(command -v logread)"
  13. if [ -x "${ban_logread_cmd}" ]; then
  14. "${ban_logger_cmd}" -p "info" -t "banIP-service [${$}]" "log/banIP service started" 2>/dev/null
  15. "${ban_logread_cmd}" -f |
  16. {
  17. grep -qE "${ban_search}" && {
  18. /etc/init.d/banip refresh
  19. exit 0
  20. }
  21. }
  22. else
  23. "${ban_logger_cmd}" -p "err" -t "banIP-service [${$}]" "can't start log/banIP service" 2>/dev/null
  24. fi