From fe1d18990fc459d28cf7fb82d20f0364205899e2 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Mon, 20 Nov 2023 20:01:22 +0100 Subject: [PATCH] enhancement: fix file perms and make sure the folder exists --- helpers/fail2ban | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/helpers/fail2ban b/helpers/fail2ban index 9de6ae910..bcc466497 100644 --- a/helpers/fail2ban +++ b/helpers/fail2ban @@ -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