This commit is contained in:
Oliver
2025-10-16 16:38:39 -03:00
parent 8ed294f3b7
commit 1808864021
14 changed files with 176 additions and 34 deletions

View File

@@ -15,6 +15,30 @@ if [[ -z "$UUID" ]]; then
exit 1
fi
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
echo "not_found"
return
fi
STATUS=$(docker inspect -f '{{.State.Status}}' "$CONTAINER_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
get_contract_info
# Extract the second part of UUID (split by "-")
@@ -34,3 +58,11 @@ case "$SECOND_PART" in
;;
esac
sqlite3 "/4server/data/contracts.db" <<SQL
DELETE FROM containers WHERE UUID='$UUID';
SQL
echo "Container $UUID successfully nuked."