diff --git a/README.md b/README.md index e298aef..ac3bbe1 100644 --- a/README.md +++ b/README.md @@ -15,17 +15,17 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -Home made tool to monitor automatically your servers +YunoMonitor is a simple tools to auto-configure monitoring on a remote YunoHost server. So you need one server to monitor and another to run monitoring task. -**Shipped version:** 1.1.0~ynh2 + +**Shipped version:** 1.1.0~ynh3 ## Disclaimers / important information -YunoMonitor is a simple tools to auto-configure monitoring on a remote YunoHost server. So you need one server to monitor and another to run monitoring task. - YunoMonitor can send you email or SMS if you give him an URL API to do it (like the API from the operator "free mobile"). + ## Documentation and resources * Official app website: https://github.com/zamentur/yunomonitor diff --git a/README_fr.md b/README_fr.md index 4f3e22f..4654307 100644 --- a/README_fr.md +++ b/README_fr.md @@ -11,17 +11,17 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour ## Vue d'ensemble -Outil pour surveiller automatiquement vos serveurs +YunoMonitor is a simple tools to auto-configure monitoring on a remote YunoHost server. So you need one server to monitor and another to run monitoring task. -**Version incluse :** 1.1.0~ynh2 + +**Version incluse :** 1.1.0~ynh3 ## Avertissements / informations importantes -YunoMonitor is a simple tools to auto-configure monitoring on a remote YunoHost server. So you need one server to monitor and another to run monitoring task. - YunoMonitor can send you email or SMS if you give him an URL API to do it (like the API from the operator "free mobile"). + ## Documentations et ressources * Site officiel de l'app : https://github.com/zamentur/yunomonitor diff --git a/check_process b/check_process index 6c69fb0..b863f8c 100644 --- a/check_process +++ b/check_process @@ -12,6 +12,8 @@ setup_private=0 setup_public=0 upgrade=1 + # 1.1.0~ynh2 + upgrade=1 from_commit=4feb4a78181518956e7d230a2ab67d96992f8563 backup_restore=1 multi_instance=0 port_already_use=0 diff --git a/conf/nginx.conf b/conf/nginx.conf index 74e710e..9a76413 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,9 +2,4 @@ location ^~ '/.well-known/yunomonitor/' { default_type "text/plain"; alias __FINALPATH__/well-known/; - - # Force usage of https - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } } diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..5fd372a --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +YunoMonitor is a simple tools to auto-configure monitoring on a remote YunoHost server. So you need one server to monitor and another to run monitoring task. diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index 9e69a4e..74a2c0a 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -1,3 +1 @@ -YunoMonitor is a simple tools to auto-configure monitoring on a remote YunoHost server. So you need one server to monitor and another to run monitoring task. - -YunoMonitor can send you email or SMS if you give him an URL API to do it (like the API from the operator "free mobile"). \ No newline at end of file +YunoMonitor can send you email or SMS if you give him an URL API to do it (like the API from the operator "free mobile"). diff --git a/manifest.json b/manifest.json index 4b868da..3b35325 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Home made tool to monitor automatically your servers", "fr": "Outil pour surveiller automatiquement vos serveurs" }, - "version": "1.1.0~ynh2", + "version": "1.1.0~ynh3", "url": "https://github.com/zamentur/yunomonitor", "upstream": { "license": "AGPL-3.0", @@ -21,14 +21,14 @@ "url": "https://reflexlibre.net" }, "requirements": { - "yunohost": ">= 4.2.0" + "yunohost": ">= 4.3.0" }, "multi_instance": false, "services": [ "nginx" ], "arguments": { - "install" : [ + "install": [ { "name": "monitored_servers", "type": "string", diff --git a/scripts/_common.sh b/scripts/_common.sh index a9096e1..02726b8 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="python3-dbus python3-crypto python3-paramiko python3-yaml python3-dnspython python3-requests-toolbelt python3-spf whois smartmontools" +pkg_dependencies="python3-dbus python3-cryptography python3-paramiko python3-yaml python3-dnspython python3-requests-toolbelt python3-spf whois smartmontools" #================================================= # PERSONAL HELPERS @@ -14,6 +14,7 @@ pkg_dependencies="python3-dbus python3-crypto python3-paramiko python3-yaml pyth #================================================= # EXPERIMENTAL HELPERS #================================================= + ynh_export () { local ynh_arg="" for var in $@; diff --git a/scripts/backup b/scripts/backup index 5c0d111..5a1cfbb 100755 --- a/scripts/backup +++ b/scripts/backup @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -53,7 +53,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/000-$app.conf" ynh_backup --src_path="/etc/systemd/system/$app.service" #================================================= -# BACKUP A CRON FILE +# BACKUP VARIOUS FILES #================================================= ynh_backup --src_path="/etc/systemd/system/$app.timer" diff --git a/scripts/install b/scripts/install index 5d2b326..c7eb68f 100755 --- a/scripts/install +++ b/scripts/install @@ -14,7 +14,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script @@ -45,14 +44,6 @@ ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_save_args domain path_url monitored_servers monitoring_servers mails sms_api -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -62,6 +53,14 @@ ynh_script_progression --message="Installing dependencies..." --weight=1 ynh_install_app_dependencies $pkg_dependencies +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=1 + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -92,8 +91,9 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= # SPECIFIC SETUP #================================================= -# CONFIGURE SYSTEMD TIMER +# SETUP SYSTEMD #================================================= +ynh_script_progression --message="Configuring a systemd service..." ynh_add_systemd_config cp ../conf/systemd.timer "/etc/systemd/system/$app.timer" @@ -103,10 +103,9 @@ systemctl enable $app.timer --quiet systemctl start $app.timer #================================================= - -#================================================= -# MODIFY A CONFIG FILE +# ADD A CONFIGURATION #================================================= +ynh_script_progression --message="Adding a configuration file..." echo "mails: [$mails]" > $final_path/conf/$app.yml echo "sms_apis: [$sms_api]" >> $final_path/conf/$app.yml @@ -118,30 +117,23 @@ sed -i 's/\[/["/g' $final_path/conf/$app.yml sed -i 's/\]/"]/g' $final_path/conf/$app.yml sed -i 's/\[""\]/[]/g' $final_path/conf/$app.yml -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= - # Calculate and store the config file checksum into the app settings ynh_store_file_checksum --file="$final_path/conf/$app.yml" #================================================= # INIT IGNORE FILE #================================================= + echo "method level server message target" > $final_path/conf/ignore_alert.csv -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - # Set permissions to app files chmod u+x $final_path/yunomonitor.py chmod u+w $final_path/conf chmod u+w $final_path/well-known +#================================================= +# GENERIC FINALIZATION #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/remove b/scripts/remove index 717981c..cbe3ac0 100755 --- a/scripts/remove +++ b/scripts/remove @@ -21,29 +21,16 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # STANDARD REMOVE -#================================================= -# REMOVE THE CRON FILE -#================================================= - -# Remove a cron file -ynh_secure_remove --file="/etc/systemd/system/$app.timer" - #================================================= # STOP AND REMOVE SERVICE #================================================= ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 +ynh_secure_remove --file="/etc/systemd/system/$app.timer" + # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - #================================================= # REMOVE APP MAIN DIR #================================================= @@ -57,9 +44,17 @@ ynh_secure_remove --file="$final_path" #================================================= ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 -# Remove the dedicated nginx config +# Remove the dedicated NGINX config ynh_remove_nginx_config +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=1 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 25eb4f6..06f69d5 100755 --- a/scripts/restore +++ b/scripts/restore @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -20,7 +20,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME diff --git a/scripts/upgrade b/scripts/upgrade index ecdae6a..2b9d5e6 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,9 +22,26 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# STANDARD UPGRADE STEPS #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -34,20 +51,6 @@ if ! [ -f $final_path/conf/ignore_alert.csv ]; then echo "method level server message target" > $final_path/conf/ignore_alert.csv fi -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 - -## Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -## Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # CREATE DEDICATED USER #================================================= @@ -56,8 +59,6 @@ ynh_script_progression --message="Making sure dedicated system user exists..." - # Create a dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir="$final_path" -#================================================= -# STANDARD UPGRADE STEPS #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -99,13 +100,7 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=1 ynh_install_app_dependencies $pkg_dependencies #================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 - -# Create a dedicated systemd config -ynh_add_systemd_config - +# SPECIFIC UPGRADE #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= @@ -117,11 +112,12 @@ ynh_backup_if_checksum_is_different --file="$final_path/conf/$app.yml" ynh_store_file_checksum --file="$final_path/conf/$app.yml" #================================================= -# RELOAD NGINX +# SETUP SYSTEMD #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +# Create a dedicated systemd config +ynh_add_systemd_config #================================================= # START SYSTEMD SERVICE @@ -130,6 +126,13 @@ ynh_script_progression --message="Reloading a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="reload" --log_path="/var/log/$app/$app.log" +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + #================================================= # END OF SCRIPT #=================================================