2017-01-05 23:37:07 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-01-31 16:07:43 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
|
2020-11-17 23:37:38 +01:00
|
|
|
# Import common cmd
|
|
|
|
source ./experimental_helper.sh
|
|
|
|
source ./_common.sh
|
|
|
|
|
2017-07-21 22:11:45 +02:00
|
|
|
# Source YunoHost helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
# Stop script if errors
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Loading installation settings..."
|
|
|
|
|
2017-01-05 23:37:07 +01:00
|
|
|
# Retrieve app settings
|
2019-06-07 23:09:30 +02:00
|
|
|
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)
|
2017-01-05 23:37:07 +01:00
|
|
|
dbuser=$app
|
|
|
|
dbname=$app
|
2019-06-07 23:09:30 +02:00
|
|
|
dbpass=$(ynh_app_setting_get --app $app --key mysqlpwd)
|
2017-01-05 23:37:07 +01:00
|
|
|
|
2017-11-11 00:04:32 +01:00
|
|
|
# Stop services
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Stoping services..."
|
2017-11-11 00:04:32 +01:00
|
|
|
systemctl stop monitorix.service
|
|
|
|
|
2018-01-13 21:31:48 +01:00
|
|
|
# Backup the current version of the app
|
2022-11-02 23:07:44 +01:00
|
|
|
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
|
2018-01-13 21:31:48 +01:00
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
2018-01-31 16:07:43 +01:00
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
|
2020-03-19 22:56:03 +01:00
|
|
|
# Install package
|
|
|
|
ynh_script_progression --message="Installing dependencies..." --weight=6
|
|
|
|
install_dependances
|
|
|
|
|
2017-10-31 23:08:23 +01:00
|
|
|
# Download package and install it
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=6
|
2022-11-02 22:34:48 +01:00
|
|
|
# Fix issue on package deployement
|
|
|
|
test -e /etc/monitorix/conf.d/00-debian.conf || touch /etc/monitorix/conf.d/00-debian.conf
|
2017-10-31 23:08:23 +01:00
|
|
|
get_install_source
|
2017-01-05 23:37:07 +01:00
|
|
|
|
2023-01-22 03:09:34 +01:00
|
|
|
# Configure init script
|
|
|
|
ynh_script_progression --message="Configuring a systemd service..." --weight=2
|
|
|
|
ynh_add_systemd_config
|
|
|
|
|
2017-07-21 22:11:45 +02:00
|
|
|
# Update nginx config
|
|
|
|
config_nginx
|
2017-01-05 23:37:07 +01:00
|
|
|
|
|
|
|
# Update monitorix configuration
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Configuring application..."
|
2017-07-21 22:11:45 +02:00
|
|
|
config_monitorix
|
2017-01-05 23:37:07 +01:00
|
|
|
|
2018-08-31 14:52:48 +02:00
|
|
|
# Remove old hook if exist
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_secure_remove --file=/usr/share/yunohost/hooks/post_iptable_rules/50-$app
|
2018-04-30 21:41:07 +02:00
|
|
|
|
2018-01-31 16:07:43 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
|
2018-01-29 18:57:10 +01:00
|
|
|
# Set access
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Protecting directory..."
|
2018-01-29 18:57:10 +01:00
|
|
|
set_permission
|
|
|
|
|
2020-11-17 23:37:38 +01:00
|
|
|
# register yunohost service
|
|
|
|
yunohost service add monitorix
|
|
|
|
|
2018-05-01 21:00:07 +02:00
|
|
|
# Reload monitorix
|
2018-05-07 23:08:03 +02:00
|
|
|
# While we stop monitorix sometime the built-in web server is not stopped cleanly. So are sure that everything is cleanly stoped by that
|
2018-05-01 21:00:07 +02:00
|
|
|
# So this fix that
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Starting monitorix services..." --weight=3
|
|
|
|
systemctl stop monitorix.service
|
2018-05-01 21:00:07 +02:00
|
|
|
sleep 1
|
2018-05-07 23:08:03 +02:00
|
|
|
pkill -f "monitorix-httpd listening on" || true
|
2023-01-22 03:09:34 +01:00
|
|
|
ynh_systemd_action -l ' - Ok, ready.' -p 'systemd'
|
2019-06-07 23:09:30 +02:00
|
|
|
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|