1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/nodebb_ynh.git synced 2024-09-03 19:46:29 +02:00

Update remove

This commit is contained in:
frju365 2018-03-11 12:42:46 +01:00 committed by GitHub
parent 7f3373e648
commit 936f2b78d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,34 +1,102 @@
#!/bin/bash #!/bin/bash
# Source app helpers #=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Exit on command errors and treat unset variables as an error #=================================================
set -u # LOAD SETTINGS
set -eu #=================================================
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
# Retrieve app settings
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
port=$(ynh_app_setting_get $app port)
dbname=$(ynh_app_setting_get $app dbname)
dbuser=$dbname
final_path=$(ynh_app_setting_get $app final_path)
sudo systemctl stop $app.service #=================================================
# STANDARD REMOVE
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
# Remove sources # Remove the dedicated systemd config
sudo rm -rf /var/www/$app ynh_remove_systemd_config
# Remove nginx configuration file #=================================================
[[ -n $domain ]] && sudo rm -f /etc/nginx/conf.d/${domain}.d/${app}.conf # REMOVE SERVICE FROM ADMIN PANEL
#=================================================
# Remove haste user and data if yunohost service status | grep -q $app
sudo userdel -r $app then
echo "Remove $app service"
yunohost service remove $app
fi
# Remove init script #=================================================
sudo systemctl disable $app.service # REMOVE DEPENDENCIES
sudo rm -f /etc/systemd/system/$app.service #=================================================
sudo systemctl daemon-reload
# Remove monitor # Remove metapackage and its dependencies
sudo yunohost service remove $app ynh_remove_app_dependencies
# Reload nginx service #=================================================
sudo systemctl reload nginx.service # REMOVE THE MONGO DATABASE
#=================================================
mongo --shell "$dbname" --eval 'db.dropUser('dbuser');' <<< exit
mongo --shell "$dbname" --eval 'db.dropDatabase();' <<< exit
#=================================================
# 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 PHP-FPM CONFIGURATION
#=================================================
# Remove the dedicated php-fpm config
#ynh_remove_fpm_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# CLOSE A PORT
#=================================================
if yunohost firewall list | grep -q "\- $port$"
then
echo "Close port $port"
yunohost firewall disallow TCP $port 2>&1
fi
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
# Delete a system user
ynh_system_user_delete $app