summaryrefslogtreecommitdiff
path: root/git/server-setup.sh
diff options
context:
space:
mode:
authoryyamashita <yyamashita@hetzner.yyamashita.com>2026-05-17 11:29:27 +0900
committeryyamashita <yyamashita@hetzner.yyamashita.com>2026-05-17 11:29:27 +0900
commitef6dbdd2ac273dc4a01c70437ee7984cea9f2a3c (patch)
tree4db9e4917a3a2ffb4d96d02fd7927dd7dcaabf39 /git/server-setup.sh
parentfa8880f38783bebbce805f8595c949b9c7f326a0 (diff)
Reorganize repo into caddy/, git/, claude/ directories
- caddy/: Caddyfile, docker-compose.yml, deploy.sh (hook runs this only) - git/: repos.txt, hooks/*/post-receive, install.sh, server-setup.sh - claude/: sessions.txt, systemd/claude-code@.service, sync.sh Post-receive hook is now: checkout + bash caddy/deploy.sh Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'git/server-setup.sh')
-rwxr-xr-xgit/server-setup.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/git/server-setup.sh b/git/server-setup.sh
new file mode 100755
index 0000000..a575628
--- /dev/null
+++ b/git/server-setup.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+# Run once on a fresh Hetzner VPS (as root).
+# hetzner-infra のみブートストラップとして作成する。
+# 他のリポジトリは最初の push 後に git/install.sh が作成する。
+set -e
+
+REPO_DIR=/var/git/hetzner-infra.git
+APP_DIR=/app/infra
+
+curl -fsSL https://get.docker.com | sh
+docker network create web || true
+
+mkdir -p "$REPO_DIR" "$APP_DIR"
+git init --bare "$REPO_DIR"
+
+# 最初の push を受け取るための最小限のフック(git/install.sh 実行後に上書きされる)
+cat > "$REPO_DIR/hooks/post-receive" << 'HOOK'
+#!/bin/bash
+set -e
+GIT_WORK_TREE=/app/infra git checkout -f
+bash /app/infra/caddy/deploy.sh
+echo "Deploy complete: hetzner-infra"
+HOOK
+chmod +x "$REPO_DIR/hooks/post-receive"
+
+echo ""
+echo "Next steps:"
+echo " 1. git remote add origin root@<server-ip>:$REPO_DIR"
+echo " 2. git push origin master"
+echo " 3. ssh root@<server-ip> 'bash $APP_DIR/git/install.sh'"