33 lines
1.1 KiB
Bash
Executable File
33 lines
1.1 KiB
Bash
Executable File
#!/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 |