openwrt-packages/net/banip/files/banip.service

29 lines
799 B
Desktop File
Executable File

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