update of an outadet approach of the user adding in the current version
This commit is contained in:
+7
-12
@@ -595,7 +595,7 @@ case "$COMMAND" in
|
|||||||
initialize_tenant_database "$TENANT_ID" "trial"
|
initialize_tenant_database "$TENANT_ID" "trial"
|
||||||
echo "Trial tenant '$TENANT_ID' successfully configured. It will expire after $DAYS_ARG day(s) and self-delete."
|
echo "Trial tenant '$TENANT_ID' successfully configured. It will expire after $DAYS_ARG day(s) and self-delete."
|
||||||
;;
|
;;
|
||||||
|
|
||||||
remove)
|
remove)
|
||||||
FORCE_REMOVE=false
|
FORCE_REMOVE=false
|
||||||
TENANT_ARG="${2:-}"
|
TENANT_ARG="${2:-}"
|
||||||
@@ -626,26 +626,21 @@ case "$COMMAND" in
|
|||||||
port_to_remove=""
|
port_to_remove=""
|
||||||
|
|
||||||
if [ -n "$APP_CONTAINER" ]; then
|
if [ -n "$APP_CONTAINER" ]; then
|
||||||
# Zuerst die MongoDB-Datenbank via PyMongo hart droppen (Erzwungenes Löschen)
|
# MongoDB-Datenbank via PyMongo direkt im Container droppen
|
||||||
docker exec -i "$APP_CONTAINER" python3 - "$TENANT_ID" << 'EOF' > /dev/null 2>&1
|
docker exec -i "$APP_CONTAINER" python3 -c '
|
||||||
import sys
|
import sys, os
|
||||||
import os
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import pymongo
|
import pymongo
|
||||||
tenant_id = sys.argv[1]
|
tenant_id = sys.argv[1]
|
||||||
|
mongo_uri = os.environ.get("MONGO_URI", "mongodb://localhost:27017/")
|
||||||
# MongoDB-URI aus der Umgebung holen oder Standard verwenden
|
|
||||||
mongo_uri = os.environ.get('MONGO_URI', 'mongodb://localhost:27017/')
|
|
||||||
client = pymongo.MongoClient(mongo_uri, serverSelectionTimeoutMS=2000)
|
client = pymongo.MongoClient(mongo_uri, serverSelectionTimeoutMS=2000)
|
||||||
|
|
||||||
db_name = f"inventar_{tenant_id}"
|
db_name = f"inventar_{tenant_id}"
|
||||||
if db_name in client.list_database_names():
|
if db_name in client.list_database_names():
|
||||||
client.drop_database(db_name)
|
client.drop_database(db_name)
|
||||||
print(f"Dropped database: {db_name}")
|
print(f"Dropped database: {db_name}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error dropping database: {e}", file=sys.stderr)
|
print(f"Error dropping database: {e}", file=sys.stderr)
|
||||||
EOF
|
' "$TENANT_ID" > /dev/null 2>&1
|
||||||
|
|
||||||
# Konfiguration und Port via Host-Funktion bereinigen und Port ermitteln
|
# Konfiguration und Port via Host-Funktion bereinigen und Port ermitteln
|
||||||
if port_to_remove="$(remove_tenant_port "$TENANT_ID" 2>/dev/null)"; then
|
if port_to_remove="$(remove_tenant_port "$TENANT_ID" 2>/dev/null)"; then
|
||||||
@@ -676,7 +671,7 @@ case "$COMMAND" in
|
|||||||
else
|
else
|
||||||
echo "Removed tenant '$TENANT_ID'. No port mapping was present."
|
echo "Removed tenant '$TENANT_ID'. No port mapping was present."
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
restart-tenant)
|
restart-tenant)
|
||||||
TENANT_ID="${2:-}"
|
TENANT_ID="${2:-}"
|
||||||
|
|||||||
Reference in New Issue
Block a user