2017-04-08 00:06:50 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-03-11 12:42:46 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
2017-04-08 00:06:50 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2018-03-11 12:42:46 +01:00
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
|
|
|
|
2017-04-08 00:06:50 +02:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
2018-03-11 12:42:46 +01:00
|
|
|
port=$(ynh_app_setting_get $app port)
|
|
|
|
dbname=$(ynh_app_setting_get $app dbname)
|
2018-03-11 14:06:48 +01:00
|
|
|
dbpass=$(ynh_app_setting_get $app dbpass)
|
2018-03-11 12:42:46 +01:00
|
|
|
dbuser=$dbname
|
|
|
|
final_path=$(ynh_app_setting_get $app final_path)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD REMOVE
|
|
|
|
#=================================================
|
|
|
|
# STOP AND REMOVE SERVICE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Remove the dedicated systemd config
|
|
|
|
ynh_remove_systemd_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REMOVE SERVICE FROM ADMIN PANEL
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
if yunohost service status | grep -q $app
|
|
|
|
then
|
|
|
|
echo "Remove $app service"
|
|
|
|
yunohost service remove $app
|
|
|
|
fi
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REMOVE THE MONGO DATABASE
|
|
|
|
#=================================================
|
|
|
|
|
2019-01-06 01:14:42 +01:00
|
|
|
mongo --shell "$dbname" --eval 'db.dropUser("'${dbuser}'", {w: "majority", wtimeout: 5000})' <<< exit
|
2018-03-11 14:25:56 +01:00
|
|
|
mongo --shell "$dbname" --eval 'db.runCommand({dropDatabase: 1})' <<< exit
|
2018-03-11 12:42:46 +01:00
|
|
|
|
2018-03-11 13:54:44 +01:00
|
|
|
#=================================================
|
|
|
|
# REMOVE DEPENDENCIES
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Remove metapackage and its dependencies
|
|
|
|
ynh_remove_app_dependencies
|
|
|
|
|
2018-03-11 12:42:46 +01:00
|
|
|
#=================================================
|
|
|
|
# REMOVE APP MAIN DIR
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Remove the app directory securely
|
|
|
|
ynh_secure_remove "$final_path"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REMOVE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Remove the dedicated nginx config
|
|
|
|
ynh_remove_nginx_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REMOVE LOGROTATE CONFIGURATION
|
|
|
|
#=================================================
|
2017-04-08 00:06:50 +02:00
|
|
|
|
2018-03-11 12:42:46 +01:00
|
|
|
# Remove the app-specific logrotate config
|
|
|
|
ynh_remove_logrotate
|
2017-04-08 00:06:50 +02:00
|
|
|
|
2018-03-11 12:42:46 +01:00
|
|
|
#=================================================
|
|
|
|
# CLOSE A PORT
|
|
|
|
#=================================================
|
2017-04-08 00:06:50 +02:00
|
|
|
|
2018-03-11 12:42:46 +01:00
|
|
|
if yunohost firewall list | grep -q "\- $port$"
|
|
|
|
then
|
|
|
|
echo "Close port $port"
|
|
|
|
yunohost firewall disallow TCP $port 2>&1
|
|
|
|
fi
|
2017-04-08 00:06:50 +02:00
|
|
|
|
2018-03-11 12:42:46 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# REMOVE DEDICATED USER
|
|
|
|
#=================================================
|
2017-04-08 00:06:50 +02:00
|
|
|
|
2018-03-11 12:42:46 +01:00
|
|
|
# Delete a system user
|
|
|
|
ynh_system_user_delete $app
|