mirror of
https://github.com/YunoHost-Apps/monitorix_ynh.git
synced 2024-09-03 19:46:06 +02:00
107 lines
3.4 KiB
Bash
Executable file
107 lines
3.4 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
load_vars
|
|
|
|
#=================================================
|
|
# MIGRATION 5 : Manage old settings
|
|
#=================================================
|
|
|
|
ensure_vars_set
|
|
|
|
#=================================================
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
#=================================================
|
|
ynh_script_progression "Ensuring downward compatibility..."
|
|
|
|
# Fix issue on package deployement
|
|
test -e /etc/monitorix/conf.d/00-debian.conf || touch /etc/monitorix/conf.d/00-debian.conf
|
|
|
|
# Remove old hook if exist
|
|
ynh_safe_rm /usr/share/yunohost/hooks/post_iptable_rules/50-"$app"
|
|
|
|
#=================================================
|
|
# STOP SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression "Stopping $app's systemd service..."
|
|
|
|
ynh_systemctl --service="$app" --action=stop
|
|
|
|
#=================================================
|
|
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...)
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
|
|
ynh_script_progression "Upgrading source files..."
|
|
|
|
# Download, check integrity, uncompress and patch the source from manifest.toml
|
|
install_monitorix_package
|
|
|
|
ynh_systemctl --service="$app" --action=stop --log_path=systemd --timeout=15
|
|
|
|
#=================================================
|
|
# MIGRATION 2
|
|
#=================================================
|
|
|
|
# Migrate log files
|
|
if [ ! -d /var/log/"${app}" ]; then
|
|
mkdir -p /var/log/new_"${app}"
|
|
mv -t /var/log/new_"${app}" /var/log/monitorix*
|
|
mv /var/log/new_"${app}" /var/log/"${app}"
|
|
fi
|
|
|
|
# Migrate data directory
|
|
if [ -e /var/lib/monitorix/system.rrd ] && [ ! -e "$data_dir"/system.rrd ] ; then
|
|
mv -f -t "$data_dir/" /var/lib/monitorix/*
|
|
fi
|
|
|
|
#=================================================
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
|
#=================================================
|
|
ynh_script_progression "Upgrading configurations related to $app..."
|
|
|
|
ynh_config_add --jinja --template=monitorix.conf --destination=/etc/monitorix/monitorix.conf
|
|
ynh_config_add --jinja --template=nginx_status.conf --destination="$nginx_status_conf"
|
|
if "$phpfpm_installed"; then
|
|
config_php_fpm
|
|
fi
|
|
ynh_config_add_nginx
|
|
ynh_config_add_systemd
|
|
|
|
yunohost service add "$app" --description=Monitorix --log=systemd
|
|
|
|
ynh_script_progression "Configuring databases access..."
|
|
configure_db
|
|
|
|
ynh_script_progression "Configuring php fpm access if needed..."
|
|
if "$phpfpm_installed"; then
|
|
config_php_fpm
|
|
fi
|
|
|
|
configure_hooks
|
|
configure_alerts_email
|
|
|
|
#=================================================
|
|
ynh_script_progression "Protecting directory..."
|
|
|
|
set_permission
|
|
|
|
ynh_config_add_logrotate "/var/log/$app"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression "Starting $app's systemd service..."
|
|
|
|
ynh_systemctl --service="$app" --action=restart --log_path=systemd --wait_until=' - Ok, ready.'
|
|
# when we change the value of 'listen [::1]:xxx;' nginx don't reload correctly the config, so force to restart to ensure that the new config are loaded
|
|
ynh_systemctl --service=nginx.service --action=restart
|
|
save_vars_current_value
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression "Upgrade of $app completed"
|