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:
parent
7f3373e648
commit
936f2b78d8
1 changed files with 88 additions and 20 deletions
108
scripts/remove
108
scripts/remove
|
@ -1,34 +1,102 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Source app helpers
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
set -u
|
||||
set -eu
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Retrieve app settings
|
||||
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
|
||||
sudo rm -rf /var/www/$app
|
||||
# Remove the dedicated systemd config
|
||||
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
|
||||
sudo userdel -r $app
|
||||
if yunohost service status | grep -q $app
|
||||
then
|
||||
echo "Remove $app service"
|
||||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
# Remove init script
|
||||
sudo systemctl disable $app.service
|
||||
sudo rm -f /etc/systemd/system/$app.service
|
||||
sudo systemctl daemon-reload
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
# Remove monitor
|
||||
sudo yunohost service remove $app
|
||||
# Remove metapackage and its dependencies
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue