- FTP-Sync durch Cloud-Backends ersetzt (Dropbox, Google Drive) - OAuth-Flow mit nutzereigenen Tokens und App-Key-Konfiguration - Zeit-Tooltips für Timeline-Labels und Abschnittsbanner beim Playback - Tests, Build-Konfiguration und Doku aktualisiert
76 lines
2.4 KiB
Bash
Executable file
76 lines
2.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Erzeugt rinkplanner/sync_apps.cfg aus docs/credentials.txt.
|
|
#
|
|
# Die OAuth-App-Zugänge sind öffentliche App-Identitäten, keine Nutzergeheimnisse.
|
|
# Sie werden beim Build als res://sync_apps.cfg eingebettet. Die Datei ist
|
|
# trotzdem gitignored, damit versehentliche Änderungen nicht im Repository landen.
|
|
#
|
|
# Aufruf:
|
|
# ./tools/sync_apps_config.sh
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
CREDENTIALS="$REPO_ROOT/docs/credentials.txt"
|
|
TARGET="$REPO_ROOT/rinkplanner/sync_apps.cfg"
|
|
|
|
if [[ ! -f "$CREDENTIALS" ]]; then
|
|
echo "FEHLER: $CREDENTIALS fehlt." >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Liest den letzten Wert eines KEY=WERT-Eintrags. Bewusst ohne assoziative
|
|
# Arrays, damit das Skript auch mit dem bash 3.2 von macOS läuft.
|
|
read_value() {
|
|
local key="$1"
|
|
local line
|
|
line="$(grep -E "^[[:space:]]*${key}[[:space:]]*=" "$CREDENTIALS" | tail -n 1 || true)"
|
|
if [[ -z "$line" ]]; then
|
|
return 0
|
|
fi
|
|
local value="${line#*=}"
|
|
value="${value%$'\r'}"
|
|
value="$(printf '%s' "$value" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
|
|
printf '%s' "$value"
|
|
}
|
|
|
|
write_value() {
|
|
local cfg_key="$1"
|
|
local cred_key="$2"
|
|
local value
|
|
value="$(read_value "$cred_key")"
|
|
# ConfigFile-Werte sind Godot-Varianten: Strings müssen in Anführungszeichen
|
|
# stehen, sonst wird z. B. ein App-Key als Identifier geparst.
|
|
value="${value//\\/\\\\}"
|
|
value="${value//\"/\\\"}"
|
|
printf '%s="%s"\n' "$cfg_key" "$value"
|
|
}
|
|
|
|
{
|
|
printf '%s\n' \
|
|
"; Automatisch erzeugt von tools/sync_apps_config.sh" \
|
|
"; Nicht einchecken; siehe sync_apps.example.cfg." \
|
|
"" \
|
|
"[apps]"
|
|
write_value google_client_id GOOGLE_CLIENT_ID
|
|
write_value google_client_secret GOOGLE_CLIENT_SECRET
|
|
write_value dropbox_app_key DROPBOX_APP_KEY
|
|
write_value dropbox_app_secret DROPBOX_APP_SECRET
|
|
} >"$TARGET"
|
|
|
|
chmod 600 "$TARGET"
|
|
echo "Geschrieben: $TARGET"
|
|
|
|
missing=0
|
|
for key in GOOGLE_CLIENT_ID GOOGLE_CLIENT_SECRET DROPBOX_APP_KEY; do
|
|
if [[ -z "$(read_value "$key")" ]]; then
|
|
echo "Hinweis: $key ist in docs/credentials.txt leer." >&2
|
|
missing=1
|
|
fi
|
|
done
|
|
if [[ "$missing" -eq 1 ]]; then
|
|
echo "Der Cloud-Sync bleibt ohne diese Werte deaktiviert." >&2
|
|
fi
|
|
if [[ -n "$(read_value GOOGLE_USER)$(read_value DROPBOX_USER)" ]]; then
|
|
echo "Hinweis: GOOGLE_USER/PASSWORD und DROPBOX_USER/PASSWORD werden nicht" >&2
|
|
echo "verwendet. Die Cloud-APIs brauchen OAuth-App-Zugänge, keine Nutzerpasswörter." >&2
|
|
fi
|