diff --git a/conf/post_iptable_rules_hook b/conf/post_iptable_rules_hook new file mode 100644 index 0000000..fc489a4 --- /dev/null +++ b/conf/post_iptable_rules_hook @@ -0,0 +1,6 @@ +#/bin/bash + +if [[ $(systemctl status monitorix.service | grep "Active" | cut -d'(' -f2 | cut -d ')' -f1) = 'running' ]] +then + systemctl restart monitorix.service +fi \ No newline at end of file diff --git a/scripts/_common.sh b/scripts/_common.sh index ee1543f..1b2f847 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -52,7 +52,6 @@ config_monitorix() { ynh_replace_string __MYSQL_USER__ $dbuser $monitorix_conf ynh_replace_string MYSQL_PASSWORD $dbpass $monitorix_conf cp $monitorix_conf /etc/monitorix/monitorix.conf - } set_permission() { diff --git a/scripts/backup b/scripts/backup index b808d9f..48d569f 100755 --- a/scripts/backup +++ b/scripts/backup @@ -26,6 +26,9 @@ domain=$(ynh_app_setting_get "$app" domain) ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" ynh_backup "/etc/nginx/conf.d/monitorix_status.conf" "monitorix_status.conf" +# Copy hook +ynh_backup "/usr/share/yunohost/hooks/post_iptable_rules/50-$app" + # Copy Monitorix configuration ynh_backup "/etc/monitorix" "config" diff --git a/scripts/install b/scripts/install index a070f8a..e84fecf 100755 --- a/scripts/install +++ b/scripts/install @@ -51,6 +51,14 @@ config_nginx # Update monitorix configuration config_monitorix +# Add hook +mkdir -p /usr/share/yunohost/hooks/post_iptable_rules +cp ../conf/post_iptable_rules_hook /usr/share/yunohost/hooks/post_iptable_rules/50-$app + +#================================================= +# GENERIC FINALIZATION +#================================================= + # Set access set_permission diff --git a/scripts/remove b/scripts/remove index 3fe8b6e..f76ee9d 100755 --- a/scripts/remove +++ b/scripts/remove @@ -33,6 +33,7 @@ ynh_mysql_drop_user "$dbuser" || true # Remove data ynh_secure_remove /var/lib/monitorix +ynh_secure_remove /usr/share/yunohost/hooks/post_iptable_rules/50-$app # Autoremove package ynh_remove_app_dependencies diff --git a/scripts/upgrade b/scripts/upgrade index b138ff1..be7addb 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -48,6 +48,10 @@ config_nginx # Update monitorix configuration config_monitorix +# Add hook +mkdir -p /usr/share/yunohost/hooks/post_iptable_rules +cp ../conf/post_iptable_rules_hook /usr/share/yunohost/hooks/post_iptable_rules/50-$app + #================================================= # GENERIC FINALIZATION #=================================================