1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mailman3_ynh.git synced 2024-09-03 19:36:17 +02:00
mailman3_ynh/scripts/remove
2021-08-25 03:39:10 +02:00

105 lines
3.7 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
db_name_app=$(ynh_app_setting_get --app=$app --key=db_name_app)
db_user_app=$db_name_app
db_name_web=$(ynh_app_setting_get --app=$app --key=db_name_web)
db_user_web=$db_name_web
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service integration..."
yunohost service remove $app
fi
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app-web service integration..."
yunohost service remove "$app-web"
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config
ynh_systemd_action --service_name=$app --action="stop"
systemctl disable $app.service --quiet
ynh_systemd_action --service_name="$app-web" --action="stop"
systemctl disable "$app-web".service --quiet
#=================================================
# REMOVE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Removing the PostgreSQL database..."
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$db_user_app --db_name=$db_name_app
ynh_psql_remove_db --db_user=$db_user_web --db_name=$db_name_web
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..."
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..."
ynh_secure_remove --file="/usr/share/mailman3-web"
# Remove a directory securely
ynh_secure_remove --file="/etc/$app"
# Remove hook for postfix conf
ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/98-postfix_mailman3"
yunohost tools regen-conf postfix
ynh_systemd_action --service_name=postfix --action="restart"
#=================================================
# GENERIC FINALIZATION
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed"