diff --git a/404_addons b/404_addons deleted file mode 100644 index 20bebd5..0000000 --- a/404_addons +++ /dev/null @@ -1,8 +0,0 @@ -account_balance_line -account_menu -account_statement_import -account_statement_import_file_reconciliation_widget -project_mail_chatter -project_timeline_task_dependency -web_drop_target -web_ir_actions_act_view_reload diff --git a/combined_addons b/combined_addons deleted file mode 100644 index ce08052..0000000 --- a/combined_addons +++ /dev/null @@ -1,32 +0,0 @@ -account_balance_line -account_menu -account_statement_import -account_statement_import_file_reconciliation_widget -project_mail_chatter -project_timeline_task_dependency -web_drop_target -web_ir_actions_act_view_reload -galicea_base -galicea_environment_checkup -mass_editing -mass_mailing_themes -muk_autovacuum -muk_fields_lobject -muk_fields_stream -muk_utils -muk_web_theme_mail -muk_web_utils -account_usability -kpi_dashboard -web_window_title -website_project_kanbanview -project_usability -project_tag -maintenance_server_monitoring_ping -maintenance_server_monitoring_ssh -maintenance_server_monitoring_memory -maintenance_server_monitoring_maintenance_equipment_status -maintenance_server_monitoring_disk -project_task_assignees_avatar -account_partner_reconcile -account_invoice_import_simple_pdf diff --git a/prepare_db.sh b/prepare_db.sh index b375e6a..14bb644 100755 --- a/prepare_db.sh +++ b/prepare_db.sh @@ -6,13 +6,6 @@ DB_NAME="$2" DB_FINALE_MODEL="$3" DB_FINALE_SERVICE="$4" -# Function to display the combined list of add-ons to uninstall -display_combined_list(){ - cat 404_addons force_uninstall_addons > combined_addons - echo "UPGRADE: Add-ons to uninstall (forced and not found in final Odoo version):" - cat combined_addons -} - # Function to ask if the add-ons list to uninstall is OK ask_confirmation() { while true; do @@ -20,27 +13,17 @@ ask_confirmation() { Do you accept to uninstall all these add-ons? (Y/N/R)" echo "Y - Yes, let's go on with the upgrade." echo "N - No, stop the upgrade" - echo "R - I've edited the list, please Re-display it" read -n 1 -p "Your choice: " choice case "$choice" in - [Yy] ) return 0;; - [Nn] ) return 1;; - [Rr] ) display_combined_list; continue;; - * ) echo "Please answer by Y, N or R.";; + [Yy] ) echo " +Upgrade confirmed!"; return 0;; + [Nn] ) echo " +Upgrade cancelled!"; return 1;; + * ) echo "Please answer by Y or N.";; esac done } -# Read names from file and create SQL commands -generate_sql_to_remove_commands() { - local name - local sql_commands="" - while IFS= read -r name; do - sql_commands+="UPDATE ir_module_module SET to_remove = TRUE WHERE name = '$name';" - done < combined_addons - echo "$sql_commands" -} - # Main execution echo "UPGRADE: Start database preparation" @@ -105,29 +88,35 @@ SQL_404_ADDONS_LIST=" echo "Retrieve 404 addons... " query_postgres_container "$SQL_404_ADDONS_LIST" "$DB_NAME" > 404_addons || exit 1 +# Create combined list of add-ons not found and add-ons which must be removed +cat 404_addons force_uninstall_addons | sort | uniq > combined_addons + +# Keep only the installed add-ons +INSTALLED_ADDONS="SELECT name FROM ir_module_module WHERE state='installed';" +query_postgres_container "$INSTALLED_ADDONS" "$DB_NAME" > installed_addons || exit 1 + +grep -Fx -f combined_addons installed_addons > addons_to_remove +rm -f 404_addons combined_addons installed_addons # Ask confirmation to uninstall the selected add-ons -display_combined_list - - -if ask_confirmation; then - echo "Upgrade goes on..." -else - echo "Upgrade stopped." - exit 1 -fi - - +echo " +==== FIRST CHECK ==== +Installed add-ons to uninstall (forced OR not found in final Odoo version): +" +cat addons_to_remove +ask_confirmation || exit 1 # Tag the selected add-ons as "to remove" echo "TAG the add-ons to remove..." SQL_TAG_TO_REMOVE="" while IFS= read -r name; do SQL_TAG_TO_REMOVE+="UPDATE ir_module_module SET to_remove = TRUE WHERE name = '$name' AND state = 'installed';" -done < combined_addons +done < addons_to_remove +echo $SQL_TAG_TO_REMOVE query_postgres_container "$SQL_TAG_TO_REMOVE" "$DB_NAME" || exit 1 echo "Add-ons to be removed TAGGED." +rm -f addons_to_remove # Identify the add-ons which depend on the add-on to uninstall echo "Detect and tag add-ons dependencies..." @@ -152,6 +141,15 @@ SQL_UPDATE_STATE="UPDATE ir_module_module SET state = 'to remove' WHERE to_remov query_postgres_container "$SQL_UPDATE_STATE" "$DB_NAME" || exit 1 echo "Add-ons to remove with state 'to remove'" +# Last check on all the add-ons to be removed +echo " +==== LAST CHECK! ==== +Here is the whole list of add-ons to be removed: +" +SQL_ADDONS_TO_BE_REMOVED="SELECT name from ir_module_module WHERE state='to remove';" +query_postgres_container "$SQL_ADDONS_TO_BE_REMOVED" "$DB_NAME" || exit 1 +ask_confirmation || exit 1 + # Launch Odooo container and launch the uninstall function echo "Launch Odoo to uninstall add-ons..."