extract logpath from /etc/fail2ban/jail.d/$app.conf

Co-authored-by: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com>
This commit is contained in:
OniriCorpe 2023-11-26 20:42:38 +01:00 committed by GitHub
parent 5194180277
commit 38415db273
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -104,14 +104,7 @@ ignoreregex =
# "$logpath" using the one in the package's conf/f2b_jail.conf template
if [ -z "$logpath" ]; then
# the first sed deletes possibles spaces and the second one extract the path
logpath=$(grep logpath "$YNH_APP_BASEDIR/conf/f2b_jail.conf" | sed "s/ //g" | sed "s/logpath=//g")
# replace any '__VAR__' by their real variable using ynh_replace_vars
# in some hacky way because ynh_replace_vars supports only files ^^'
tempdir="$(mktemp -d)"
echo "$logpath" > "$tempdir/process-logpath"
ynh_replace_vars --file="$tempdir/process-logpath"
logpath="$(cat "$tempdir/process-logpath")"
rm -r "$tempdir"
logpath=$(grep logpath "/etc/fail2ban/jail.d/$app.conf" | sed "s/ //g" | sed "s/logpath=//g")
fi
# Create the folder and logfile if they doesn't exist,