initial commit
This commit is contained in:
33
scripts/odoo/init-odoo.sh
Executable file
33
scripts/odoo/init-odoo.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "Checking if Odoo DB '$DB_NAME' exists and base module is installed..."
|
||||
retries=0
|
||||
max_retries=10
|
||||
|
||||
install_base_via_odoo() {
|
||||
echo "Installing base module into '$DB_NAME' via Odoo CLI"
|
||||
# Use --stop-after-init so the command exits after installing
|
||||
if odoo -d "$DB_NAME" -i base --stop-after-init --db_host="$HOST" --db_user="$USER" --db_password="$PASSWORD"; then
|
||||
echo "Base module installed successfully"
|
||||
return 0
|
||||
fi
|
||||
echo "Failed to install base module via Odoo CLI"
|
||||
return 1
|
||||
}
|
||||
|
||||
while true; do
|
||||
# Try to install base into the DB. If the DB exists and base is already
|
||||
# installed this will succeed or be a no-op. If the DB doesn't exist
|
||||
# the command will fail and we'll proceed to initialize it.
|
||||
if install_base_via_odoo; then
|
||||
echo "Odoo DB '$DB_NAME' is ready with base module installed."
|
||||
break
|
||||
fi
|
||||
retries=$((retries+1))
|
||||
if [ "$retries" -ge "$max_retries" ]; then
|
||||
echo "Initialization failed after $retries attempts. Exiting with error."
|
||||
exit 1
|
||||
fi
|
||||
echo "Retry #$retries: waiting before next attempt..."
|
||||
sleep 2
|
||||
done
|
||||
Reference in New Issue
Block a user