2017-02-18 16:45:43 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-12-03 19:24:03 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC STARTING
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2017-02-18 16:45:43 +01:00
|
|
|
|
|
|
|
# See comments in install script
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
2017-03-12 12:40:26 +01:00
|
|
|
# Source local helpers
|
|
|
|
source ./_common.sh
|
|
|
|
|
2017-02-18 16:45:43 +01:00
|
|
|
# Source YunoHost helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
# Retrieve app settings
|
|
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
|
|
|
|
|
|
|
# Stop services
|
|
|
|
sudo systemctl stop grafana-server
|
|
|
|
sudo systemctl stop influxdb
|
|
|
|
|
|
|
|
# Remove app dependencies
|
2017-03-12 12:40:26 +01:00
|
|
|
ynh_remove_app_dependencies || true
|
|
|
|
|
2017-02-18 16:45:43 +01:00
|
|
|
# If packages deinstalled (weren't installed priorly to package installation)
|
|
|
|
# purge remaining files
|
|
|
|
if [[ -n "$(dpkg-query --status grafana | grep -E "Status|deinstall")" ]] ; then
|
|
|
|
sudo dpkg --purge grafana
|
2019-01-13 18:51:59 +01:00
|
|
|
sudo rm $GRAFANA_REPOSITORY
|
2017-02-18 16:45:43 +01:00
|
|
|
fi
|
|
|
|
if [[ -n "$(dpkg-query --status influxdb | grep -E "Status|deinstall")" ]] ; then
|
|
|
|
sudo dpkg --purge influxdb
|
|
|
|
fi
|
|
|
|
|
2017-08-03 07:38:57 +02:00
|
|
|
# Remove services from YunoHost monitoring
|
|
|
|
sudo yunohost service remove influxdb
|
|
|
|
sudo yunohost service remove grafana-server
|
|
|
|
|
2017-02-18 16:45:43 +01:00
|
|
|
# If NetData is installed, configure it not to feed InfluxDB any more
|
|
|
|
netdata_conf="/opt/netdata/etc/netdata/netdata.conf"
|
|
|
|
if [[ -f "$netdata_conf" ]] ; then
|
|
|
|
sudo sed -i '/^\[backend\]$/,/^\[/ {
|
|
|
|
s/enabled = yes/# enabled = no/
|
|
|
|
s/type = opentsdb/# type = graphite/
|
|
|
|
s/destination = localhost:4242/# destination = localhost/
|
2019-01-13 18:51:59 +01:00
|
|
|
s/update every = 60/# update every = 10/
|
2017-02-18 16:45:43 +01:00
|
|
|
}' $netdata_conf
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Remove nginx configuration file
|
|
|
|
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
sudo rm -rf /home/yunohost.app/$app
|
|
|
|
|
|
|
|
# Drop MySQL database and user
|
|
|
|
dbname=$app
|
|
|
|
dbuser=$app
|
|
|
|
ynh_mysql_drop_db "$dbname" || true
|
|
|
|
ynh_mysql_drop_user "$dbuser" || true
|
|
|
|
|
|
|
|
|
|
|
|
# Reload nginx service
|
2017-03-12 12:40:26 +01:00
|
|
|
sudo systemctl reload nginx
|