1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/homeassistant_ynh.git synced 2024-09-03 19:26:16 +02:00

Merge pull request #185 from maniackcrudelis/fail2ban

Add fail2ban support
This commit is contained in:
ewilly 2023-02-03 08:34:11 +01:00 committed by GitHub
commit 9a9e4a6fa7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 1 deletions

View file

@ -6,7 +6,7 @@
"en": "Home automation platform", "en": "Home automation platform",
"fr": "Plateforme domotique" "fr": "Plateforme domotique"
}, },
"version": "2023.1.7~ynh1", "version": "2023.1.7~ynh2",
"url": "https://github.com/home-assistant/home-assistant", "url": "https://github.com/home-assistant/home-assistant",
"upstream": { "upstream": {
"license": "Apache-2.0", "license": "Apache-2.0",

View file

@ -58,6 +58,13 @@ ynh_backup --src_path="$data_path" --is_big
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP FAIL2BAN CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP
#================================================= #=================================================

View file

@ -183,6 +183,14 @@ ynh_store_file_checksum --file="/etc/systemd/system/$app.service"
systemctl daemon-reload systemctl daemon-reload
ynh_systemd_action --service_name=$app --action=restart ynh_systemd_action --service_name=$app --action=restart
#=================================================
# SETUP FAIL2BAN
#=================================================
ynh_script_progression --message="Configuring Fail2Ban..." --weight=1
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="$log_file" --failregex="Login attempt or request with invalid authentication from <HOST>"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================

View file

@ -91,6 +91,14 @@ ynh_script_progression --message="Removing dependencies..."
ynh_remove_app_dependencies ynh_remove_app_dependencies
#=================================================
# REMOVE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=1
# Remove the dedicated Fail2Ban config
ynh_remove_fail2ban_config
#================================================= #=================================================
# SPECIFIC REMOVE # SPECIFIC REMOVE
#================================================= #=================================================

View file

@ -79,6 +79,15 @@ ynh_restore_file --origin_path="$data_path" --not_mandatory
mkdir -p $data_path mkdir -p $data_path
#=================================================
# RESTORE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=1
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
ynh_systemd_action --action=restart --service_name=fail2ban
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#================================================= #=================================================

View file

@ -112,6 +112,14 @@ ynh_script_progression --message="Upgrading systemd configuration..."
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
#=================================================
# SETUP FAIL2BAN
#=================================================
ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=1
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="$log_file" --failregex="Login attempt or request with invalid authentication from <HOST>"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================