__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"
if [ -f "$__object/parameter/enable-services" ]; then
enable_services="$(cat "$__object/parameter/enable-services")"
if [ -f "$__object/parameter/enable-jails" ]; then
enable_jails="$(cat "$__object/parameter/enable-jails")"
else
enable_services="$__object_id"
enable_jails="$__object_id"
fi
services="$(echo $enable_services | sed -e 's/,/ /g')"
for service in $services
jails="$(echo $enable_jails | sed -e 's/,/ /g')"
for jail in $jails
do
echo "[$(tput setaf 6)info$(tput sgr 0)] Enabling fail2ban for $service..." >&2
echo "Enabling fail2ban for $jail..." >&2
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
done
echo "service fail2ban restart"

View file

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

View file

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