Some checks failed
Deploy explore / deploy (push) Failing after 18s
Entscheidungen als Markdown, Normen-Index und schlankes Git-Sync nach /opt/explore (Gitea Actions, ohne Docker). Co-authored-by: Cursor <cursoragent@cursor.com>
67 lines
1.9 KiB
Bash
Executable File
67 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
# Spiegelt Explor.Code.Law auf den Strato-VServer (rsync).
|
|
# Nützlich bevor das Gitea-Repo existiert, und für ge_xml/ (gitignoriert).
|
|
#
|
|
# Usage:
|
|
# ./sync_to_server.sh # Code + ge_md + data + ge_xml
|
|
# ./sync_to_server.sh --xml-only
|
|
# ./sync_to_server.sh --dry-run
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "$0")" && pwd)"
|
|
SERVER="root@82.165.92.92"
|
|
SSH_KEY="${SSH_KEY:-$HOME/.ssh/gitea_deploy}"
|
|
REMOTE_DIR="/opt/explore"
|
|
RSYNC_SSH="ssh -i $SSH_KEY -o BatchMode=yes -o StrictHostKeyChecking=accept-new"
|
|
|
|
XML_ONLY=0
|
|
DRY=()
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--xml-only) XML_ONLY=1 ;;
|
|
--dry-run) DRY=(--dry-run) ;;
|
|
-h|--help)
|
|
sed -n '2,12p' "$0"
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "Unbekanntes Argument: $arg" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [ ! -f "$SSH_KEY" ]; then
|
|
echo "SSH-Key fehlt: $SSH_KEY" >&2
|
|
exit 1
|
|
fi
|
|
|
|
ssh -i "$SSH_KEY" -o BatchMode=yes "$SERVER" "mkdir -p $REMOTE_DIR/ge_md $REMOTE_DIR/data $REMOTE_DIR/ge_xml $REMOTE_DIR/kommentar"
|
|
|
|
if [ "$XML_ONLY" -eq 1 ]; then
|
|
echo "Sync ge_xml/ → $SERVER:$REMOTE_DIR/ge_xml/"
|
|
rsync -avz "${DRY[@]}" \
|
|
-e "$RSYNC_SSH" \
|
|
--exclude '.DS_Store' \
|
|
"$ROOT/ge_xml/" "$SERVER:$REMOTE_DIR/ge_xml/"
|
|
else
|
|
echo "Sync Projekt → $SERVER:$REMOTE_DIR/"
|
|
rsync -avz "${DRY[@]}" \
|
|
-e "$RSYNC_SSH" \
|
|
--exclude '.git/' \
|
|
--exclude '.venv/' \
|
|
--exclude 'venv/' \
|
|
--exclude '__pycache__/' \
|
|
--exclude '.pytest_cache/' \
|
|
--exclude '.DS_Store' \
|
|
--exclude '.env' \
|
|
"$ROOT/" "$SERVER:$REMOTE_DIR/"
|
|
fi
|
|
|
|
echo ""
|
|
ssh -i "$SSH_KEY" -o BatchMode=yes "$SERVER" \
|
|
"echo ge_md: \$(find $REMOTE_DIR/ge_md -name '*.md' 2>/dev/null | wc -l); \
|
|
echo ge_xml: \$(find $REMOTE_DIR/ge_xml -type f 2>/dev/null | wc -l); \
|
|
echo index: \$([ -f $REMOTE_DIR/data/normen_index.json ] && wc -c < $REMOTE_DIR/data/normen_index.json || echo fehlt) bytes"
|
|
echo "Fertig."
|