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

55 lines
1.2 KiB
Text
Raw Normal View History

2015-09-14 17:12:17 +02:00
#!/bin/bash
2017-05-18 23:28:18 +02:00
set -u
2016-07-05 15:22:12 +02:00
2017-05-18 23:28:18 +02:00
source /usr/share/yunohost/helpers
source _future.sh
source _common.sh
2017-05-18 23:28:18 +02:00
app=$YNH_APP_INSTANCE_NAME
2016-07-05 15:22:12 +02:00
# Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain)
2017-05-18 23:28:18 +02:00
odoo_version=$(ynh_app_setting_get "$app" odoo_version)
if [ "$odoo_version" = "" ]; then
exit 0
fi
2015-09-20 08:34:07 +02:00
database=${domain//./-}
2017-05-18 23:28:18 +02:00
is_master=$(ynh_app_setting_get "$app" is_master)
2015-09-14 17:12:17 +02:00
2017-05-18 23:28:18 +02:00
define_paths
2015-09-16 13:00:17 +02:00
2017-05-18 23:28:18 +02:00
yunohost service stop odoo
list=$(yunohost app list --installed | grep odoo)
2015-09-16 13:00:17 +02:00
# If removing master instance, remove Odoo.
2017-05-18 23:28:18 +02:00
if [ $(echo $list | wc -l) = 1 ]; then
rm -f /etc/apt/sources.list.d/odoo.list
apt-get update
yunohost service remove odoo
ynh_psql_drop_db $APPNAME
#ynh_psql_drop_user $APPNAME
else
# Set another app as master
if [ "$is_master" = "true" ]; then
for instance in $list; do
if [ "$instance" != "$app" ]; then
ynh_app_setting_set "$instance" is_master "true"
break
fi
done
is_master="false"
fi
2016-07-05 15:22:12 +02:00
fi
2017-05-18 23:28:18 +02:00
ynh_remove_app_dependencies
# Remove database
2017-05-18 23:28:18 +02:00
ynh_psql_drop_db $database
2017-05-18 23:28:18 +02:00
if [ "$is_master" = "false" ]; then
yunohost service start odoo
2016-12-14 11:04:44 +01:00
fi
2015-09-14 17:12:17 +02:00
2017-05-18 23:28:18 +02:00
# Remove NGINX conf
ynh_rm_nginx_conf