1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/nextcloud_ynh.git synced 2024-09-03 19:55:57 +02:00
nextcloud_ynh/scripts/remove
2017-04-17 14:12:15 +02:00

50 lines
No EOL
1.2 KiB
Bash
Executable file

#!/bin/bash
# Load common variables and helpers
source ./_common.sh
# Source app helpers
source /usr/share/yunohost/helpers
# Set app specific variables
app=$YNH_APP_INSTANCE_NAME
dbname=$app
dbuser=$app
# Remove cron job
# TODO: Ensure that cron job is not running
sudo rm -f "/etc/cron.d/${app}"
# Drop MySQL database and user
ynh_mysql_drop_db "$dbname"
ynh_mysql_drop_user "$dbuser"
# Retrieve domain from app settings
domain=$(ynh_app_setting_get "$app" domain)
# Delete app directory and configurations
[[ "/var/www" =~ "/var/www/${app}" ]] \
|| (test -n "$app" && sudo rm -r "/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"
# Reload services
sudo service php5-fpm reload
sudo service nginx reload
# Remove app dependencies
ynh_package_autoremove "$DEPS_PKG_NAME"
# Clean home folders ACLs
for i in $(ls /home); do
[[ ! $i == yunohost.* ]] \
&& sudo setfacl -x g:$app:rwx >/dev/null 2>&1
done
# Remove the user account
id "$app" >/dev/null 2>&1 \
&& sudo deluser --quiet --remove-home "$app" >/dev/null
# Remove logrotate configuration
ynh_remove_logrotate