__fail2ban update for error msg and parameter

This commit is contained in:
Simon Walter 2024-05-29 15:25:45 +02:00
parent 5e09834811
commit c832ed1ef3
3 changed files with 11 additions and 11 deletions

View file

@ -20,17 +20,17 @@
config_file="/etc/fail2ban/jail.conf" config_file="/etc/fail2ban/jail.conf"
if [ -f "$__object/parameter/enable-services" ]; then if [ -f "$__object/parameter/enable-jails" ]; then
enable_services="$(cat "$__object/parameter/enable-services")" enable_jails="$(cat "$__object/parameter/enable-jails")"
else else
enable_services="$__object_id" enable_jails="$__object_id"
fi fi
services="$(echo $enable_services | sed -e 's/,/ /g')" jails="$(echo $enable_jails | sed -e 's/,/ /g')"
for service in $services for jail in $jails
do do
echo "[$(tput setaf 6)info$(tput sgr 0)] Enabling fail2ban for $service..." >&2 echo "Enabling fail2ban for $jail..." >&2
cat << EOF cat << EOF
perl -i -pe 'BEGIN{undef $/;} s/\[$service\].*[\n]*enabled.*=.*\n/\[$service\]\n\nenabled = true\n/g' $config_file perl -i -pe 'BEGIN{undef $/;} s/\[$jail\].*[\n]*enabled.*=.*\n/\[$jail\]\n\nenabled = true\n/g' $config_file
EOF EOF
done done
echo "service fail2ban restart" echo "service fail2ban restart"

View file

@ -31,9 +31,9 @@ case "$os" in
require=__package/epel-release __package fail2ban --state present require=__package/epel-release __package fail2ban --state present
;; ;;
*) *)
echo "Your operating system ($os) is currently untested for ${__type##*/}." >&2 echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2
echo "If it works, please add it." >&2 echo "Please contribute an implementation for it if you can." >&2
__package fail2ban --state present exit 1
;; ;;
esac esac

View file

@ -1 +1 @@
enable-services enable-jails