This commit is contained in:
oliver committed 2026-09-27 10:39:11 -03:00
1 parent d3d9614825
commit 2e9c775599
34 files changed
+390 -1833

No files matched your search

+20 -39
View File
@@ -1,68 +1,49 @@
#!/bin/bash
# Usage: ./start_by_uuid.sh <uuid>
# Example: ./start_by_uuid.sh abc-001-xxxx-xxxx-xxxx
exec > /4server/data/log/nukeContainer.log 2>&1
echo "$(date '+%Y-%m-%d %H:%M') Nuke container $1"
source /4server/sbin/helpers
_self="$(realpath "${BASH_SOURCE[0]:-$0}")"; SBIN="$(dirname "$_self")"
source "$SBIN/helpers"
BIN_PATH="/4server/sbin"
BIN_PATH="$SBIN"
CONTAINER_ID="$1"
UUID="$1"
if [[ -z "$UUID" ]]; then
echo "Usage: $0 <uuid>"
exit 1
fi
[ -z "$CONTAINER_ID" ] && die "Usage: $0 <uuid>"
log "Nuke container $CONTAINER_ID"
get_container_status() {
local uuid="$1"
# Get the container ID or name matching the UUID
CONTAINER_ID=$(docker ps -a --filter "name=$uuid" --format "{{.ID}}")
if [[ -z "$CONTAINER_ID" ]]; then
local container_id="$1"
# Get the Docker container ID or name matching the container_id
DOCKER_ID=$(docker ps -a --filter "name=$container_id" --format "{{.ID}}")
if [[ -z "$DOCKER_ID" ]]; then
echo "not_found"
return
fi
STATUS=$(docker inspect -f '{{.State.Status}}' "$CONTAINER_ID")
STATUS=$(docker inspect -f '{{.State.Status}}' "$DOCKER_ID")
echo "$STATUS"
}
# Check if container exists
STATUS=$(get_container_status "$UUID")
if [[ "$STATUS" == "running" ]]; then
echo "Container $UUID is still running. Aborting deletion."
exit 2
fi
STATUS=$(get_container_status "$CONTAINER_ID")
[ "$STATUS" = "running" ] && die "Container $CONTAINER_ID is still running — stop it first"
load_container_config "$CONTAINER_ID"
get_contract_info
# Extract the second part of UUID (split by "-")
SECOND_PART=$(echo "$UUID" | cut -d'-' -f2)
# Decide which script to run
case "$SECOND_PART" in
001)
case "$SOFTWARE" in
n8n)
"$BIN_PATH/nuke/n8n"
;;
002)
"$BIN_PATH/nuke/ODOO_19"
ODOO_17|ODOO_18|ODOO_19)
"$BIN_PATH/nuke/odoo"
;;
*)
echo "Unknown UUID type: $SECOND_PART"
exit 2
die "Unknown SOFTWARE type '${SOFTWARE}' for container_id $CONTAINER_ID — run: initContainer $CONTAINER_ID <n8n|ODOO_17|ODOO_18|ODOO_19>"
;;
esac
#sqlite3 "/4server/data/contracts.db" <<SQL
#DELETE FROM containers WHERE UUID='$UUID';
#SQL
echo "Container $UUID successfully nuked."
log "Container $CONTAINER_ID successfully nuked."