mirror of
https://github.com/YunoHost-Apps/zabbix_ynh.git
synced 2024-09-03 20:36:14 +02:00
138 lines
4.4 KiB
Bash
138 lines
4.4 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
|
port=$(ynh_app_setting_get "$app" port)
|
|
db_name=$(ynh_app_setting_get "$app" db_name)
|
|
db_user=$db_name
|
|
#final_path=$(ynh_app_setting_get "$app" final_path) #not used
|
|
|
|
#=================================================
|
|
# REMOVE SERVICE FROM ADMIN PANEL
|
|
#=================================================
|
|
# Remove a service from the admin panel, added by `yunohost service add`
|
|
|
|
yunohost service remove snmpd
|
|
yunohost service remove zabbix-server
|
|
yunohost service remove zabbix-agent
|
|
|
|
#=================================================
|
|
# REMOVE PHP-FPM CONFIGURATION
|
|
#=================================================
|
|
|
|
# Remove the dedicated php-fpm config
|
|
ynh_remove_fpm_config
|
|
|
|
#=================================================
|
|
# REMOVE DEPENDENCIES
|
|
#=================================================
|
|
|
|
timeout 5 systemctl stop zabbix-server || killall zabbix_server
|
|
systemctl disable zabbix-server --quiet
|
|
killall zabbix_server
|
|
|
|
timeout 5 systemctl stop zabbix-agent || killall zabbix_agentd
|
|
systemctl disable zabbix-agent --quiet
|
|
killall zabbix_agentd
|
|
|
|
#Remove config file detection
|
|
delete_initZabbixConf
|
|
|
|
DEBIAN_FRONTEND=noninteractive apt-get purge zabbix-release -y
|
|
ynh_remove_app_dependencies
|
|
|
|
#force removing if ynh_remove_app_dependencies not work (old zabbix version)
|
|
for zabbix_pkg in $(apt list --installed | grep -Po "\K(zabbix-.*)(?=/)")
|
|
do
|
|
DEBIAN_FRONTEND=noninteractive apt-get purge --allow-change-held-packages "$zabbix_pkg" -y
|
|
done
|
|
|
|
#=================================================
|
|
# REMOVE THE MYSQL DATABASE
|
|
#=================================================
|
|
|
|
# Remove a database if it exists, along with the associated user
|
|
ynh_mysql_remove_db "$db_user" "$db_name"
|
|
|
|
#=================================================
|
|
# REMOVE NGINX CONFIGURATION
|
|
#=================================================
|
|
|
|
# Remove the dedicated nginx config
|
|
ynh_remove_nginx_config
|
|
|
|
#=================================================
|
|
# REMOVE LOGROTATE CONFIGURATION
|
|
#=================================================
|
|
|
|
# Remove the app-specific logrotate config
|
|
ynh_remove_logrotate
|
|
|
|
#=================================================
|
|
# CLOSE A PORT
|
|
#=================================================
|
|
|
|
if yunohost firewall list | grep -q "\- $port$"
|
|
then
|
|
echo "Close port $port" >&2
|
|
yunohost firewall disallow TCP "$port" 2>&1
|
|
fi
|
|
|
|
#=================================================
|
|
# SPECIFIC REMOVE
|
|
#=================================================
|
|
# REMOVE THE CRON FILE
|
|
#=================================================
|
|
|
|
remove_zabbix_repo
|
|
|
|
if [ -d /var/www/zabbix ] ;then ynh_secure_remove /var/www/zabbix;fi
|
|
|
|
# Remove a directory securely
|
|
if [ -d /etc/zabbix ] ;then ynh_secure_remove "/etc/zabbix";fi
|
|
|
|
# Remove the log files
|
|
if [ -d /var/log/zabbix ] ;then ynh_secure_remove "/var/log/zabbix";fi
|
|
|
|
# Remove the pid/socket files
|
|
if [ -d /run/zabbix ] ;then ynh_secure_remove "/run/zabbix";fi
|
|
|
|
# Remove the sudoers file
|
|
if [ -f /etc/sudoers.d/zabbix ] ;then ynh_secure_remove "/etc/sudoers.d/zabbix";fi
|
|
|
|
|
|
#REMOVE NONFREE PART PATCH IF NEEDED (snmp-mibs-downloader (non-free) installed in version 1)
|
|
nonfreepackagelist=$(dpkg-query -W -f='${Section}\t${Package}\n' | grep ^non-free)
|
|
if [ $(echo $nonfreepackagelist | wc -l) -eq 1 ] && [ $(echo $nonfreepackagelist | grep -c "snmp-mibs-downloader") -eq 1 ] ;then
|
|
ynh_print_info "Removing snmp-mibs-downloader (non-free package)"
|
|
cp /var/lib/dpkg/status{,.$(date "+%m%d%y")}
|
|
ynh_replace_string --match_string=" snmp-mibs-downloader," --replace_string="" --target_file=/var/lib/dpkg/status
|
|
DEBIAN_FRONTEND=noninteractive apt purge snmp-mibs-downloader -y
|
|
if [ -f /etc/apt/sources.list.d/non-free.list ];then
|
|
ynh_secure_remove /etc/apt/sources.list.d/non-free.list
|
|
fi
|
|
fi
|
|
|
|
|
|
#=================================================
|
|
# GENERIC FINALIZATION
|
|
#=================================================
|
|
# REMOVE DEDICATED USER
|
|
#=================================================
|
|
|
|
# Delete a system user
|
|
ynh_system_user_delete zabbix
|