Multi-customer config system: - CUSTOMER env var selects customer (tianpu/zpark) - customers/tianpu/config.yaml — Tianpu branding, collectors, features - customers/zpark/config.yaml — Z-Park branding, Sungrow collector - GET /api/v1/branding endpoint for customer-specific branding - main.py loads customer config for app title, CORS, logging - Collector manager filters by customer's enabled collectors Z-Park (中关村医疗器械园) support: - Sungrow iSolarCloud API collector (sungrow_collector.py) - Z-Park device definitions (10 inverters, 8 combiner boxes, 22+ buildings) - Z-Park TOU pricing config (Beijing 2026 rates) - Z-Park seed script (seed_zpark.py) Gitea migration scripts (Mac Studio → labmac3): - 5 migration scripts + README in scripts/gitea-migration/ - Creates 3-repo structure: ems-core, tp-ems, zpark-ems Version: v1.0.0 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
61 lines
2.0 KiB
Bash
61 lines
2.0 KiB
Bash
#!/bin/bash
|
|
# Run this ON labmac3 after transferring backup
|
|
# Usage: ssh duwenbo@192.168.1.77 'bash -s' < 03_restore_data.sh
|
|
|
|
echo "=== Restoring Gitea data on labmac3 ==="
|
|
|
|
cd /opt/gitea
|
|
|
|
# Stop Gitea if running
|
|
docker compose down 2>/dev/null
|
|
|
|
# Restore data from backup
|
|
if [ -d "/opt/gitea-backup/gitea-data" ]; then
|
|
echo "Restoring from data volume backup..."
|
|
cp -r /opt/gitea-backup/gitea-data/* ./data/ 2>/dev/null
|
|
# Fix the ROOT_URL in app.ini to point to new IP
|
|
if [ -f "./data/conf/app.ini" ]; then
|
|
sed -i 's|ROOT_URL.*=.*|ROOT_URL = http://192.168.1.77:3300/|' ./data/conf/app.ini
|
|
sed -i 's|SSH_DOMAIN.*=.*|SSH_DOMAIN = 192.168.1.77|' ./data/conf/app.ini
|
|
echo "Updated ROOT_URL and SSH_DOMAIN in app.ini"
|
|
fi
|
|
elif [ -f "/opt/gitea-backup/gitea-dump.zip" ]; then
|
|
echo "Restoring from gitea dump..."
|
|
unzip /opt/gitea-backup/gitea-dump.zip -d /tmp/gitea-restore
|
|
# Copy repos and database
|
|
cp -r /tmp/gitea-restore/repos/* ./data/gitea/repositories/ 2>/dev/null
|
|
cp /tmp/gitea-restore/gitea-db.sql ./data/ 2>/dev/null
|
|
fi
|
|
|
|
# Fix permissions
|
|
sudo chown -R 1000:1000 ./data
|
|
|
|
# Start Gitea
|
|
docker compose up -d
|
|
|
|
echo "Waiting for Gitea to start..."
|
|
sleep 10
|
|
|
|
# Verify
|
|
echo "=== Verification ==="
|
|
curl -s http://localhost:3300/api/v1/version
|
|
echo ""
|
|
curl -s http://localhost:3300/api/v1/repos/search?limit=5 | python3 -c "
|
|
import sys,json
|
|
try:
|
|
data=json.load(sys.stdin)
|
|
repos = data.get('data', data) if isinstance(data, dict) else data
|
|
print(f'Repos found: {len(repos)}')
|
|
for r in repos[:5]:
|
|
name = r.get('full_name', r.get('name', '?'))
|
|
print(f' {name}')
|
|
except: print('Could not parse response')
|
|
" 2>/dev/null
|
|
|
|
echo ""
|
|
echo "=== Gitea should now be accessible at: ==="
|
|
echo " http://192.168.1.77:3300/"
|
|
echo ""
|
|
echo "If this is a fresh install (no backup), create admin:"
|
|
echo " docker exec -it gitea gitea admin user create --admin --username tianpu --password 'TianpuGit2026!' --email admin@tianpu.com"
|