|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# #!/usr/bin/env python3 |
| 4 | +# """ |
| 5 | +# Update Odoo module |
| 6 | +# |
| 7 | +# This script proceed to a manual update of one or more Odoo modules in the database. |
| 8 | +# |
| 9 | +# NOTE: this command is handy to quickly test updates during some development iterations, |
| 10 | +# however keep in mind that on Odoo.sh the convention is to increase a module's |
| 11 | +# version number in it's manifest file whenever the committed changes requires |
| 12 | +# a database upgrade. Please refer to the documentation for more details: |
| 13 | +# https://www.odoo.sh/doc/getting_started/branches.html#production |
| 14 | +# |
| 15 | +# |
| 16 | +# Usage: |
| 17 | +# odoo-update [--help] <module> |
| 18 | +# |
| 19 | +# Options: |
| 20 | +# -h, --help Show this screen and exit. |
| 21 | +# <module> Module list to update separated by comma. |
| 22 | +# Use 'all' as module name to update all modules at once. |
| 23 | +# """ |
| 24 | +# import os |
| 25 | +# import sys |
| 26 | +# import docopt |
| 27 | +# argv = sys.argv[1:] or ['-h'] |
| 28 | +# args = docopt.docopt(__doc__, argv=argv) |
| 29 | +# cmd = ['/opt/odoo.sh/odoosh/bin/odoo-bin', '-u', args['<module>'], '--stop-after-init', '--no-http'] |
| 30 | +# os.execv(cmd[0], cmd) |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | +# Check if a database name is provided |
| 35 | +if [ -z "$1" ]; then |
| 36 | + echo "⚠️ Please provide the database name as an argument." |
| 37 | + echo "Usage:" |
| 38 | + echo " odoo-update my_database" |
| 39 | + exit 1 |
| 40 | +fi |
| 41 | + |
| 42 | + |
| 43 | +CMD="/var/lib/odoo/odoo-bin" |
| 44 | +DB_NAME="$1" |
| 45 | +# Path to the Odoo configuration file (change this if needed) |
| 46 | +CONFIG_FILE="/etc/odoo/odoo.conf" |
| 47 | +GLOBAL_OPTIONS="--stop-after-init --without-demo=all --no-http" |
| 48 | + |
| 49 | + |
| 50 | +# Run the update |
| 51 | +echo "🚀 Updating database: $DB_NAME ..." |
| 52 | +$CMD -c "$CONFIG_FILE" -d "$DB_NAME" -u all $GLOBAL_OPTIONS |
| 53 | + |
| 54 | +# Check the result |
| 55 | +if [ $? -eq 0 ]; then |
| 56 | + echo "✅ Update completed successfully." |
| 57 | +else |
| 58 | + echo "❌ An error occurred during the update." |
| 59 | +fi |
| 60 | + |
| 61 | + |
| 62 | + |
0 commit comments