This commit is contained in:
Oliver
2026-03-06 16:04:09 -03:00
parent 099dd17467
commit e3068f8925
12 changed files with 138 additions and 15 deletions

View File

@@ -1 +1 @@
meppel sydney

3
app/sbin/ODOO_19/audit Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
/4server/sbin/ODOO_19/listModules $1

60
app/sbin/ODOO_19/updateModules Executable file
View File

@@ -0,0 +1,60 @@
#!/bin/bash
export PATH=/4PROJECTS/bin:$PATH
# --------------------------------------------------
# Validate parameter
# --------------------------------------------------
if [ -z "$1" ]; then
echo "Missing Parameters <UUID>"
exit 1
fi
UUID=$1
# --------------------------------------------------
# Load environment helpers
# --------------------------------------------------
source /4server/sbin/helpers
if ! get_contract_info "$UUID"; then
echo "Error: Failed to load contract info for $UUID" >&2
exit 1
fi
# --------------------------------------------------
# Verify container exists
# --------------------------------------------------
if ! doas docker ps -a --format "{{.Names}}" | grep -q "^${UUID}$"; then
echo "Error: Container $UUID does not exist" >&2
exit 1
fi
echo "Updating all Odoo modules for database: $UUID"
echo "Using DB host: $POSTGRES_HOST"
# --------------------------------------------------
# Run Odoo update inside container
# --------------------------------------------------
if ! doas docker exec -u odoo "$UUID" odoo \
-u all \
-d "$UUID" \
--stop-after-init \
--db_host="$POSTGRES_HOST" \
--db_port="$POSTGRES_PORT" \
--db_user="$POSTGRES_ADMIN_USER" \
--db_password="$POSTGRES_ADMIN_PASSWORD"
then
echo "Error: Odoo module update failed for $UUID" >&2
exit 1
fi
echo "Module update completed successfully for $UUID"
# --------------------------------------------------
# Restart container
# --------------------------------------------------
echo "Starting container $UUID"
/4server/sbin/startContainer "$UUID"
echo "Done."
exit 0

View File

@@ -373,6 +373,12 @@ def add_git_key(request: AddKeyRequest):
return {"message": f"Key saved for container {request.uuid}", "file": file_path} return {"message": f"Key saved for container {request.uuid}", "file": file_path}
@app.get("/client/audit/{uuid}", dependencies=[Depends(verify_api_key)])
def audit_odoo(uuid: str):
return {"message": run_command([f"{BIN_PATH}/ODOO_19/listModules", uuid])}
@app.get("/client/logs/{uuid}", dependencies=[Depends(verify_api_key)]) @app.get("/client/logs/{uuid}", dependencies=[Depends(verify_api_key)])
async def get_odoo_log_summary(uuid: str): async def get_odoo_log_summary(uuid: str):
if not re.fullmatch(r"[0-9a-fA-F\-]+", uuid): if not re.fullmatch(r"[0-9a-fA-F\-]+", uuid):

View File

@@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
# Usage: ./start_by_uuid.sh <uuid> exec >> /4server/data/log/backupContainer_$1.log 2>&1
# Example: ./start_by_uuid.sh abc-001-xxxx-xxxx-xxxx
exec > /4server/data/log/backupContainer.log 2>&1
echo "$(date '+%Y-%m-%d %H:%M') Backup container $1" echo "$(date '+%Y-%m-%d %H:%M') Backup container $1"
source /4server/sbin/helpers source /4server/sbin/helpers
@@ -20,6 +18,8 @@ get_contract_info
# Extract the second part of UUID (split by "-") # Extract the second part of UUID (split by "-")
SECOND_PART=$(echo "$UUID" | cut -d'-' -f2) SECOND_PART=$(echo "$UUID" | cut -d'-' -f2)
echo "Conatiner Type $UUID"
# Decide which script to run # Decide which script to run
case "$SECOND_PART" in case "$SECOND_PART" in
001) 001)
@@ -40,4 +40,3 @@ case "$SECOND_PART" in
exit 2 exit 2
;; ;;
esac esac

