53 lines
1.1 KiB
Bash
Executable File
53 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
set -euo pipefail
|
||
|
||
FILE="/opt/hx-ki/workspaces/homepage/homepage.json"
|
||
|
||
echo "=== Repair homepage.json ==="
|
||
|
||
if [[ ! -f "$FILE" ]]; then
|
||
echo "✘ homepage.json fehlt – wird neu erstellt."
|
||
cat > "$FILE" <<EOF2
|
||
{
|
||
"hero_title": "HX-KI – Repair Mode",
|
||
"hero_sub": "homepage.json war weg und wurde automatisch neu erstellt.",
|
||
"sections": [
|
||
{
|
||
"title": "Hinweis",
|
||
"text": "Dies ist ein Fallback-Content aus repair_homepage_json.sh."
|
||
}
|
||
]
|
||
}
|
||
EOF2
|
||
echo "✔ homepage.json neu angelegt."
|
||
exit 0
|
||
fi
|
||
|
||
# JSON grob prüfen (ohne jq, über Python)
|
||
python3 - <<PYEOF
|
||
import json, sys
|
||
try:
|
||
json.load(open("$FILE", "r"))
|
||
except Exception as e:
|
||
sys.exit(1)
|
||
PYEOF
|
||
|
||
if [[ $? -eq 0 ]]; then
|
||
echo "✔ homepage.json ist gültiges JSON."
|
||
else
|
||
echo "✘ homepage.json ist defekt – wird repariert."
|
||
cat > "$FILE" <<EOF3
|
||
{
|
||
"hero_title": "HX-KI – Repair Mode",
|
||
"hero_sub": "homepage.json war defekt und wurde automatisch repariert.",
|
||
"sections": [
|
||
{
|
||
"title": "Hinweis",
|
||
"text": "Der vorherige Inhalt war ungültig. Dies ist ein Fallback."
|
||
}
|
||
]
|
||
}
|
||
EOF3
|
||
echo "✔ homepage.json repariert."
|
||
fi
|