1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/monitorix_ynh.git synced 2024-09-03 19:46:06 +02:00

initial commit manifestv2

This commit is contained in:
Salamandar 2023-12-09 00:35:51 +01:00 committed by Salamandar
parent b8a823a6b6
commit 00250054a9
13 changed files with 330 additions and 360 deletions

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://www.monitorix.org/monitorix_3.15.0-izzy1_all.deb
SOURCE_SUM=0d960b9433ecbaba38d9befe27163644886fb5a466d44f5380576ca975b9d8e4
SOURCE_FORMAT=deb
SOURCE_EXTRACT=false
SOURCE_FILENAME=monitorix.deb

View file

@ -21,13 +21,13 @@ include_dir = /etc/monitorix/conf.d
base_dir = /var/lib/monitorix/www/
base_lib = /var/lib/monitorix/
base_url = __YNH_WWW_PATH__
base_cgi = __YNH_WWW_PATH__/cgi
base_url = __PATH__
base_cgi = __PATH__/cgi
<httpd_builtin>
enabled = y
host = localhost
port = __SERVICE_PORT__
port = __PORT__
user = www-data
group = nogroup
log_file = /var/log/monitorix-httpd.log
@ -465,7 +465,7 @@ secure_log_date_format = %b %e
conn_type = socket
list = /run/mysqld/mysqld.sock
<desc>
/run/mysqld/mysqld.sock = 3306, __MYSQL_USER__, __MYSQL_PASSWORD__
/run/mysqld/mysqld.sock = 3306, __DB_USER__, __DB_PASSWORD__
</desc>
rigid = 0, 2, 0, 0, 0, 0
limit = 100, 100, 100, 100, 100, 100
@ -733,9 +733,9 @@ secure_log_date_format = %b %e
# -----------------------------------------------------------------------------
<emailreports>
enabled = n
url_prefix = http://127.0.0.1:__SERVICE_PORT____YNH_WWW_PATH__
url_prefix = http://127.0.0.1:__PORT____PATH__
smtp_hostname = localhost
from_address = noreply@__YNH_DOMAIN__
from_address = noreply@__DOMAIN__
hour = 0
minute = 0
<daily>

View file

@ -1,6 +1,6 @@
server {
listen __PORT__;
listen [::]:__PORT__;
listen __NGINX_STATUS_PORT__;
listen [::]:__NGINX_STATUS_PORT__;
access_log /var/log/nginx/localhost-nginx_status_monitorix.lan-access.log;
error_log /var/log/nginx/localhost-nginx_status_monitorix.lan-error.log;
@ -12,4 +12,4 @@ server {
allow ::1;
deny all;
}
}
}

View file

@ -1,45 +0,0 @@
{
"name": "Monitorix",
"id": "monitorix",
"packaging_format": 1,
"description": {
"en": "A system monitoring tool",
"fr": "Un outil de monitoring système"
},
"version": "3.15.0~ynh3",
"url": "http://monitorix.org",
"upstream": {
"license": "GPL-2.0",
"website": "http://monitorix.org",
"demo": "https://www.fibranet.cat/monitorix/",
"admindoc": "https://www.monitorix.org/documentation.html",
"code": "https://github.com/mikaku/Monitorix"
},
"license": "GPL-2.0",
"maintainer": {
"name": "Josué Tille",
"email": "josue@familletille.ch"
},
"requirements": {
"yunohost": ">= 11.0.11"
},
"multi_instance": false,
"services": [
"nginx",
"mysql"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"example": "/monitorix",
"default": "/monitorix"
}
]
}
}

64
manifest.toml Normal file
View file

