2015-10-21 13:03:49 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-10-10 14:09:26 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2021-01-11 23:46:48 +01:00
|
|
|
source _common.sh
|
2017-02-04 19:20:51 +01:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2017-10-10 14:09:26 +02:00
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
|
|
|
|
2017-10-10 14:12:41 +02:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2021-01-11 23:46:48 +01:00
|
|
|
|
|
|
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
|
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
|
|
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|
|
|
db_user=$db_name
|
|
|
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
2021-09-16 11:39:20 +02:00
|
|
|
data_path=$(ynh_app_setting_get --app=$app --key=data_path)
|
2015-10-21 13:03:49 +02:00
|
|
|
|
2017-10-10 14:09:26 +02:00
|
|
|
#=================================================
|
|
|
|
# STANDARD REMOVE
|
2020-02-08 23:34:06 +01:00
|
|
|
#=================================================
|
|
|
|
# REMOVE SERVICE FROM ADMIN PANEL
|
|
|
|
#=================================================
|
|
|
|
|
2021-03-17 20:59:57 +01:00
|
|
|
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
2021-01-11 23:46:48 +01:00
|
|
|
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
|
|
|
then
|
|
|
|
ynh_script_progression --message="Removing $app service..." --weight=1
|
|
|
|
yunohost service remove $app
|
2020-02-08 23:34:06 +01:00
|
|
|
fi
|
|
|
|
|
2017-10-10 14:09:26 +02:00
|
|
|
#=================================================
|
|
|
|
# STOP AND REMOVE SERVICE
|
|
|
|
#=================================================
|
2021-01-11 23:46:48 +01:00
|
|
|
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
|
2017-10-10 14:09:26 +02:00
|
|
|
|
2021-01-11 23:46:48 +01:00
|
|
|
# Remove the dedicated systemd config
|
2017-10-12 12:47:51 +02:00
|
|
|
ynh_remove_systemd_config
|
|
|
|
|
2017-10-10 14:09:26 +02:00
|
|
|
#=================================================
|
2021-01-13 11:31:12 +01:00
|
|
|
# REMOVE THE MySQL DATABASE
|
2017-10-10 14:09:26 +02:00
|
|
|
#=================================================
|
2021-01-11 23:46:48 +01:00
|
|
|
ynh_script_progression --message="Removing the MySQL database..." --weight=2
|
2015-10-21 13:03:49 +02:00
|
|
|
|
2021-01-11 23:46:48 +01:00
|
|
|
# Remove a database if it exists, along with the associated user
|
|
|
|
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
2015-10-21 13:03:49 +02:00
|
|
|
|
2017-10-10 14:09:26 +02:00
|
|
|
#=================================================
|
|
|
|
# REMOVE APP MAIN DIR
|
|
|
|
#=================================================
|
2021-01-11 23:46:48 +01:00
|
|
|
ynh_script_progression --message="Removing $app main directory..." --weight=6
|
|
|
|
|
|
|
|
# Remove the app directory securely
|
|
|
|
ynh_secure_remove --file="$final_path"
|
2015-10-31 16:51:08 +01:00
|
|
|
|
2021-10-03 11:24:09 +02:00
|
|
|
#=================================================
|
|
|
|
# REMOVE DATA DIR
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Remove the data directory if --purge option is used
|
|
|
|
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
|
|
|
|
then
|
|
|
|
ynh_script_progression --message="Removing app data directory..." --weight=1
|
|
|
|
ynh_secure_remove --file="$data_path"
|
|
|
|
fi
|
2017-10-10 14:09:26 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REMOVE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2021-01-11 23:46:48 +01:00
|
|
|
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=5
|
2015-10-21 14:33:49 +02:00
|
|
|
|
2021-01-11 23:46:48 +01:00
|
|
|
# Remove the dedicated NGINX config
|
2017-10-10 14:26:45 +02:00
|
|
|
ynh_remove_nginx_config
|
2015-10-21 14:33:49 +02:00
|
|
|
|
2021-01-11 23:46:48 +01:00
|
|
|
#=================================================
|
|
|
|
# REMOVE LOGROTATE CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
|
|
|
|
|
|
|
|
# Remove the app-specific logrotate config
|
|
|
|
ynh_remove_logrotate
|
|
|
|
|
2017-10-10 14:09:26 +02:00
|
|
|
#=================================================
|
|
|
|
# REMOVE LOG FILE
|
|
|
|
#=================================================
|
|
|
|
|
2021-01-11 23:46:48 +01:00
|
|
|
ynh_secure_remove --file="/var/log/$app"
|
2017-10-10 14:09:26 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REMOVE DEDICATED USER
|
|
|
|
#=================================================
|
2021-01-11 23:46:48 +01:00
|
|
|
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
|
|
|
|
|
|
|
ynh_system_user_delete --username=$app
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2017-10-10 14:09:26 +02:00
|
|
|
|
2021-01-11 23:46:48 +01:00
|
|
|
ynh_script_progression --message="Removal of $app completed" --last
|