libreerp_ynh/scripts/remove
2016-12-14 12:47:31 +01:00

42 lines
941 B
Bash

#!/bin/bash
set -eu
app=$YNH_APP_INSTANCE_NAME
# Load common variables
source ./_common.sh
# Source YunoHost helpers
. /usr/share/yunohost/helpers
# Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain)
database=${domain//./-}
instance=$(ynh_app_setting_get "$app" instance)
sudo yunohost service stop odoo | true
# If removing master instance, remove Odoo.
if [ "$instance" = "master" ]; then
sudo rm -f /etc/apt/sources.list.d/odoo.list
sudo apt-get update
sudo yunohost service remove odoo | true
ynh_package_remove odoo | true
sudo dpkg -P odoo | true
ynh_psql_drop_db $APPNAME | true
fi
# Remove database
ynh_psql_drop_db $database | true
ynh_psql_drop_user $database | true
if [ "$instance" = "slave" ]; then
sudo yunohost service start odoo | true
fi
# Remove NGINX conf
sudo rm /etc/nginx/conf.d/$domain.d/$app.conf | true
# Reload
sudo service nginx reload
sudo yunohost app ssowatconf