From c0894008aaa69042747fc3a3538d3cb6417781df Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 27 Jan 2022 02:21:23 +0100 Subject: [PATCH 1/4] Apply last example_ynh --- conf/nginx.conf | 5 ----- doc/DESCRIPTION.md | 1 + doc/DISCLAIMER.md | 4 +--- manifest.json | 4 ++-- scripts/_common.sh | 3 ++- scripts/backup | 4 ++-- scripts/install | 38 +++++++++++++------------------- scripts/remove | 27 ++++++++++------------- scripts/restore | 4 ++-- scripts/upgrade | 55 ++++++++++++++++++++++++---------------------- 10 files changed, 65 insertions(+), 80 deletions(-) create mode 100644 doc/DESCRIPTION.md 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..8d3d7e4 100644 --- a/manifest.json +++ b/manifest.json @@ -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 #================================================= From ef069ab33d95f7ac843c2de9e2c04e063180a2da Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Thu, 27 Jan 2022 01:21:28 +0000 Subject: [PATCH 2/4] Auto-update README --- README.md | 6 +++--- README_fr.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e298aef..1dfcb48 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ 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 @@ -23,9 +24,8 @@ Home made tool to monitor automatically your servers ## 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..488c4e1 100644 --- a/README_fr.md +++ b/README_fr.md @@ -11,7 +11,8 @@ 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 @@ -19,9 +20,8 @@ Outil pour surveiller automatiquement vos serveurs ## 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 From 68fd28343830cbc4632fc0c7bfcb9fa960b028ad Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 30 Jan 2022 15:17:21 +0100 Subject: [PATCH 3/4] Increase version number --- check_process | 2 ++ manifest.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) 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/manifest.json b/manifest.json index 8d3d7e4..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", From 6822e97d5573a4ecb45cf9abb740e2ad516d3116 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sun, 30 Jan 2022 14:17:27 +0000 Subject: [PATCH 4/4] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1dfcb48..ac3bbe1 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in 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 diff --git a/README_fr.md b/README_fr.md index 488c4e1..4654307 100644 --- a/README_fr.md +++ b/README_fr.md @@ -14,7 +14,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour 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