1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/yunomonitor_ynh.git synced 2024-09-03 17:46:11 +02:00

Merge pull request #8 from YunoHost-Apps/testing

Fix Bullseye
This commit is contained in:
yalh76 2022-02-06 15:08:10 +01:00 committed by GitHub
commit c633d60c75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 76 additions and 89 deletions

View file

@ -15,17 +15,17 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
## Overview ## 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 ## 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"). 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 ## Documentation and resources
* Official app website: https://github.com/zamentur/yunomonitor * Official app website: https://github.com/zamentur/yunomonitor

View file

@ -11,17 +11,17 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
## Vue d'ensemble ## 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 ## 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"). 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 ## Documentations et ressources
* Site officiel de l'app : https://github.com/zamentur/yunomonitor * Site officiel de l'app : https://github.com/zamentur/yunomonitor

View file

@ -12,6 +12,8 @@
setup_private=0 setup_private=0
setup_public=0 setup_public=0
upgrade=1 upgrade=1
# 1.1.0~ynh2
upgrade=1 from_commit=4feb4a78181518956e7d230a2ab67d96992f8563
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
port_already_use=0 port_already_use=0

View file

@ -2,9 +2,4 @@ location ^~ '/.well-known/yunomonitor/' {
default_type "text/plain"; default_type "text/plain";
alias __FINALPATH__/well-known/; alias __FINALPATH__/well-known/;
# Force usage of https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
} }

1
doc/DESCRIPTION.md Normal file
View file

@ -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.

View file

@ -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"). 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").

View file

@ -6,7 +6,7 @@
"en": "Home made tool to monitor automatically your servers", "en": "Home made tool to monitor automatically your servers",
"fr": "Outil pour surveiller automatiquement vos serveurs" "fr": "Outil pour surveiller automatiquement vos serveurs"
}, },
"version": "1.1.0~ynh2", "version": "1.1.0~ynh3",
"url": "https://github.com/zamentur/yunomonitor", "url": "https://github.com/zamentur/yunomonitor",
"upstream": { "upstream": {
"license": "AGPL-3.0", "license": "AGPL-3.0",
@ -21,14 +21,14 @@
"url": "https://reflexlibre.net" "url": "https://reflexlibre.net"
}, },
"requirements": { "requirements": {
"yunohost": ">= 4.2.0" "yunohost": ">= 4.3.0"
}, },
"multi_instance": false, "multi_instance": false,
"services": [ "services": [
"nginx" "nginx"
], ],
"arguments": { "arguments": {
"install" : [ "install": [
{ {
"name": "monitored_servers", "name": "monitored_servers",
"type": "string", "type": "string",

View file

@ -5,7 +5,7 @@
#================================================= #=================================================
# dependencies used by the app # 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 # PERSONAL HELPERS
@ -14,6 +14,7 @@ pkg_dependencies="python3-dbus python3-crypto python3-paramiko python3-yaml pyth
#================================================= #=================================================
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================
ynh_export () { ynh_export () {
local ynh_arg="" local ynh_arg=""
for var in $@; for var in $@;

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS # 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 ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers 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" 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" ynh_backup --src_path="/etc/systemd/system/$app.timer"

View file

@ -14,7 +14,6 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true true
} }
# Exit if an error occurs during the execution of the script # 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 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 # STANDARD MODIFICATIONS
#================================================= #=================================================
@ -62,6 +53,14 @@ ynh_script_progression --message="Installing dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies 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 # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
@ -92,8 +91,9 @@ ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
#================================================= #=================================================
# CONFIGURE SYSTEMD TIMER # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..."
ynh_add_systemd_config ynh_add_systemd_config
cp ../conf/systemd.timer "/etc/systemd/system/$app.timer" cp ../conf/systemd.timer "/etc/systemd/system/$app.timer"
@ -103,10 +103,9 @@ systemctl enable $app.timer --quiet
systemctl start $app.timer systemctl start $app.timer
#================================================= #=================================================
# ADD A CONFIGURATION
#=================================================
# MODIFY A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..."
echo "mails: [$mails]" > $final_path/conf/$app.yml echo "mails: [$mails]" > $final_path/conf/$app.yml
echo "sms_apis: [$sms_api]" >> $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
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 # Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$final_path/conf/$app.yml" ynh_store_file_checksum --file="$final_path/conf/$app.yml"
#================================================= #=================================================
# INIT IGNORE FILE # INIT IGNORE FILE
#================================================= #=================================================
echo "method level server message target" > $final_path/conf/ignore_alert.csv echo "method level server message target" > $final_path/conf/ignore_alert.csv
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files # Set permissions to app files
chmod u+x $final_path/yunomonitor.py chmod u+x $final_path/yunomonitor.py
chmod u+w $final_path/conf chmod u+w $final_path/conf
chmod u+w $final_path/well-known chmod u+w $final_path/well-known
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================

View file

@ -21,29 +21,16 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#=================================================
# REMOVE THE CRON FILE
#=================================================
# Remove a cron file
ynh_secure_remove --file="/etc/systemd/system/$app.timer"
#================================================= #=================================================
# STOP AND REMOVE SERVICE # STOP AND REMOVE SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 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 # Remove the dedicated systemd config
ynh_remove_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 # 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 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 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 # GENERIC FINALIZATION
#================================================= #=================================================

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS # 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 ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -20,7 +20,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading settings..." --weight=1 ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME

View file

@ -22,9 +22,26 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) 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 # 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 echo "method level server message target" > $final_path/conf/ignore_alert.csv
fi 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 # CREATE DEDICATED USER
#================================================= #=================================================
@ -56,8 +59,6 @@ ynh_script_progression --message="Making sure dedicated system user exists..." -
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path" ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
@ -99,13 +100,7 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# SETUP SYSTEMD # SPECIFIC UPGRADE
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
# Create a dedicated systemd config
ynh_add_systemd_config
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # 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" 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 # 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" 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 # END OF SCRIPT
#================================================= #=================================================