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 #14 from YunoHost-Apps/manifestv2

Manifestv2
This commit is contained in:
Salamandar 2024-01-19 17:06:44 +01:00 committed by GitHub
commit 24bd6308aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 188 additions and 449 deletions

View file

@ -19,14 +19,9 @@ 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~ynh3
## Disclaimers / important information
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").
**Shipped version:** 1.1.0~ynh4
## Documentation and resources
* Official app website: <https://github.com/zamentur/yunomonitor>
* Official admin documentation: <https://github.com/zamentur/yunomonitor/blob/master/README.md>
* Upstream app code repository: <https://github.com/zamentur/yunomonitor>
* YunoHost Store: <https://apps.yunohost.org/app/yunomonitor>

View file

@ -19,14 +19,9 @@ Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po
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~ynh3
## Avertissements / informations importantes
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").
**Version incluse :** 1.1.0~ynh4
## Documentations et ressources
* Site officiel de lapp : <https://github.com/zamentur/yunomonitor>
* Documentation officielle de ladmin : <https://github.com/zamentur/yunomonitor/blob/master/README.md>
* Dépôt de code officiel de lapp : <https://github.com/zamentur/yunomonitor>
* YunoHost Store: <https://apps.yunohost.org/app/yunomonitor>

View file

@ -1,20 +0,0 @@
;; Test complet
; Manifest
monitored_servers="remote_domain.tld,remote_domain2.tld"
monitoring_servers=""
mails="john@example.com"
sms_api=""
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=0
setup_nourl=1
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
change_url=0

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/zamentur/yunomonitor/archive/0a2c295485dbda9da3b97353e094ef414c939609.tar.gz
SOURCE_SUM=e9c63885c5158771a00ae892967a0f7d1f3f538f26d124f8f096bb7b8ff3113a
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=yunomonitor-1-1-0.tar.gz
SOURCE_EXTRACT=true

View file

@ -1,5 +1,5 @@
location ^~ '/.well-known/yunomonitor/' {
default_type "text/plain";
alias __FINALPATH__/well-known/;
alias __INSTALL_DIR__/well-known/;
}

View file

@ -6,8 +6,8 @@ After=network.target
Type=oneshot
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__
ExecStart=__FINALPATH__/yunomonitor.py -c __FINALPATH__/conf/__APP__.yml
WorkingDirectory=__INSTALL_DIR__
ExecStart=__INSTALL_DIR__/yunomonitor.py -c __INSTALL_DIR__/conf/__APP__.yml
User=root
Group=root

View file

@ -1,73 +0,0 @@
{
"name": "YunoMonitor",
"id": "yunomonitor",
"packaging_format": 1,
"description": {
"en": "Home made tool to monitor automatically your servers",
"fr": "Outil pour surveiller automatiquement vos serveurs"
},
"version": "1.1.0~ynh3",
"url": "https://github.com/zamentur/yunomonitor",
"upstream": {
"license": "AGPL-3.0",
"website": "https://github.com/zamentur/yunomonitor",
"admindoc": "https://github.com/zamentur/yunomonitor/blob/master/README.md",
"code": "https://github.com/zamentur/yunomonitor"
},
"license": "AGPL-3.0",
"maintainer": {
"name": "ljf",
"email": "ljf+@reflexlibre.net",
"url": "https://reflexlibre.net"
},
"requirements": {
"yunohost": ">= 4.3.0"
},
"multi_instance": false,
"services": [
"nginx"
],
"arguments": {
"install": [
{
"name": "monitored_servers",
"type": "string",
"ask": {
"en": "List all servers you want to monitor with this server (separated by comma)"
},
"help": {
"en": "You need to install yunomonitor on those servers or add manually a custom configuration file for each server to monitor"
},
"example": "example.com,example2.com",
"default": "localhost"
},
{
"name": "monitoring_servers",
"type": "string",
"ask": {
"en": "List all monitoring servers that monitored this server (separated by comma)"
},
"example": "example.com,example2.com",
"optional": true
},
{
"name": "mails",
"type": "string",
"ask": {
"en": "Mails to which send alerts about servers monitored by this server (separated by comma)"
},
"example": "john@example.com,jane@example.com",
"optional": true
},
{
"name": "sms_api",
"type": "string",
"ask": {
"en": "List here an SMS URL to use to send alerts by SMS (e.g. the internet provider 'free' offers some API for that)"
},
"example": "https://smsapi.free-mobile.fr/sendmsg?user=USERID&pass=PASSWORD&msg=",
"optional": true
}
]
}
}

