enhancement: fix file perms and make sure the folder exists

This commit is contained in:
OniriCorpe 2023-11-20 20:01:22 +01:00
parent 21531281e1
commit fe1d18990f

View file

@ -100,9 +100,13 @@ ignoreregex =
ynh_add_config --template="f2b_jail.conf" --destination="/etc/fail2ban/jail.d/$app.conf"
ynh_add_config --template="f2b_filter.conf" --destination="/etc/fail2ban/filter.d/$app.conf"
# Create the logfile if it doesn't exist, as fail2ban require an existing file
# Create the folder and logfile if they doesn't exist,
# as fail2ban require an existing logfile before configuration
mkdir -p "/var/log/$app"
if [ ! -f "$logpath" ]; then
touch "$logpath"
chown -R "$app:$app" "$logpath"
chmod -R u=rwX,g=rX,o= "$logpath"
fi
ynh_systemd_action --service_name=fail2ban --action=reload --line_match="(Started|Reloaded) Fail2Ban Service" --log_path=systemd