wotking
This commit is contained in:
@@ -11,7 +11,7 @@ exec > /4server/data/log/importDb.log 2>&1
|
|||||||
echo "$(date '+%Y-%m-%d %H:%M') Import file $1"
|
echo "$(date '+%Y-%m-%d %H:%M') Import file $1"
|
||||||
|
|
||||||
# Generate random 8-digit filename
|
# Generate random 8-digit filename
|
||||||
RANDOM_FILE="/4server/tmp/$(printf "%08d" $((RANDOM % 100000000))).zip"
|
RANDOM_FILE="/4server/tmp/import_$(date '+%Y%m%d_%H%M').zip"
|
||||||
|
|
||||||
# Download file from Google Drive using gdown
|
# Download file from Google Drive using gdown
|
||||||
gdown "$1" -O "$RANDOM_FILE"
|
gdown "$1" -O "$RANDOM_FILE"
|
||||||
|
|||||||
30
app/sbin/ODOO_19/listModules
Executable file
30
app/sbin/ODOO_19/listModules
Executable file
@@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
export PATH=/4PROJECTS/bin:$PATH
|
||||||
|
if [ ! -n "$1" ]; then
|
||||||
|
echo "Missing Parameters <UUID>"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
UUID=$1
|
||||||
|
|
||||||
|
source /4server/sbin/helpers
|
||||||
|
|
||||||
|
get_contract_info
|
||||||
|
|
||||||
|
# Query installed Odoo modules and output as CSV (disable pager for non-interactive use)
|
||||||
|
PGPASSWORD="$POSTGRES_ADMIN_PASSWORD" PAGER= psql \
|
||||||
|
-h "$POSTGRES_HOST" \
|
||||||
|
-U "$POSTGRES_ADMIN_USER" \
|
||||||
|
-p "$POSTGRES_PORT" \
|
||||||
|
-d "$UUID" \
|
||||||
|
--csv \
|
||||||
|
-c "
|
||||||
|
SELECT
|
||||||
|
name,
|
||||||
|
latest_version,
|
||||||
|
author,
|
||||||
|
summary
|
||||||
|
FROM ir_module_module
|
||||||
|
WHERE state = 'installed'
|
||||||
|
ORDER BY name;
|
||||||
|
"
|
||||||
27
app/sbin/api
27
app/sbin/api
@@ -131,6 +131,10 @@ class MoveRequest(BaseModel):
|
|||||||
source: str
|
source: str
|
||||||
destination: str
|
destination: str
|
||||||
|
|
||||||
|
class AddKeyRequest(BaseModel):
|
||||||
|
key: str
|
||||||
|
uuid: str
|
||||||
|
|
||||||
|
|
||||||
# ---------------------- Routes ----------------------
|
# ---------------------- Routes ----------------------
|
||||||
@app.get("/", include_in_schema=False)
|
@app.get("/", include_in_schema=False)
|
||||||
@@ -209,7 +213,11 @@ def start_container(request: UUIDRequest):
|
|||||||
|
|
||||||
@app.post("/container/stop", dependencies=[Depends(verify_api_key)])
|
@app.post("/container/stop", dependencies=[Depends(verify_api_key)])
|
||||||
def stop_container(request: UUIDRequest):
|
def stop_container(request: UUIDRequest):
|
||||||
|
try:
|
||||||
return {"message": run_command([f"{BIN_PATH}/stopContainer", request.UUID])}
|
return {"message": run_command([f"{BIN_PATH}/stopContainer", request.UUID])}
|
||||||
|
except HTTPException:
|
||||||
|
# Command failed, but continue without error to the API
|
||||||
|
return {"message": "Container stop command executed (may have failed)"}
|
||||||
|
|
||||||
|
|
||||||
@app.post("/container/nuke", dependencies=[Depends(verify_api_key)])
|
@app.post("/container/nuke", dependencies=[Depends(verify_api_key)])
|
||||||
@@ -346,6 +354,25 @@ def git_tool(request: CommandRequest):
|
|||||||
output = run_command(command)
|
output = run_command(command)
|
||||||
return {"message": output}
|
return {"message": output}
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/client/addGitKey", dependencies=[Depends(verify_api_key)])
|
||||||
|
def add_git_key(request: AddKeyRequest):
|
||||||
|
if not request.key or not request.uuid:
|
||||||
|
raise HTTPException(status_code=400, detail="Key and uuid are required")
|
||||||
|
|
||||||
|
file_path = f"/4server/data/{request.uuid}/git-server/keys/id_rsa.pub"
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Ensure the directory exists
|
||||||
|
os.makedirs(os.path.dirname(file_path), exist_ok=True)
|
||||||
|
# Write the key to the file
|
||||||
|
with open(file_path, "w", encoding="utf-8") as f:
|
||||||
|
f.write(request.key)
|
||||||
|
except Exception as e:
|
||||||
|
raise HTTPException(status_code=500, detail=f"Failed to save key: {str(e)}")
|
||||||
|
|
||||||
|
return {"message": f"Key saved for container {request.uuid}", "file": file_path}
|
||||||
|
|
||||||
@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):
|
||||||
|
|||||||
18
app/sbin/backup/N8N
Executable file
18
app/sbin/backup/N8N
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail # Fail on error, undefined variables, and pipe errors
|
||||||
|
|
||||||
|
# Create backup filename
|
||||||
|
FILENAME="$(date +"%Y%m%d_%H%M").zip"
|
||||||
|
BACKUP_DIR="/BACKUP/$UUID"
|
||||||
|
mkdir -p "$BACKUP_DIR"
|
||||||
|
|
||||||
|
tar -czvf "$BACKUP_DIR/$FILENAME" -C "/4server/data" "$UUID"
|
||||||
|
|
||||||
|
# Remove old backups beyond the configured slots
|
||||||
|
ls -t "$BACKUP_DIR"/[0-9]*.zip 2>/dev/null | tail -n +$((BACKUP_SLOTS + 1)) | while read -r file; do
|
||||||
|
echo "Deleting old backup: $file"
|
||||||
|
doas rm -f "$file"
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
48
app/sbin/backup/ODOO_17
Executable file
48
app/sbin/backup/ODOO_17
Executable file
@@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Backup Odoo database script
|
||||||
|
# Author: Your Name
|
||||||
|
# Description: Dumps Odoo DB, manages backups, and sets permissions
|
||||||
|
|
||||||
|
set -euo pipefail # Fail on error, undefined variables, and pipe errors
|
||||||
|
|
||||||
|
# Load helper functions
|
||||||
|
source /4server/sbin/helpers
|
||||||
|
|
||||||
|
# Get contract info
|
||||||
|
get_contract_info
|
||||||
|
|
||||||
|
# Export Odoo database password
|
||||||
|
export ODOO_DB_PASSWORD
|
||||||
|
ODOO_DB_PASSWORD=$(echo "$SECRET" | jq -r '.psql')
|
||||||
|
|
||||||
|
# Display basic info
|
||||||
|
echo "UUID: $UUID"
|
||||||
|
echo "Backup slots: $BACKUP_SLOTS"
|
||||||
|
|
||||||
|
# Create backup filename
|
||||||
|
FILENAME="$(date +"%Y%m%d_%H%M").zip"
|
||||||
|
BACKUP_DIR="/BACKUP/$UUID"
|
||||||
|
|
||||||
|
# Ensure backup directory exists
|
||||||
|
mkdir -p "$BACKUP_DIR"
|
||||||
|
|
||||||
|
# Perform database dump using docker
|
||||||
|
doas docker exec "$UUID" odoo db \
|
||||||
|
--db_host beedb \
|
||||||
|
-r "$UUID" \
|
||||||
|
-w "$ODOO_DB_PASSWORD" \
|
||||||
|
--data-dir /home/odoo/.local/share/Odoo/ \
|
||||||
|
dump "$UUID" "/mnt/backup/$FILENAME"
|
||||||
|
|
||||||
|
# Set permissions for backup files
|
||||||
|
doas chmod 600 "$BACKUP_DIR"/*
|
||||||
|
doas docker exec "$UUID" chown odoo:odoo -R /mnt/backup
|
||||||
|
|
||||||
|
|
||||||
|
# Remove old backups beyond the configured slots
|
||||||
|
ls -t "$BACKUP_DIR"/[0-9]*.zip 2>/dev/null | tail -n +$((BACKUP_SLOTS + 1)) | while read -r file; do
|
||||||
|
echo "Deleting old backup: $file"
|
||||||
|
doas rm -f "$file"
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
48
app/sbin/backup/ODOO_18
Executable file
48
app/sbin/backup/ODOO_18
Executable file
@@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Backup Odoo database script
|
||||||
|
# Author: Your Name
|
||||||
|
# Description: Dumps Odoo DB, manages backups, and sets permissions
|
||||||
|
|
||||||
|
set -euo pipefail # Fail on error, undefined variables, and pipe errors
|
||||||
|
|
||||||
|
# Load helper functions
|
||||||
|
source /4server/sbin/helpers
|
||||||
|
|
||||||
|
# Get contract info
|
||||||
|
get_contract_info
|
||||||
|
|
||||||
|
# Export Odoo database password
|
||||||
|
export ODOO_DB_PASSWORD
|
||||||
|
ODOO_DB_PASSWORD=$(echo "$SECRET" | jq -r '.psql')
|
||||||
|
|
||||||
|
# Display basic info
|
||||||
|
echo "UUID: $UUID"
|
||||||
|
echo "Backup slots: $BACKUP_SLOTS"
|
||||||
|
|
||||||
|
# Create backup filename
|
||||||
|
FILENAME="$(date +"%Y%m%d_%H%M").zip"
|
||||||
|
BACKUP_DIR="/BACKUP/$UUID"
|
||||||
|
|
||||||
|
# Ensure backup directory exists
|
||||||
|
mkdir -p "$BACKUP_DIR"
|
||||||
|
|
||||||
|
# Perform database dump using docker
|
||||||
|
doas docker exec "$UUID" odoo db \
|
||||||
|
--db_host beedb \
|
||||||
|
-r "$UUID" \
|
||||||
|
-w "$ODOO_DB_PASSWORD" \
|
||||||
|
--data-dir /home/odoo/.local/share/Odoo/ \
|
||||||
|
dump "$UUID" "/mnt/backup/$FILENAME"
|
||||||
|
|
||||||
|
# Set permissions for backup files
|
||||||
|
doas chmod 600 "$BACKUP_DIR"/*
|
||||||
|
doas docker exec "$UUID" chown odoo:odoo -R /mnt/backup
|
||||||
|
|
||||||
|
|
||||||
|
# Remove old backups beyond the configured slots
|
||||||
|
ls -t "$BACKUP_DIR"/[0-9]*.zip 2>/dev/null | tail -n +$((BACKUP_SLOTS + 1)) | while read -r file; do
|
||||||
|
echo "Deleting old backup: $file"
|
||||||
|
doas rm -f "$file"
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
@@ -23,11 +23,18 @@ SECOND_PART=$(echo "$UUID" | cut -d'-' -f2)
|
|||||||
# Decide which script to run
|
# Decide which script to run
|
||||||
case "$SECOND_PART" in
|
case "$SECOND_PART" in
|
||||||
001)
|
001)
|
||||||
"$BIN_PATH/backup/n8n"
|
"$BIN_PATH/backup/N8N"
|
||||||
|
;;
|
||||||
|
002)
|
||||||
|
"$BIN_PATH/backup/ODOO_18"
|
||||||
;;
|
;;
|
||||||
003)
|
003)
|
||||||
"$BIN_PATH/backup/ODOO_19"
|
"$BIN_PATH/backup/ODOO_19"
|
||||||
;;
|
;;
|
||||||
|
004)
|
||||||
|
"$BIN_PATH/backup/ODOO_17"
|
||||||
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
echo "Unknown UUID type: $SECOND_PART"
|
echo "Unknown UUID type: $SECOND_PART"
|
||||||
exit 2
|
exit 2
|
||||||
|
|||||||
@@ -28,15 +28,27 @@ docker run -d \
|
|||||||
--cap-add=SYS_ADMIN \
|
--cap-add=SYS_ADMIN \
|
||||||
--security-opt seccomp=unconfined \
|
--security-opt seccomp=unconfined \
|
||||||
--restart=always \
|
--restart=always \
|
||||||
|
-e N8N_EMAIL_MODE=smtp \
|
||||||
|
-e N8N_SMTP_HOST="smtp.strato.de" \
|
||||||
|
-e N8N_SMTP_PORT=587 \
|
||||||
|
-e N8N_SMTP_USER="n8n@odoo4projects.com" \
|
||||||
|
-e N8N_SMTP_PASS="Airbus12N@N" \
|
||||||
|
-e N8N_SMTP_SENDER="n8n <n8n@odoo4projects.com>" \
|
||||||
|
-e N8N_SMTP_SSL=false \
|
||||||
-e N8N_HOST="${UUID}.odoo4projects.com" \
|
-e N8N_HOST="${UUID}.odoo4projects.com" \
|
||||||
-e N8N_PORT=5678 \
|
-e N8N_PORT=5678 \
|
||||||
-e N8N_PROTOCOL=https \
|
-e N8N_PROTOCOL=https \
|
||||||
|
-e N8N_FORMDATA_FILE_SIZE_MAX=3000 \
|
||||||
|
-e N8N_TRUST_PROXY=true \
|
||||||
-e NODE_ENV=production \
|
-e NODE_ENV=production \
|
||||||
|
-e EXECUTIONS_PRUNE=true \
|
||||||
|
-e EXECUTIONS_PRUNE_MAX_AGE=48 \
|
||||||
-e WEBHOOK_URL="https://${UUID}.odoo4projects.com/" \
|
-e WEBHOOK_URL="https://${UUID}.odoo4projects.com/" \
|
||||||
-e GENERIC_TIMEZONE="UTC-3" \
|
-e GENERIC_TIMEZONE="UTC-3" \
|
||||||
|
-e N8N_BLOCK_ENV_ACCESS_AND_PROCESS_INFORMATION=true \
|
||||||
-e N8N_CUSTOM_EXTENSIONS="/usr/local/share/n8n/custom" \
|
-e N8N_CUSTOM_EXTENSIONS="/usr/local/share/n8n/custom" \
|
||||||
-v "/4server/data/${UUID}/n8n:/home/node/.n8n" \
|
-v "/4server/data/${UUID}/n8n:/home/node/.n8n" \
|
||||||
-v "/4server/data/${UUID}/backup:/data" \
|
-v "/4server/data/${UUID}/data:/data" \
|
||||||
-v "/4server/data/${UUID}/backup:/backup" \
|
-v "/4server/data/${UUID}/backup:/backup" \
|
||||||
--label "traefik.enable=true" \
|
--label "traefik.enable=true" \
|
||||||
--label "traefik.http.routers.${UUID}.rule=Host(\`${UUID}.odoo4projects.com\`)" \
|
--label "traefik.http.routers.${UUID}.rule=Host(\`${UUID}.odoo4projects.com\`)" \
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user