From 6a31249ae7c31b0d6ec6d7410e97810ca66f2898 Mon Sep 17 00:00:00 2001 From: ljf Date: Wed, 14 Dec 2016 10:10:53 +0100 Subject: [PATCH] [fix] Uncorrect remove file on failling setup --- scripts/install | 35 ++++------------------------------- scripts/remove | 13 ++++++++----- 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/scripts/install b/scripts/install index 81a119f..3a7c996 100644 --- a/scripts/install +++ b/scripts/install @@ -22,44 +22,16 @@ sudo yunohost app checkurl $domain -a $app \ # Remove trailing "/" for next commands domain=${domain%/} ynh_app_setting_set "$app" domain "$domain" -ynh_app_setting_set "$app" domain "$domain" -is_master=false - -# Exit to allow host change in my trap function -function exit_without_linter_warning -{ - ynh_die "$1" $2 -} - -function exit_properly -{ - - set +e - if [ "$is_master" = true ]; then - sudo rm -f /etc/apt/sources.list.d/odoo.list - sudo apt-get update - ynh_package_remove odoo - sudo rm -f /etc/odoo/openerp-server.conf - sudo yunohost service remove odoo - fi - # TODO: uninstall db - sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf - sudo service nginx reload - exit_without_linter_warning "Error during installation" 1 -} - -trap exit_properly ERR if [ -f /usr/bin/openerp-server ]; then echo "Odoo is already installed, switching to multi-instances" ynh_app_setting_set "$app" instance "slave" else - is_master=true sudo yunohost app checkport 8069 if [[ ! $? -eq 0 ]]; then - exit_without_linter_warning "Port 8069 unavailable" 1 + ynh_die "Port 8069 unavailable" 1 fi echo "Installing odoo" @@ -88,6 +60,7 @@ else ynh_package_install wkhtmltopdf # Set admin password + # TODO Support @ in password sudo sed -i "s@ADMIN_PASSWORD@$admin_password@g" ../conf/openerp-server.conf sudo sed -i "s@DATABASE_PASSWORD@$database_password@g" ../conf/openerp-server.conf sudo cp ../conf/openerp-server.conf /etc/odoo/openerp-server.conf @@ -123,6 +96,7 @@ ynh_psql_create_db() { } # Configure Nginx and reload +sed -i "s@#YNH_APP_INSTANCE_NAME#@${YNH_APP_INSTANCE_NAME}@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf # Make Odoo public @@ -144,6 +118,5 @@ sudo /usr/bin/openerp-server -c /etc/odoo/openerp-server.conf --stop-after-init #sudo sed -i "s@DATABASE_LANG@$lang@g" ../conf/install_database.py #sudo sed -i "s@DATABASE_PASSWORD@$database_password@g" ../conf/install_database.py #sudo python ../conf/install_database.py - +sudo service odoo restart # Setup LDAP: TO BE DONE -echo $? diff --git a/scripts/remove b/scripts/remove index eaa90a0..3fbc58a 100644 --- a/scripts/remove +++ b/scripts/remove @@ -11,18 +11,21 @@ domain=$(ynh_app_setting_get "$app" domain) database=${domain//./-} instance=$(ynh_app_setting_get "$app" instance) -# Remove database -sudo su -c "dropdb $database" postgres # If removing master instance, remove Odoo. if [ "$instance" = "master" ]; then - # Remove Odoo + sudo rm -f /etc/apt/sources.list.d/odoo.list + sudo apt-get update sudo yunohost service stop odoo - sudo apt-get remove odoo -y - sudo apt-get remove wkhtmltopdf -y + ynh_package_remove odoo + ynh_package_remove wkhtmltopdf + sudo rm -f /etc/odoo/openerp-server.conf sudo yunohost service remove odoo fi +# Remove database +sudo su -c "dropdb $database" postgres + # Remove NGINX conf sudo rm /etc/nginx/conf.d/$domain.d/$app.conf