80
manifest.toml Normal file
View file

@ -0,0 +1,80 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "yunomonitor"
name = "YunoMonitor"
description.en = "Home made tool to monitor automatically your servers"
description.fr = "Outil pour surveiller automatiquement vos serveurs"
version = "1.1.0~ynh4"
maintainers = ["ljf"]
[upstream]
license = "AGPL-3.0"
code = "https://github.com/zamentur/yunomonitor"
admindoc = "https://github.com/zamentur/yunomonitor/blob/master/README.md"
fund = "https://donate.yunohost.org/"
[integration]
yunohost = ">= 4.3.0"
architectures = "all"
multi_instance = false
ldap = "not_relevant"
sso = "not_relevant"
disk = "10M"
ram.build = "50M"
ram.runtime = "50M"
[install]
[install.monitored_servers]
ask.en = "List all servers you want to monitor with this server (separated by comma)"
help.en = "You need to install yunomonitor on those servers or add manually a custom configuration file for each server to monitor"
type = "string"
example = "example.com,example2.com"
default = "localhost"
[install.monitoring_servers]
ask.en = "List all monitoring servers that monitored this server (separated by comma)"
type = "string"
example = "example.com,example2.com"
optional = true
[install.mails]
ask.en = "Mails to which send alerts about servers monitored by this server (separated by comma)"
type = "string"
example = "john@example.com,jane@example.com"
optional = true
[install.sms_api]
ask.en = "List here an SMS URL to use to send alerts by SMS (e.g. the internet provider 'free' offers some API for that)"
type = "string"
example = "https://smsapi.free-mobile.fr/sendmsg?user=USERID&pass=PASSWORD&msg="
optional = true
[resources]
[resources.sources.main]
url = "https://github.com/zamentur/yunomonitor/archive/0a2c295485dbda9da3b97353e094ef414c939609.tar.gz"
sha256 = "e9c63885c5158771a00ae892967a0f7d1f3f538f26d124f8f096bb7b8ff3113a"
autoupdate.strategy = "latest_github_commit"
[resources.system_user]
[resources.install_dir]
[resources.permissions]
[resources.apt]
packages = [
"python3-dbus",
"python3-pip",
"python3-cryptography",
"python3-paramiko",
"python3-yaml",
"python3-dnspython",
"python3-requests-toolbelt",
"python3-spf",
"whois",
"smartmontools",
]

View file

@ -4,43 +4,32 @@
# COMMON VARIABLES
#=================================================
# dependencies used by the app
pkg_dependencies="python3-dbus python3-cryptography python3-paramiko python3-yaml python3-dnspython python3-requests-toolbelt python3-spf whois smartmontools"
#=================================================
# PERSONAL HELPERS
#=================================================
_yunomonitor_add_nginx_config() {
# Create a dedicated nginx config
# Note: i don't use the helper because i need this file to be named "000-"
finalnginxconf="/etc/nginx/conf.d/$domain.d/000-$app.conf"
ynh_backup_if_checksum_is_different --file="$finalnginxconf"
cp ../conf/nginx.conf "$finalnginxconf"
ynh_replace_string --match_string="__INSTALL_DIR__" --replace_string="$install_dir" --target_file="$finalnginxconf"
ynh_store_file_checksum --file="$finalnginxconf"
}
_yunomonitor_remove_nginx_config() {
finalnginxconf="/etc/nginx/conf.d/$domain.d/000-$app.conf"
ynh_secure_remove --file="$finalnginxconf"
# Workaround for app linter that does not want you to reload nginx
service=nginx
ynh_systemd_action --service_name="$service" --action=reload
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
ynh_export () {
local ynh_arg=""
for var in $@;
do
ynh_arg=$(echo $var | awk '{print toupper($0)}')
if [ "$var" == "path_url" ]; then
ynh_arg="PATH"
fi
ynh_arg="YNH_APP_ARG_$ynh_arg"
export $var="${!ynh_arg}"
done
}
# Save listed var in YunoHost app settings
# usage: ynh_save_args VARNAME1 [VARNAME2 [...]]
ynh_save_args () {
for var in $@;
do
local setting_var="$var"
if [ "$var" == "path_url" ]; then
setting_var="path"
fi
ynh_app_setting_set "$app" "$setting_var" "${!var}"
done
}
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -10,23 +10,6 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
@ -36,7 +19,7 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$final_path"
ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION

View file

@ -10,83 +10,32 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
# INITIALIZE AND STORE SETTINGS
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
domain=$(yunohost domain list --json | jq -r '.["main"]')
path=/.well-known/yunomonitor/
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
export domain=$(cat /etc/yunohost/current_host)
export path_url=/.well-known/yunomonitor/
ynh_export monitored_servers monitoring_servers mails sms_api
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/opt/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_save_args domain path_url monitored_servers monitoring_servers mails sms_api
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
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"
ynh_app_setting_set --app="$app" --key="domain" --value="$domain"
ynh_app_setting_set --app="$app" --key="path" --value="$path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
ynh_setup_source --dest_dir="$install_dir"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated nginx config
# Note: i don't use the helper because i need this file to be named "000-"
finalnginxconf="/etc/nginx/conf.d/$domain.d/000-$app.conf"
ynh_backup_if_checksum_is_different --file="$finalnginxconf"
cp ../conf/nginx.conf "$finalnginxconf"
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$finalnginxconf"
ynh_store_file_checksum --file="$finalnginxconf"
ynh_systemd_action --service_name=nginx --action=reload
_yunomonitor_add_nginx_config
#=================================================
# SPECIFIC SETUP
@ -95,8 +44,8 @@ ynh_systemd_action --service_name=nginx --action=reload
#=================================================
ynh_script_progression --message="Building Yunomonitor..."
pushd "$final_path"
pip3 install pycryptodome
pushd "$install_dir"
python3 -m pip install pycryptodome pyyaml
popd
#=================================================
@ -105,50 +54,43 @@ popd
ynh_script_progression --message="Configuring a systemd service..."
ynh_add_systemd_config
cp ../conf/systemd.timer "/etc/systemd/system/$app.timer"
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/etc/systemd/system/$app.timer"
ynh_add_config --template="systemd.timer" --destination="/etc/systemd/system/$app.timer"
systemctl daemon-reload
systemctl enable $app.timer --quiet
systemctl start $app.timer
systemctl enable "$app.timer" --quiet
systemctl start "$app.timer"
#=================================================
# 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
echo "monitored_servers: [$monitored_servers]" >> $final_path/conf/$app.yml
echo "monitoring_servers: [$monitoring_servers]" >> $final_path/conf/$app.yml
echo "cachet_apis: []" >> $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
python3 -c '
import sys
import yaml
split_or_empty = lambda x: [] if x == "" else x.split(",")
print(yaml.dump({
"mails": split_or_empty(sys.argv[1]),
"sms_apis": split_or_empty(sys.argv[2]),
"monitored_servers": split_or_empty(sys.argv[3]),
"monitoring_servers": split_or_empty(sys.argv[4]),
}))
' "$mails" "$sms_api" "$monitored_servers" "$monitoring_servers" \
> "$install_dir/conf/$app.yml"
# 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="$install_dir/conf/$app.yml"
#=================================================
# INIT IGNORE FILE
#=================================================
echo "method level server message target" > $final_path/conf/ignore_alert.csv
echo "method level server message target" > "$install_dir/conf/ignore_alert.csv"
# 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
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
chmod u+x "$install_dir/yunomonitor.py"
chmod u+w "$install_dir/conf"
chmod u+w "$install_dir/well-known"
#=================================================
# END OF SCRIPT

View file

@ -10,60 +10,21 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
app=$YNH_APP_INSTANCE_NAME
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
yunohost service remove "$app"
fi
domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" --timeout=15
ynh_secure_remove --file="/etc/systemd/system/$app.timer"
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# 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
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user
ynh_system_user_delete --username=$app
_yunomonitor_remove_nginx_config
#=================================================
# END OF SCRIPT

View file

@ -10,41 +10,6 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE FILES
#=================================================
@ -57,30 +22,20 @@ ynh_restore
#=================================================
# Restore permissions on app files
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod u+x $final_path/yunomonitor.py
chmod u+w $final_path/conf
chmod u+w $final_path/well-known
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chmod u+x "$install_dir/yunomonitor.py"
chmod u+w "$install_dir/conf"
chmod u+w "$install_dir/well-known"
#=================================================
# BUILD YUNOMONITOR
#=================================================
ynh_script_progression --message="Building Yunomonitor..."
pushd "$final_path"
pip3 install pycryptodome
pushd "$install_dir"
python3 -m pip install pycryptodome
popd
#=================================================
@ -89,9 +44,9 @@ popd
ynh_script_progression --message="Activating systemd timer..." --weight=1
systemctl daemon-reload
systemctl enable $app.service --quiet
systemctl enable $app.timer --quiet
systemctl start $app.timer
systemctl enable "$app.service" --quiet
systemctl enable "$app.timer" --quiet
systemctl start "$app.timer"
#=================================================
# GENERIC FINALIZATION

View file

@ -9,37 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
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
#=================================================
@ -47,85 +16,50 @@ ynh_abort_if_errors
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
if ! [ -f $final_path/conf/ignore_alert.csv ]; then
echo "method level server message target" > $final_path/conf/ignore_alert.csv
if ! [ -f "$install_dir/conf/ignore_alert.csv" ]; then
echo "method level server message target" > "$install_dir/conf/ignore_alert.csv"
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Upgrading source files..." --weight=1
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
fi
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod u+x $final_path/yunomonitor.py
chmod u+w $final_path/conf
chmod u+w $final_path/well-known
chmod u+x "$install_dir/yunomonitor.py"
chmod u+w "$install_dir/conf"
chmod u+w "$install_dir/well-known"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
# Create a dedicated nginx config
# Note: i don't use the helper because i need this file to be named "000-"
finalnginxconf="/etc/nginx/conf.d/$domain.d/000-$app.conf"
ynh_backup_if_checksum_is_different --file="$finalnginxconf"
cp ../conf/nginx.conf "$finalnginxconf"
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$finalnginxconf"
ynh_store_file_checksum --file="$finalnginxconf"
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# SPECIFIC UPGRADE
#=================================================
# BUILD YUNOMONITOR
#=================================================
ynh_script_progression --message="Building Yunomonitor..."
pushd "$final_path"
pip3 install pycryptodome
pushd "$install_dir"
python3 -m pip install pycryptodome pyyaml
popd
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
ynh_backup_if_checksum_is_different --file="$final_path/conf/$app.yml"
ynh_backup_if_checksum_is_different --file="$install_dir/conf/$app.yml"
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$final_path/conf/$app.yml"
ynh_store_file_checksum --file="$install_dir/conf/$app.yml"
#=================================================
# SETUP SYSTEMD
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
_yunomonitor_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
@ -133,14 +67,7 @@ ynh_add_systemd_config
#=================================================
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
ynh_systemd_action --service_name="$app" --action="reload" --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT

12
tests.toml Normal file
View file

@ -0,0 +1,12 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
test_format = 1.0
[default]
args.monitored_servers = "remote_domain.tld,remote_domain2.tld"
args.monitoring_servers = ""
args.mails = "john@example.com"
args.sms_api = ""
test_upgrade_from.64c9fef.name = "Last Packagingv1 version"