Files
timemaster/remote.sh
T
patrickandClaude Sonnet 5.5 7e165d37b6
Security Audit / Python Dependency Audit (push) Canceled after 0s
Security Audit / Node.js Dependency Audit (push) Canceled after 0s
Security Audit / Frontend Build (tsc + vite) (push) Canceled after 0s
feat(deploy): deploy.sh + lokale Host-Konfig, server-update/setup_server übernehmen Unit und sudoers aus dem Repo
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-05 09:40:35 +01:00

54 lines
1.9 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# ============================================================
# remote.sh – Schnellbefehle für den Deployment-Server
# Usage:
# ./remote.sh logs → Live-Logs
# ./remote.sh status → Service-Status
# ./remote.sh restart → Service neu starten
# ./remote.sh migrate → alembic upgrade head
# ./remote.sh shell → SSH Shell öffnen
# ./remote.sh psql → PostgreSQL Shell
# ./remote.sh test → Tests auf dem Server ausführen
# ./remote.sh env → .env auf Server bearbeiten
# ============================================================
# Hosts aus deploy.local.env; TM_TARGET=prod nutzt TM_PROD_HOST
[[ -f "$(dirname "$0")/deploy.local.env" ]] && source "$(dirname "$0")/deploy.local.env"
if [[ "${TM_TARGET:-dev}" == "prod" ]]; then HOST="${TM_PROD_HOST:-}"; else HOST="${TM_DEV_HOST:-}"; fi
[[ -n "$HOST" ]] || { echo "Host nicht gesetzt (deploy.local.env)." >&2; exit 1; }
SERVER="${TM_SSH_USER:-root}@$HOST"
REMOTE="/opt/timemaster"
case "$1" in
logs)
ssh "$SERVER" "journalctl -u timemaster -f"
;;
status)
ssh "$SERVER" "systemctl status timemaster --no-pager"
;;
restart)
ssh "$SERVER" "systemctl restart timemaster && systemctl is-active timemaster"
;;
migrate)
ssh "$SERVER" "cd $REMOTE/backend && source venv/bin/activate && alembic upgrade head"
;;
shell)
ssh "$SERVER"
;;
psql)
ssh -t "$SERVER" "sudo -u postgres psql timemaster_db"
;;
test)
ssh "$SERVER" "cd $REMOTE/backend && source venv/bin/activate && pip install aiosqlite -q && pytest -v"
;;
env)
ssh -t "$SERVER" "nano $REMOTE/backend/.env"
;;
health)
ssh "$SERVER" "curl -s http://127.0.0.1:8000/health" | python3 -m json.tool
;;
*)
echo "Usage: ./remote.sh [logs|status|restart|migrate|shell|psql|test|env|health]"
;;
esac