Restore AppFactory scripts to stable versions

This commit is contained in:
2026-05-27 09:29:18 +02:00
parent b6ed79cc3f
commit 438c29e2e0
9 changed files with 88 additions and 254 deletions
+15 -50
View File
@@ -4,35 +4,24 @@ set -euo pipefail
APP_ID="${1:-}"
if [ -z "$APP_ID" ]; then
echo "Usage:"
echo " ./delete-app.sh <app-id>"
echo "Usage: ./delete-app.sh <app-id>"
exit 1
fi
CONFIG_FILE="/opt/appfactory/config/appfactory.env"
if [ -f "$CONFIG_FILE" ]; then
source "$CONFIG_FILE"
fi
APPFACTORY_DIR="${APPFACTORY_DIR:-/opt/appfactory}"
WORKSPACE_DIR="${WORKSPACE_DIR:-/home/jiri/workspace}"
source "$CONFIG_FILE"
COMPOSE_FILE="$APPFACTORY_DIR/deploy/apps-compose.yml"
CATALOG_FILE="$APPFACTORY_DIR/apps/catalog.yml"
CADDY_FILE="$APPFACTORY_DIR/gateway/Caddyfile"
TOOLS_DIR="$WORKSPACE_DIR/appfactory-tools"
echo "Deleting app: $APP_ID"
if [ -n "${GITEA_URL:-}" ] && [ -n "${GITEA_TOKEN:-}" ] && [ -n "${GITEA_ORG:-}" ]; then
echo "Deleting Gitea repository..."
curl -sS -X DELETE \
"$GITEA_URL/api/v1/repos/$GITEA_ORG/$APP_ID" \
-H "Authorization: token $GITEA_TOKEN" || true
fi
echo "Deleting Gitea repository..."
curl -sS -X DELETE \
"$GITEA_URL/api/v1/repos/$GITEA_ORG/$APP_ID" \
-H "Authorization: token $GITEA_TOKEN" || true
echo "Stopping container..."
docker rm -f "$APP_ID" || true
@@ -55,61 +44,37 @@ caddy_file = Path(sys.argv[4])
def remove_block(lines, predicate):
out = []
i = 0
while i < len(lines):
line = lines[i]
if predicate(line):
indent = len(line) - len(line.lstrip())
i += 1
while i < len(lines):
next_line = lines[i]
if next_line.strip():
next_indent = len(next_line) - len(next_line.lstrip())
if next_indent <= indent:
break
i += 1
continue
out.append(line)
i += 1
return out
if compose_file.exists():
compose_lines = compose_file.read_text().splitlines()
compose_lines = remove_block(
compose_lines,
lambda l: l.startswith(f" {app_id}:")
)
compose_file.write_text("\n".join(compose_lines) + "\n")
lines = compose_file.read_text().splitlines()
lines = remove_block(lines, lambda l: l.startswith(f" {app_id}:"))
compose_file.write_text("\n".join(lines).rstrip() + "\n")
if catalog_file.exists():
catalog_lines = catalog_file.read_text().splitlines()
catalog_lines = remove_block(
catalog_lines,
lambda l: l.strip() == f"- id: {app_id}"
)
catalog_file.write_text("\n".join(catalog_lines) + "\n")
lines = catalog_file.read_text().splitlines()
lines = remove_block(lines, lambda l: l.strip() == f"- id: {app_id}")
catalog_file.write_text("\n".join(lines).rstrip() + "\n")
if caddy_file.exists():
caddy_lines = caddy_file.read_text().splitlines()
caddy_lines = remove_block(
caddy_lines,
lambda l: f"/apps/{app_id}/*" in l
)
caddy_file.write_text("\n".join(caddy_lines) + "\n")
lines = caddy_file.read_text().splitlines()
lines = remove_block(lines, lambda l: f"/apps/{app_id}/*" in l)
caddy_file.write_text("\n".join(lines).rstrip() + "\n")
PY
echo "Regenerating generated files..."