Browse Source

new: [postgres] add support of ``--neutralize|-n`` option to ``load`` action

rallly
Valentin Lab 11 months ago
parent
commit
183dc8c965
  1. 39
      odoo-tecnativa/actions/load

39
odoo-tecnativa/actions/load

@ -30,12 +30,16 @@ EXAMPLES:
dbname=
neutralize=
while [ "$1" ]; do
case "$1" in
"--help"|"-h")
print_help >&2
exit 0
;;
"--neutralize"|"-n")
neutralize=yes
;;
"--force"|"-f")
force=yes
;;
@ -55,6 +59,10 @@ while [ "$1" ]; do
done
version:ge() { [ "$(printf '%s\n' "$@" | sort -rV | head -n 1)" == "$1" ]; }
version:lt() { ! version:ge "$@"; }
if [ -z "$dbname" ]; then
##
@ -82,6 +90,8 @@ fi
set -e
curl_opts=()
## Ensure odoo is launched
service_def=$(get_compose_service_def "$SERVICE_NAME")
@ -97,6 +107,34 @@ ADMIN_PASSWORD=$(echo "$service_def" | shyaml -q get-value options.admin-passwor
fi
}
containers="$(get_running_containers_for_service "$SERVICE_NAME")"
if [ -z "$containers" ]; then
err "No containers running for service $DARKYELLOW$SERVICE_NAME$NORMAL."
exit 1
fi
if [ "$(echo "$containers" | wc -l)" -gt 1 ]; then
err "More than 1 container running for service $DARKYELLOW$SERVICE_NAME$NORMAL."
echo " Please contact administrator to fix this issue." >&2
exit 1
fi
container="$(echo "$containers" | head -n 1)"
odoo_version=$(docker exec "$container" python -c 'import odoo.release; print(odoo.release.version)') || {
err "Failed to get odoo version."
exit 1
}
if version:lt "$odoo_version" "16.0" && [ -n "$neutralize" ]; then
err "Option \`\`--neutralize\`\` (or \`\`-n\`\`)" \
"is only available for odoo ${WHITE}16.0${NORMAL}+."
echo " Service ${DARKYELLOW}$SERVICE_NAME${NORMAL} is running odoo ${WHITE}$odoo_version${NORMAL}" >&2
exit 1
fi
if [ -n "$neutralize" ]; then
curl_opts+=(-F "neutralize_database=true")
fi
container_network_ip=$(get_healthy_container_ip_for_service "$SERVICE_NAME" 8069 4) || {
err "Please ensure that $DARKYELLOW$service$NORMAL is running before using '$exname'."
exit 1
@ -131,6 +169,7 @@ cmd=(
-F "master_pwd=${ADMIN_PASSWORD}"
-F "backup_file=@-"
-F "name=${dbname}"
"${curl_opts[@]}"
http://${container_ip}:8069/web/database/restore
)

Loading…
Cancel
Save