#!/bin/bash #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # STOP SYSTEMD SERVICE #================================================= ynh_script_progression --message="Stopping $app's systemd service..." ynh_systemd_action --service_name="$app-server" --action="stop" --log_path="/var/log/$app/${app}_server.log" ynh_systemd_action --service_name="$app-agent" --action="stop" --log_path="/var/log/$app/${app}_agent.log" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." if [ "$language" == "fr" ]; then language="fr_FR" ynh_app_setting_set --app="$app" --key="language" --value="$language" fi if [ "$language" == "en" ]; then language="en_GB" ynh_app_setting_set --app="$app" --key="language" --value="$language" fi export mysqlconn="mysql --user=$db_user --password=$db_pwd --database=$db_name" # patch to remove old zabbix-client service if yunohost service status | grep zabbix-client; then ynh_script_progression --message="remove zabbix-client old service" yunohost service remove zabbix-client fi ynh_remove_logrotate # Check if new zabbix version is available on repo" ynh_package_update ynh_add_config --template="../conf/etc_zabbix_web_zabbix.conf.php" --destination="/etc/zabbix/web/zabbix.conf.php" chmod 400 "/etc/zabbix/web/zabbix.conf.php" chown "$app:www-data" "/etc/zabbix/web/zabbix.conf.php" if [ -f "/usr/share/zabbix/conf/zabbix.conf.php" ]; then ynh_secure_remove --file="/usr/share/zabbix/conf/zabbix.conf.php" fi ln -s "/etc/zabbix/web/zabbix.conf.php" "/usr/share/zabbix/conf/zabbix.conf.php" ynh_remove_extra_repo --name=zabbix chmod 750 "/usr/share/zabbix" chmod -R o-rwx "/usr/share/zabbix" chown -R "$app:www-data" "/usr/share/zabbix" #================================================= # SPECIFIC UPGRADE #================================================= # CUSTOMIZE DATABASE #================================================= ynh_script_progression --message="Customize the database..." convert_ZabbixDB set_mediatype_default_yunohost #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config # Create a dedicated NGINX config ynh_add_nginx_config change_timeoutAgent systemctl enable zabbix-agent --quiet systemctl enable zabbix-server --quiet yunohost service add snmpd --description="Management of SNMP Daemon" yunohost service add zabbix-server --description="Management Zabbix server daemon : collect, agregate, compute and notify" --log="/var/log/$app/${app}_server.log" yunohost service add zabbix-agent --description="Management Zabbix agent daemon : send informations about this host to the server" --log="/var/log/$app/${app}_agent.log" update_initZabbixConf #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting $app's systemd service..." --weight=1 # Start a systemd service ynh_systemd_action --service_name="$app-server" --action="restart" --log_path="/var/log/$app/${app}_server.log" --line_match="server #0 started" ynh_systemd_action --service_name="$app-agent" --action="restart" --log_path="/var/log/$app/${app}_agent.log" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Upgrade of $app completed"