View File

@@ -25,8 +25,15 @@ for dir in ???-???-*; do
/4server/sbin/ODOO_19/restore ${dir%/} $FILENAME /4server/sbin/ODOO_19/restore ${dir%/} $FILENAME
rm "${dir}/cc/restore" rm "${dir}/cc/restore"
fi fi
fi fi
if [ -d "${dir}/n8n" ]; then
if [ -f "${dir}/n8n/database.sqlite-journal" ]; then
echo "Restart N8N (journal)for: ${dir%/}"
/4server/sbin/startContainer ${dir%/}
fi
fi
done done
sleep 60 sleep 60

View File

@@ -21,12 +21,9 @@ done < <(sqlite3 "$DB_PATH" "
SELECT 'UUID=' || UUID FROM containers WHERE UUID='$UUID' SELECT 'UUID=' || UUID FROM containers WHERE UUID='$UUID'
UNION ALL SELECT 'EMAIL=' || email FROM containers WHERE UUID='$UUID' UNION ALL SELECT 'EMAIL=' || email FROM containers WHERE UUID='$UUID'
UNION ALL SELECT 'EXPIRES=' || expires FROM containers WHERE UUID='$UUID' UNION ALL SELECT 'EXPIRES=' || expires FROM containers WHERE UUID='$UUID'
UNION ALL SELECT 'TAGS=' || tags FROM containers WHERE UUID='$UUID' UNION ALL SELECT 'TAGS=' || replace(replace(tags, char(10), ''), char(13), '') FROM containers WHERE UUID='$UUID'
UNION ALL SELECT 'ENV=' || env FROM containers WHERE UUID='$UUID' UNION ALL SELECT 'ENV=' || replace(replace(env, char(10), ''), char(13), '') FROM containers WHERE UUID='$UUID'
UNION ALL SELECT 'AFFILIATE=' || affiliate FROM containers WHERE UUID='$UUID'
UNION ALL SELECT 'IMAGE=' || image FROM containers WHERE UUID='$UUID' UNION ALL SELECT 'IMAGE=' || image FROM containers WHERE UUID='$UUID'
UNION ALL SELECT 'HISTORY=' || history FROM containers WHERE UUID='$UUID'
UNION ALL SELECT 'COMMENT=' || comment FROM containers WHERE UUID='$UUID'
UNION ALL SELECT 'DOMAINS=' || domains FROM containers WHERE UUID='$UUID' UNION ALL SELECT 'DOMAINS=' || domains FROM containers WHERE UUID='$UUID'
UNION ALL SELECT 'STATUS=' || status FROM containers WHERE UUID='$UUID' UNION ALL SELECT 'STATUS=' || status FROM containers WHERE UUID='$UUID'
UNION ALL SELECT 'CREATED=' || created FROM containers WHERE UUID='$UUID' UNION ALL SELECT 'CREATED=' || created FROM containers WHERE UUID='$UUID'

View File

@@ -64,10 +64,15 @@ find "$BASEURL" -type d -exec chmod 777 {} \;
PORT=$((CONTAINERDBID + 2200)) PORT=$((CONTAINERDBID + 2200))
echo "PORT $PORT" echo "PORT $PORT"
mkdir -p ${ETC_DIR} mkdir -p ${ETC_DIR}
chmod 777 ${ETC_DIR}
echo "GITPATH ${ETC_DIR}gitpath" echo "GITPATH ${ETC_DIR}gitpath"
touch ${ETC_DIR}gitpath touch ${ETC_DIR}gitpath
mkdir -p ${BACKUP_DIR}
chmod 777 ${BACKUP_DIR}
mkdir -p ${GIT_DIR}keys mkdir -p ${GIT_DIR}keys
chmod 777 ${GIT_DIR}
touch ${GIT_DIR}keys/id_rsa.pub touch ${GIT_DIR}keys/id_rsa.pub
@@ -114,7 +119,7 @@ docker run -d --name "$UUID" \
docker exec $UUID chown -R odoo:odoo /home/odoo/.local docker exec $UUID chown -R odoo:odoo /home/odoo/.local
docker exec $UUID chown -R odoo:odoo /mnt/* docker exec $UUID chown -R odoo:odoo /mnt/*
docker exec $UUID chown odoo:odoo /git-server/keys/id_rsa.pub docker exec $UUID chown -R odoo:odoo /git-server
chmod 777 /4server/data/$UUID/cc chmod 777 /4server/data/$UUID/cc
check_and_create_db check_and_create_db

View File

@@ -10,14 +10,14 @@ LABEL virt
MENU LABEL Linux virt MENU LABEL Linux virt
LINUX vmlinuz-virt LINUX vmlinuz-virt
INITRD initramfs-virt INITRD initramfs-virt
APPEND root=LABEL=/ modules=sd-mod,usb-storage,ext4 console=ttyS0,115200n8 console=ttyAMA0,115200n8 APPEND root=UUID=15665bb5-c475-4ac8-9479-d49df97d5ccb modules=sd-mod,usb-storage,ext4 console=ttyS0,115200n8 console=ttyAMA0,115200n8
LABEL lts LABEL lts
MENU DEFAULT MENU DEFAULT
MENU LABEL Linux lts MENU LABEL Linux lts
LINUX vmlinuz-lts LINUX vmlinuz-lts
INITRD initramfs-lts INITRD initramfs-lts
APPEND root=LABEL=/ modules=sd-mod,usb-storage,ext4 console=ttyS0,115200n8 console=ttyAMA0,115200n8 APPEND root=UUID=15665bb5-c475-4ac8-9479-d49df97d5ccb modules=sd-mod,usb-storage,ext4 console=ttyS0,115200n8 console=ttyAMA0,115200n8
MENU SEPARATOR MENU SEPARATOR

View File

@@ -0,0 +1,23 @@
SERIAL ttyS0 115200
DEFAULT menu.c32
PROMPT 0
MENU TITLE Alpine/Linux Boot Menu
MENU HIDDEN
MENU AUTOBOOT Alpine will be booted automatically in # seconds.
TIMEOUT 100
LABEL virt
MENU LABEL Linux virt
LINUX vmlinuz-virt
INITRD initramfs-virt
APPEND root=UUID=15665bb5-c475-4ac8-9479-d49df97d5ccb modules=sd-mod,usb-storage,ext4 console=ttyS0,115200n8 console=ttyAMA0,115200n8
LABEL lts
MENU DEFAULT
MENU LABEL Linux lts
LINUX vmlinuz-lts
INITRD initramfs-lts
APPEND root=UUID=15665bb5-c475-4ac8-9479-d49df97d5ccb modules=sd-mod,usb-storage,ext4 console=ttyS0,115200n8 console=ttyAMA0,115200n8
MENU SEPARATOR

View File

@@ -0,0 +1,23 @@
SERIAL ttyS0 115200
DEFAULT menu.c32
PROMPT 0
MENU TITLE Alpine/Linux Boot Menu
MENU HIDDEN
MENU AUTOBOOT Alpine will be booted automatically in # seconds.
TIMEOUT 100
LABEL virt
MENU LABEL Linux virt
LINUX vmlinuz-virt
INITRD initramfs-virt
APPEND root=LABEL=/ modules=sd-mod,usb-storage,ext4 console=ttyS0,115200n8 console=ttyAMA0,115200n8
LABEL lts
MENU DEFAULT
MENU LABEL Linux lts
LINUX vmlinuz-lts
INITRD initramfs-lts
APPEND root=LABEL=/ modules=sd-mod,usb-storage,ext4 console=ttyS0,115200n8 console=ttyAMA0,115200n8
MENU SEPARATOR

Binary file not shown.