mirror of
https://github.com/YunoHost-Apps/dokuwiki_ynh.git
synced 2024-09-03 18:26:20 +02:00
[enh] refactor 'remove' script to best practices
This commit is contained in:
parent
42a170b60c
commit
bdf0f77c19
1 changed files with 72 additions and 20 deletions
|
@ -1,30 +1,82 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
set -u
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
||||
# Get multi-instances specific variables
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Loads the generic functions usually used in the script
|
||||
source .fonctions
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
|
||||
# Retrieve app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
|
||||
# Delete app directory and configurations
|
||||
sudo rm -rf "/var/www/${app}"
|
||||
sudo rm -f "/etc/php5/fpm/pool.d/${app}.conf"
|
||||
sudo rm -f "/etc/php5/fpm/conf.d/20-${app}.ini"
|
||||
[[ -n $domain ]] && sudo rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
|
||||
# Reload services
|
||||
sudo systemctl reload php5-fpm
|
||||
sudo systemctl reload nginx
|
||||
#=================================================
|
||||
# REMOVE SERVICE FROM ADMIN PANEL
|
||||
#=================================================
|
||||
|
||||
# Delete system user dedicace for this app
|
||||
if yunohost service status | grep -q $app
|
||||
then
|
||||
echo "Remove $app service"
|
||||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
|
||||
# Remove the log files
|
||||
ynh_secure_remove "/var/log/$app/"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete $app
|
||||
|
||||
echo -e "\e[0m" # Restore normal color
|
Loading…
Add table
Reference in a new issue