summaryrefslogtreecommitdiff
path: root/git/server-setup.sh
diff options
context:
space:
mode:
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'"