This commit is contained in:
oliver committed 2026-09-27 10:39:39 -03:00
1 parent 2e9c775599
commit 9a59b2932a
10 files changed
+499

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
"$(dirname "$(realpath "${BASH_SOURCE[0]:-$0}")")/listModules" "$1"
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env python3
import csv
import sys
import zipfile
if len(sys.argv) < 2:
print("Usage: python3 check_odoo_version.py <dump.zip>")
sys.exit(1)
zip_path = sys.argv[1]
base_version = None
with zipfile.ZipFile(zip_path, 'r') as z:
# Assume there is only one .sql file in the zip
sql_files = [f for f in z.namelist() if f.endswith('.sql')]
if not sql_files:
print("No .sql file found in the zip.")
sys.exit(1)
sql_file_name = sql_files[0]
with z.open(sql_file_name, 'r') as f:
# Decode bytes to string
lines = (line.decode('utf-8') for line in f)
# Skip lines until COPY command
for line in lines:
if line.startswith("COPY public.ir_module_module"):
break
# Read the COPY data until the terminator '\.'
reader = csv.reader(lines, delimiter='\t', quotechar='"', escapechar='\\')
for row in reader:
if row == ['\\.']: # End of COPY
break
if len(row) < 12:
continue
module_name = row[7].strip() # 8th column = name
if module_name == "base":
base_version = row[11].strip() # 12th column = latest_version
break
if base_version:
print(base_version.split(".")[0])
else:
print("Base module not found in dump.")
+31
View File
@@ -0,0 +1,31 @@
#!/bin/bash
# Create the tmp directory if it doesn't exist
mkdir -p /4server/tmp/
# Save original stdout
exec 3>&1
# Redirect all other output to log
exec > /4server/data/log/importDb.log 2>&1
echo "$(date '+%Y-%m-%d %H:%M') Import file $1"
# Generate random 8-digit filename
RANDOM_FILE="/4server/tmp/import_$(date '+%Y%m%d_%H%M').zip"
# Download file from Google Drive using gdown
gdown "$1" -O "$RANDOM_FILE"
# Execute dbVersion on the downloaded file and capture output
VERSION=$("$(dirname "$(realpath "${BASH_SOURCE[0]:-$0}")")/dbVersion" "$RANDOM_FILE")
# Output JSON to original stdout
cat <<EOF >&3
{
"version":"$VERSION",
"file":"$RANDOM_FILE"
}
EOF
# Close saved stdout
exec 3>&-
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash
export PATH=/4PROJECTS/bin:$PATH
CONTAINER_ID="$1"
_self="$(realpath "${BASH_SOURCE[0]:-$0}")"; SBIN_ROOT="$(dirname "$(dirname "$_self")")" # parent of ODOO/
source "$SBIN_ROOT/helpers"
[ -z "$CONTAINER_ID" ] && die "Usage: $0 <container_id>"
load_container_config "$CONTAINER_ID"
get_contract_info
DB_NAME="${DB_NAME:-$CONTAINER_ID}"
log "shell: CONTAINER_ID=$CONTAINER_ID DB_NAME=$DB_NAME"
doas docker exec -it "$CONTAINER_ID" odoo shell --db_host beedb --db_password="$ODOO_DB_PASSWORD" -d "$DB_NAME" --db_user="$DB_NAME"
+31
View File
@@ -0,0 +1,31 @@
#!/bin/bash
export PATH=/4PROJECTS/bin:$PATH
# --------------------------------------------------
# Validate parameter
# --------------------------------------------------
CONTAINER_ID="$1"
_self="$(realpath "${BASH_SOURCE[0]:-$0}")"; SBIN_ROOT="$(dirname "$(dirname "$_self")")" # parent of ODOO/
source "$SBIN_ROOT/helpers"
[ -z "$CONTAINER_ID" ] && die "Usage: $0 <container_id>"
load_container_config "$CONTAINER_ID"
get_contract_info
DB_NAME="${DB_NAME:-$CONTAINER_ID}"
doas docker ps -a --format "{{.Names}}" | grep -q "^${CONTAINER_ID}$" \
|| die "Container $CONTAINER_ID does not exist"
log "Updating all Odoo modules: DB=$DB_NAME host=$POSTGRES_HOST"
doas docker exec -u odoo "$CONTAINER_ID" odoo \
-u all \
-d "$DB_NAME" \
--stop-after-init \
--db_host="$POSTGRES_HOST" \
--db_port="$POSTGRES_PORT" \
--db_user="$POSTGRES_ADMIN_USER" \
--db_password="$POSTGRES_ADMIN_PASSWORD" \
|| die "Odoo module update failed for $CONTAINER_ID"
log "Module update complete — restarting $CONTAINER_ID"
"$SBIN_ROOT/startContainer" "$CONTAINER_ID"