| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- #!/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"
- if [ ! -d "/usr/share/zabbix-cli" ]; then
- zabbix_username="svc_${app}_ldap"
- zabbix_password=$(ynh_string_random --length=32)
- ynh_app_setting_set --app="$app" --key=zabbix_username --value="$zabbix_username"
- ynh_app_setting_set --app="$app" --key=zabbix_password --value="$zabbix_password"
- yunohost user create "$zabbix_username" --fullname "${zabbix_username//_}" --domain "$domain" --password "$zabbix_password" -q 0
- mkdir -p /usr/share/zabbix-cli
- python3 -m venv /usr/share/zabbix-cli
- /usr/share/zabbix-cli/bin/pip install zabbix-cli-uio
- ynh_add_config --template="zabbix-cli_default.toml" --destination="/usr/share/zabbix-cli/zabbix-cli.toml"
- enable_admin_user
- /usr/share/zabbix-cli/bin/zabbix-cli --config /usr/share/zabbix-cli/zabbix-cli.toml create_user $zabbix_username --firstname $zabbix_username --lastname $zabbix_username --passwd $zabbix_password --role superadmin --groups 7
- disable_admin_user
- ynh_add_config --template="zabbix-cli.toml" --destination="/usr/share/zabbix-cli/zabbix-cli.toml"
- fi
- #=================================================
- # 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"
|