You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

121 lines
3.8 KiB

#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
domain_dev=$(ynh_app_setting_get --app=$app --key=domain_dev)
domain_staging=$(ynh_app_setting_get --app=$app --key=domain_staging)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
cache=$(ynh_app_setting_get --app=$app --key=cache)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Removing the MySQL database..." --weight=2
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_name --db_name=$db_name
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..."
if [ $cache -eq 1 ]
then
sed -i "/fastcgi_cache_path/d" /etc/nginx/conf.d/$domain.conf
rm -r /var/run/nginx-cache/$app
fi
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2
# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config
#=================================================
# REMOVE PLUGIN CONFIGURATION
#=================================================
sed -i "/$app ALL=(root)/d" /etc/sudoers
#=================================================
# REMOVE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=8
# Remove the dedicated Fail2Ban config
ynh_remove_fail2ban_config
#=================================================
# REMOVE THE CRON
#=================================================
ynh_secure_remove /etc/cron.d/$app
#=================================================
# GENERIC FINALISATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=3
# Delete dedicated system user
ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================
app_dev=$(yunohost app map -r | grep -A2 $domain_dev | grep id: | sed "s/.*id: //")
if [ ! -z "$app_dev" ]; then
if [ -d /var/www/$app_dev ]; then
yunohost app remove $app_dev
fi
fi
app_staging=$(yunohost app map -r | grep -A2 $domain_staging | grep id: | sed "s/.*id: //")
if [ ! -z "$app_staging" ]; then
if [ -d /var/www/$app_staging ]; then
yunohost app remove $app_staging
fi
fi
# TODO
rm /etc/nginx/conf.d/fastcgi.conf
systemctl reload nginx
#if [[ ! $(ls -A /etc/nginx/conf.d/fastcgi.conf-*) ]]; then
#rm /etc/nginx/conf.d/fastcgi.conf
#fi
ynh_script_progression --message="Removal of $app completed" --last