@ -0,0 +1,64 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "monitorix"
name = "Monitorix"
description.en = "A system monitoring tool"
description.fr = "Un outil de monitoring système"
version = "3.15.0~ynh3"
maintainers = ["Josue-T"]
[upstream]
license = "GPL-2.0"
website = "https://monitorix.org"
demo = "https://www.fibranet.cat/monitorix/"
admindoc = "https://www.monitorix.org/documentation.html"
code = "https://github.com/mikaku/Monitorix"
cpe = "cpe:2.3:a:fibranet:monitorix"
[integration]
yunohost = ">= 11.0.11"
architectures = "all"
multi_instance = false
ldap = "not_relevant"
sso = "not_relevant"
disk = "50M"
ram.build = "50M"
ram.runtime = "50M"
[install]
[install.domain]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "domain"
[install.path]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "path"
default = "/monitorix"
[resources]
[resources.sources.main]
url = "https://www.monitorix.org/monitorix_3.15.0-izzy1_all.deb"
sha256 = "0d960b9433ecbaba38d9befe27163644886fb5a466d44f5380576ca975b9d8e4"
format = "whatever"
rename = "monitorix.deb"
[resources.system_user]
[resources.permissions]
main.url = "/"
[resources.ports]
main.default = 8080
nginx_status.default = 8081
[resources.apt]
packages = [
"mariadb-server",
]
[resources.database]
type = "mysql"

View file

@ -2,60 +2,48 @@
# SET ALL CONSTANTS
#=================================================
app=$YNH_APP_INSTANCE_NAME
pkg_version="3.15.0"
systemd_user=root
nginx_status_conf="/etc/nginx/conf.d/monitorix_status.conf"
#=================================================
# DEFINE ALL COMMON FONCTIONS
#=================================================
install_dependances() {
ynh_install_app_dependencies rrdtool perl libwww-perl libmailtools-perl libmime-lite-perl librrds-perl libdbi-perl libdbd-mysql-perl libxml-simple-perl libhttp-server-simple-perl libconfig-general-perl pflogsumm libxml-libxml-perl mariadb-server
}
install_monitorix_package() {
# Create the temporary directory
tempdir="$(mktemp -d)"
get_install_source() {
ynh_setup_source --dest_dir /tmp
# Download the deb files
ynh_setup_source --dest_dir="$tempdir" --source_id="main"
ynh_package_update
dpkg --force-confdef --force-confold -i /tmp/monitorix.deb
ynh_secure_remove --file=/etc/monitorix/conf.d/00-debian.conf
ynh_package_install -f
}
# Install the package
ynh_package_install "$tempdir/monitorix.deb"
config_nginx() {
ynh_add_nginx_config
# The doc says it should be called only once,
# but the code says multiple calls are supported.
# Also, they're already installed so that should be quasi instantaneous.
ynh_install_app_dependencies monitorix="$pkg_version"
# Add special hostname for monitorix status
nginx_status_conf="/etc/nginx/conf.d/monitorix_status.conf"
cp ../conf/nginx_status.conf $nginx_status_conf
ynh_replace_string --match_string __PORT__ --replace_string $nginx_status_port --target_file $nginx_status_conf
systemctl reload nginx
# Mark packages as dependencies, to allow automatic removal
apt-mark auto monitorix
}
config_monitorix() {
jail_list=$(fail2ban-client status | grep 'Jail list:' | sed 's/.*Jail list://' | sed 's/,//g')
additional_jail=""
f2b_additional_jail=""
for jail in $jail_list; do
if ! [[ "$jail" =~ (recidive|pam-generic|yunohost|postfix|postfix-sasl|dovecot|nginx-http-auth|sshd|sshd-ddos) ]]; then
if [ -z "$additional_jail" ]; then
additional_jail="[$jail]"
if [ -z "$f2b_additional_jail" ]; then
f2b_additional_jail="[$jail]"
else
additional_jail+=", [$jail]"
f2b_additional_jail+=", [$jail]"
fi
fi
done
monitorix_conf=/etc/monitorix/monitorix.conf
cp ../conf/monitorix.conf $monitorix_conf
ynh_replace_string --match_string __SERVICE_PORT__ --replace_string $port --target_file $monitorix_conf
ynh_replace_string --match_string __YNH_DOMAIN__ --replace_string $domain --target_file $monitorix_conf
ynh_replace_string --match_string __NGINX_STATUS_PORT__ --replace_string $nginx_status_port --target_file $monitorix_conf
ynh_replace_string --match_string __YNH_WWW_PATH__/ --replace_string "${path_url%/}/" --target_file $monitorix_conf
ynh_replace_string --match_string __YNH_WWW_PATH__ --replace_string $path_url --target_file $monitorix_conf
ynh_replace_string --match_string __MYSQL_USER__ --replace_string $dbuser --target_file $monitorix_conf
ynh_replace_string --match_string __MYSQL_PASSWORD__ --replace_string $dbpass --target_file $monitorix_conf
ynh_replace_string --match_string __F2B_ADDITIONAL_JAIL__ --replace_string "$additional_jail" --target_file $monitorix_conf
ynh_add_config --template=../conf/monitorix.conf --destination="/etc/monitorix/monitorix.conf"
}
set_permission() {
@ -64,3 +52,14 @@ set_permission() {
chown www-data:root -R /var/lib/monitorix
chmod u=rwX,g=rwX,o= -R /var/lib/monitorix
}
_ynh_systemd_restart_monitorix() {
# Reload monitorix
# While we stop monitorix sometime the built-in web server is not stopped cleanly. So are sure that everything is cleanly stoped by that
# So this fix that
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
sleep 1
pkill -f "monitorix-httpd listening on" || true
ynh_systemd_action --service_name="$app" --action="start" --log_path 'systemd' --line_match ' - Ok, ready.'
}

View file

@ -3,46 +3,57 @@
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Import common cmd
source ../settings/scripts/experimental_helper.sh
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Stop script if errors
ynh_abort_if_errors
# Retrieve arguments
ynh_print_info --message="Loading installation settings..."
domain=$(ynh_app_setting_get --app $app --key domain)
if [[ ! "$(systemctl status $app.service)" =~ "Active: inactive (dead)" ]]; then
ynh_print_warn --message="It's hightly recommended to make your backup when the service is stopped. Please stop $app service and with this command before to run the backup 'systemctl stop $app.service'"
fi
#=================================================
# STANDARD BACKUP STEPS
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
# Copy NGINX configuration
ynh_print_info --message="Backing up configuration..."
domain=$(ynh_app_setting_get --app $app --key domain)
ynh_backup --src_path "/etc/nginx/conf.d/${domain}.d/${app}.conf"
ynh_backup --src_path "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path "/etc/nginx/conf.d/monitorix_status.conf"
# systemd config
ynh_backup --src_path "/etc/systemd/system/${app}.service"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP SYSTEMD
#=================================================
# Copy hook
ynh_backup --src_path "/etc/yunohost/hooks.d/post_iptable_rules/50-$app"
ynh_backup --src_path "/etc/systemd/system/$app.service"
# Copy Monitorix configuration
ynh_backup --src_path "/etc/monitorix"
#=================================================
# BACKUP VARIOUS FILES
#=================================================
# Copy Monitorix data
ynh_print_info --message="Backing up data..."
ynh_backup --src_path "/var/lib/monitorix" --is_big=1
ynh_backup --src_path "/var/lib/$app" --is_big=1
ynh_backup --src_path="/etc/$app/"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_print_info --message="Backing up the MySQL database..."
### (However, things like MySQL dumps *do* take some time to run, though the
### copy of the generated dump to the archive still happens later)
ynh_mysql_dump_db --database="$db_name" > db.sql
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -1,62 +1,48 @@
#!/bin/bash
#=================================================
# GENERIC START
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# Source YunoHost helpers
source _common.sh
source /usr/share/yunohost/helpers
# Stop script if errors
ynh_abort_if_errors
ynh_script_progression --message="Loading installation settings..."
# Retrive arguments
path_url=$(ynh_normalize_url_path --path_url $YNH_APP_NEW_PATH)
old_domain=$YNH_APP_OLD_DOMAIN
domain=$YNH_APP_NEW_DOMAIN
port=$(ynh_app_setting_get --app $app --key http_port)
nginx_status_port=$(ynh_app_setting_get --app $app --key nginx_status_port)
dbuser=$app
dbname=$app
dbpass=$(ynh_app_setting_get --app $app --key mysqlpwd)
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_script_progression --message="Updating nginx configuration..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
# Update nginx config
if [ "$old_domain" != "$domain" ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file "/etc/nginx/conf.d/$old_domain.d/$app.conf"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
mv "/etc/nginx/conf.d/$old_domain.d/$app.conf" "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_change_url_nginx_config
# Store file checksum for the new config file location
ynh_store_file_checksum --file "/etc/nginx/conf.d/$domain.d/$app.conf"
fi
config_nginx
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1
ynh_script_progression --message="Updating monitorix configuration..."
# Update monitorix configuration
config_monitorix
ynh_script_progression --message="Restarting monitorix services..." --weight=3
# Reload monitorix
# While we stop monitorix sometime the built-in web server is not stopped cleanly. So are sure that everything is cleanly stoped by that
# So this fix that
systemctl stop monitorix.service
sleep 1
pkill -f "monitorix-httpd listening on" || true
ynh_systemd_action -l ' - Ok, ready.' -p '/var/log/monitorix'
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
_ynh_systemd_restart_monitorix
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -3,24 +3,15 @@
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# Source YunoHost helpers
source _common.sh
source /usr/share/yunohost/helpers
# Stop script if errors
ynh_abort_if_errors
ynh_script_progression --message="Validating installation parameters..."
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
ynh_webpath_register $app $domain $path_url
#=================================================
# CHECK EXISTING DIRECTORIES
#=================================================
if [ -e "/var/lib/monitorix" ]; then
old_data_dir_path="/var/lib/monitorix$(date '+%Y%m%d.%H%M%S')"
@ -28,70 +19,56 @@ if [ -e "/var/lib/monitorix" ]; then
mv "/var/lib/monitorix" "$old_data_dir_path"
fi
# Find a port for built-in monitorix HTTP server
ynh_script_progression --message="Finding available ports..."
port=$(ynh_find_port --port 8080)
nginx_status_port=$(ynh_find_port --port $(($port +1)))
# store config in yunohost
ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app $app --key http_port --value $port
ynh_app_setting_set --app $app --key nginx_status_port --value $nginx_status_port
#=================================================
# STANDARD MODIFICATIONS
#=================================================
ynh_script_progression --message="Installing packages..." --weight=1
# Creating the folder
mkdir -p /var/lib/monitorix/www/imgs
mkdir -p /etc/monitorix/conf.d/
touch /etc/monitorix/conf.d/00-debian.conf
# Install package
ynh_script_progression --message="Installing dependencies..." --weight=7
install_dependances
# Download package and install it
ynh_script_progression --message="Installing sources files..." --weight=7
get_install_source
install_monitorix_package
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" --timeout=15
#=================================================
# SYSTEM CONFIGURATION
#=================================================ç
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Configure init script
ynh_script_progression --message="Configuring a systemd service..." --weight=2
ynh_add_systemd_config
yunohost service add "$app" --description="Monitorix"
# # Generate MySQL user
ynh_script_progression --message="Configuring MySQL database..."
dbuser=$app
dbpass=$(ynh_string_random 12)
ynh_app_setting_set --app $app --key mysqlpwd --value "$dbpass"
ynh_mysql_create_user $dbuser $dbpass
ynh_add_config --template "nginx_status.conf" --destination "$nginx_status_conf"
ynh_add_nginx_config
# Config nginx
ynh_script_progression --message="Configuring nginx..." --weight=1
config_nginx
#=================================================
# SPECIFIC SETUP
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
# Update monitorix configuration
ynh_script_progression --message="Configuring application..." --weight=3
config_monitorix
#=================================================
# GENERIC FINALIZATION
#=================================================
# Set access
ynh_script_progression --message="Protecting directory..."
set_permission
# register yunohost service
yunohost service add monitorix
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Reload monitorix
ynh_script_progression --message="Starting monitorix services..." --weight=3
# While we stop monitorix sometime the built-in web server is not stopped cleanly. So are sure that everything is cleanly stoped by that
# So this fix that
systemctl stop monitorix.service
sleep 1
pkill -f "monitorix-httpd listening on" || true
ynh_systemd_action -l ' - Ok, ready.' -p 'systemd'
_ynh_systemd_restart_monitorix
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -3,51 +3,40 @@
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# Source YunoHost helpers
source _common.sh
source /usr/share/yunohost/helpers
ynh_script_progression --message="Loading installation settings..."
# Retrieve app settings
domain=$(ynh_app_setting_get --app $app --key domain)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# Stop service
ynh_script_progression --message="Stoping services..."
systemctl stop monitorix.service
# 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
ynh_script_progression --message="Removing $app service integration..." --weight=3
yunohost service remove "$app"
fi
# Drop MySQL database and user
ynh_script_progression --message="Removing databases..."
dbname=$app
dbuser=$app
ynh_mysql_drop_db "$dbname" || true
ynh_mysql_drop_user "$dbuser" || true
#=================================================
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# Remove data
ynh_print_info --message="Due of the backup core only feature the data directory in '/var/lib/monitorix' was not removed. It need to be removed manually to purge app user data."
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" --timeout=15
# Remove nginx config
ynh_secure_remove --file="/etc/nginx/conf.d/monitorix_status.conf"
ynh_secure_remove --file="$nginx_status_conf"
ynh_remove_nginx_config
# Remove init script
ynh_script_progression --message="Removing systemd units..."
ynh_remove_systemd_config
# Autoremove package
ynh_script_progression --message="Removing dependencies" --weight=10
ynh_remove_app_dependencies
ynh_package_autoremove monitorix
yunohost service remove monitorix
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Due of the backup core only feature the data directory in '/var/lib/monitorix' was not removed. It need to be removed manually to purge app user data."
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -3,77 +3,74 @@
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Import common cmd
source ../settings/scripts/experimental_helper.sh
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Stop script if errors
ynh_abort_if_errors
ynh_script_progression --message="Loading settings..."
# Retrieve old app settings
domain=$(ynh_app_setting_get --app $app --key domain)
path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path))
#=================================================
# STANDARD RESTORATION STEPS
# RESTORE THE DEPENDENCIES
#=================================================
ynh_script_progression --message="Restoring the dependencies..." --weight=1
# Creating the folder
# FIXME: needed ?
mkdir -p /var/lib/monitorix/www/imgs
mkdir -p /etc/monitorix/conf.d/
touch /etc/monitorix/conf.d/00-debian.conf
# Install package
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
install_dependances
install_monitorix_package
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" --timeout=15
# Download package and install it
ynh_script_progression --message="Installing sources files..." --weight=7
get_install_source
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
# Create user for database
ynh_script_progression --message="Configuring MySQL database..."
dbuser=$app
dbpass=$(ynh_app_setting_get --app $app --key mysqlpwd)
ynh_mysql_create_user $dbuser $dbpass
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
# Restore all config and data
ynh_script_progression --message="Restoring files..." --weight=10
ynh_secure_remove --file=/etc/monitorix # we remove the directory because if it is not empty the ynh_restore cmd fail
ynh_secure_remove --file=/var/lib/monitorix
ynh_restore
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
# Restore systemd files
systemctl daemon-reload
systemctl enable "$app".service --quiet
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --src_path "/etc/nginx/conf.d/monitorix_status.conf"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
yunohost service add $app --description="Monitorix" --log="systemd"
# Directories created by the dep package
ynh_secure_remove --file="/etc/$app"
ynh_secure_remove --file="/var/lib/$app"
ynh_restore_file --origin_path="/var/lib/$app" --not_mandatory
ynh_restore_file --origin_path="/etc/$app/"
#=================================================
# GENERIC FINALIZATION
#=================================================
# Set access
ynh_script_progression --message="Protecting directory..."
set_permission
# register yunohost service
yunohost service add monitorix
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#=================================================
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
# Reload nginx
systemctl reload nginx.service
_ynh_systemd_restart_monitorix
# Reload monitorix
ynh_script_progression --message="Starting monitorix services..." --weight=3
# While we stop monitorix sometime the built-in web server is not stopped cleanly. So are sure that everything is cleanly stoped by that
# So this fix that
systemctl stop monitorix.service
sleep 1
pkill -f "monitorix-httpd listening on" || true
ynh_systemd_action -l ' - Ok, ready.' -p 'systemd'
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -3,90 +3,87 @@
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# Source YunoHost helpers
source _common.sh
source /usr/share/yunohost/helpers
# Stop script if errors
ynh_abort_if_errors
ynh_script_progression --message="Loading installation settings..."
# Retrieve app settings
domain=$(ynh_app_setting_get --app $app --key domain)
path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path))
port=$(ynh_app_setting_get --app $app --key http_port)
nginx_status_port=$(ynh_app_setting_get --app $app --key nginx_status_port)
dbuser=$app
dbname=$app
dbpass=$(ynh_app_setting_get --app $app --key mysqlpwd)
# Stop services
ynh_script_progression --message="Stoping services..."
systemctl stop monitorix.service
# Backup the current version of the app
if [ "0$(ynh_app_setting_get --app=$app --key=disable_backup_before_upgrade)" -ne 1 ]
then
ynh_backup_before_upgrade
ynh_clean_setup () {
# Clean installation remainings that are not handled by the remove script.
ynh_restore_upgradebackup
}
fi
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Install package
ynh_script_progression --message="Installing dependencies..." --weight=6
install_dependances
# Download package and install it
ynh_script_progression --message="Upgrading source files..." --weight=6
# Fix issue on package deployement
test -e /etc/monitorix/conf.d/00-debian.conf || touch /etc/monitorix/conf.d/00-debian.conf
get_install_source
# Configure init script
ynh_script_progression --message="Configuring a systemd service..." --weight=2
ynh_add_systemd_config
# Update nginx config
config_nginx
# Update monitorix configuration
ynh_script_progression --message="Configuring application..."
config_monitorix
# Remove old hook if exist
ynh_secure_remove --file=/usr/share/yunohost/hooks/post_iptable_rules/50-$app
#=================================================
# GENERIC FINALIZATION
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
# Set access
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from manifest.toml
install_monitorix_package
fi
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" --timeout=15
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
ynh_add_config --template "nginx_status.conf" --destination "$nginx_status_conf"
ynh_add_nginx_config
ynh_add_systemd_config
yunohost service add $app --description="Monitorix" --log="systemd"
#=================================================
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1
config_monitorix
#=================================================
# GENERIC FINALIZATION
#=================================================
ynh_script_progression --message="Protecting directory..."
set_permission
# register yunohost service
yunohost service add monitorix
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Reload monitorix
# While we stop monitorix sometime the built-in web server is not stopped cleanly. So are sure that everything is cleanly stoped by that
# So this fix that
ynh_script_progression --message="Starting monitorix services..." --weight=3
systemctl stop monitorix.service
sleep 1
pkill -f "monitorix-httpd listening on" || true
ynh_systemd_action -l ' - Ok, ready.' -p 'systemd'
_ynh_systemd_restart_monitorix
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last