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

40 lines
1.1 KiB
Bash

#!/bin/bash
# Get multi-instances specific variables
app=$YNH_APP_INSTANCE_NAME
app_nb=$YNH_APP_INSTANCE_NUMBER
# Source app helpers
. /usr/share/yunohost/helpers
# Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain)
with_mysql=$(ynh_app_setting_get "$app" with_mysql)
user=$(ynh_app_setting_get "$app" user)
# Drop MySQL database and user as needed
if [[ $with_mysql -eq 1 ]]; then
dbname=$app
dbuser=$app
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
ynh_mysql_drop_db $dbname || true
ynh_mysql_drop_user $dbuser || true
fi
# Delete app directory and configurations
sudo rm -rf "/var/www/${app}"
sudo rm -f "/etc/php5/fpm/pool.d/${app}.conf"
[[ -n $domain ]] && sudo rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf"
# Remove custom SSH configuration
sudo sed -i "/##-> ${app}/,/##<- ${app}/d" /etc/ssh/sshd_config
# Reload services
sudo service php5-fpm restart || true
sudo service nginx reload || true
sudo systemctl reload sshd
# Remove the user account
id "$user" >/dev/null 2>&1 \
&& sudo deluser --quiet --force "$user" >/dev/null \
|| true