diff options
| author | yyamashita <yyamashita@hetzner.yyamashita.com> | 2026-05-17 11:18:12 +0900 |
|---|---|---|
| committer | yyamashita <yyamashita@hetzner.yyamashita.com> | 2026-05-17 11:18:12 +0900 |
| commit | b6efad84b51c6df5f595683d66b855c75bddabc4 (patch) | |
| tree | b12d164613032105a05e871f7b2e0871b51ea658 /scripts/server-setup.sh | |
| parent | fa882598d3ee6bff4e32892a81b6b2712eb8c11d (diff) | |
Centralize repo and hook management: add repos.txt and install.sh
All bare repo creation is now driven by repos.txt in this repo.
install.sh replaces install-hooks.sh and handles both repo creation
and hook deployment. Other repos' server-setup.sh no longer manage
bare repos or hooks.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'scripts/server-setup.sh')
| -rw-r--r-- | scripts/server-setup.sh | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/scripts/server-setup.sh b/scripts/server-setup.sh index 154c6c7..ca9a3f9 100644 --- a/scripts/server-setup.sh +++ b/scripts/server-setup.sh @@ -1,9 +1,11 @@ #!/bin/bash -# Run once on a fresh Hetzner VPS (as root). Run this first before other app setups. +# Run once on a fresh Hetzner VPS (as root). +# hetzner-infra のみブートストラップとして作成する。 +# 他のリポジトリは最初の push 後に install.sh が作成する。 set -e -APP_DIR=/app/infra REPO_DIR=/var/git/hetzner-infra.git +APP_DIR=/app/infra # Install Docker curl -fsSL https://get.docker.com | sh @@ -11,18 +13,30 @@ curl -fsSL https://get.docker.com | sh # Create shared Docker network docker network create web || true -mkdir -p "$APP_DIR" -mkdir -p "$REPO_DIR" +# hetzner-infra bare repo をブートストラップ +mkdir -p "$REPO_DIR" "$APP_DIR" git init --bare "$REPO_DIR" +# 最初の push を受け取るための最小限のフック(install.sh 実行後に上書きされる) +cat > "$REPO_DIR/hooks/post-receive" << 'HOOK' +#!/bin/bash +set -e +APP_DIR=/app/infra +GIT_WORK_TREE=$APP_DIR git checkout -f +cd $APP_DIR +docker network create web 2>/dev/null || true +docker compose up -d +docker compose exec -T caddy caddy reload --config /etc/caddy/Caddyfile 2>/dev/null || true +echo "Deploy complete: hetzner-infra" +if [ -f "$APP_DIR/scripts/sync-claude-services.sh" ]; then + bash "$APP_DIR/scripts/sync-claude-services.sh" +fi +HOOK +chmod +x "$REPO_DIR/hooks/post-receive" + echo "" -echo "Setup complete. On your local machine, run:" -echo " git remote add hetzner root@<server-ip>:$REPO_DIR" -echo " git push hetzner master" -echo "" -echo "Then install hooks:" -echo " ssh root@<server-ip> 'bash /app/infra/scripts/install-hooks.sh'" -echo "" -echo "Then run setup scripts for each app:" -echo " tokyo-livehouse-events/scripts/server-setup.sh" -echo " whois-band/scripts/server-setup.sh" +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/scripts/install.sh'" +echo " (他のリポジトリ作成 + 全フックの正式インストール)" |
