diff --git a/README.md b/README.md index 4831de2..fbc2729 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # hantim-server Server provisioning and app management for the hantim webserver. This repo -lives at `/opt` on the server and contains Docker Compose configs, deploy +lives at `/opt/hantim` on the server and contains Docker Compose configs, deploy scripts, and Gitea Actions workflows for each app. ## Repo structure @@ -26,9 +26,9 @@ On a fresh Rocky Linux 9 (or compatible) install: ```bash dnf install -y epel-release dnf install -y git git-crypt -git clone /opt +git clone /opt/hantim git-crypt unlock /path/to/git-crypt-key -/opt/setup.sh +/opt/hantim/setup.sh ``` `setup.sh` installs Docker, creates a `deploy` user, sets up the shared Docker diff --git a/scripts/deploy-dispatch.sh b/scripts/deploy-dispatch.sh index a7eea7b..cf3e117 100644 --- a/scripts/deploy-dispatch.sh +++ b/scripts/deploy-dispatch.sh @@ -2,8 +2,8 @@ set -euo pipefail case "$SSH_ORIGINAL_COMMAND" in - deploy-nginx) /opt/scripts/deploy-nginx.sh ;; - deploy-timothykim) /opt/scripts/deploy-timothykim.sh ;; + deploy-nginx) /opt/hantim/scripts/deploy-nginx.sh ;; + deploy-timothykim) /opt/hantim/scripts/deploy-timothykim.sh ;; *) echo "Unknown command: $SSH_ORIGINAL_COMMAND" echo "Available: deploy-nginx, deploy-timothykim" diff --git a/scripts/deploy-nginx.sh b/scripts/deploy-nginx.sh index 287cca8..30dd3a1 100644 --- a/scripts/deploy-nginx.sh +++ b/scripts/deploy-nginx.sh @@ -1,2 +1,2 @@ #!/bin/bash -cd /opt && git pull && cd docker/nginx && docker compose pull && docker compose up -d +cd /opt/hantim && git pull && cd docker/nginx && docker compose pull && docker compose up -d diff --git a/scripts/deploy-timothykim.sh b/scripts/deploy-timothykim.sh index 3466b7b..799b7f5 100755 --- a/scripts/deploy-timothykim.sh +++ b/scripts/deploy-timothykim.sh @@ -1,2 +1,2 @@ #!/bin/bash -cd /opt && git pull && cd docker/timothykim.net && docker compose pull && docker compose up -d +cd /opt/hantim && git pull && cd docker/timothykim.net && docker compose pull && docker compose up -d diff --git a/scripts/new-app.sh b/scripts/new-app.sh index a35a768..fb892e6 100755 --- a/scripts/new-app.sh +++ b/scripts/new-app.sh @@ -33,12 +33,12 @@ EOF echo "Creating scripts/deploy-$APP.sh..." cat > "$REPO_ROOT/scripts/deploy-$APP.sh" < /opt +# 2. git clone /opt/hantim # 3. git-crypt unlock /path/to/git-crypt-key -# 4. /opt/setup.sh +# 4. /opt/hantim/setup.sh # errors=() @@ -25,8 +25,8 @@ if ! command -v git-crypt &>/dev/null; then errors+=("git-crypt is not installed. Run: dnf install -y epel-release && dnf install -y git git-crypt") fi -if [ "$(pwd)" != "/opt" ] && [ "$(dirname "$(readlink -f "$0")")" != "/opt" ]; then - errors+=("Repo does not appear to be cloned to /opt. Run: git clone /opt") +if [ "$(pwd)" != "/opt/hantim" ] && [ "$(dirname "$(readlink -f "$0")")" != "/opt/hantim" ]; then + errors+=("Repo does not appear to be cloned to /opt/hantim. Run: git clone /opt/hantim") fi if git-crypt status &>/dev/null && git-crypt status 2>/dev/null | grep -q '^\*\*\*ENCRYPTED\*\*\*'; then @@ -38,9 +38,9 @@ if [ ${#errors[@]} -gt 0 ]; then echo "" echo "Please complete the initial setup before running this script:" echo " 1. dnf install -y epel-release && dnf install -y git git-crypt" - echo " 2. git clone /opt" + echo " 2. git clone /opt/hantim" echo " 3. git-crypt unlock /path/to/git-crypt-key" - echo " 4. /opt/setup.sh" + echo " 4. /opt/hantim/setup.sh" echo "" echo "Issues found:" for err in "${errors[@]}"; do @@ -64,13 +64,13 @@ mkdir -p /home/deploy/.ssh chmod 700 /home/deploy/.ssh if [ ! -f /home/deploy/.ssh/authorized_keys ]; then echo "WARNING: Add the CI public key manually:" - echo ' command="/opt/scripts/deploy-dispatch.sh",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty ssh-ed25519 ' + echo ' command="/opt/hantim/scripts/deploy-dispatch.sh",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty ssh-ed25519 ' echo " into /home/deploy/.ssh/authorized_keys" fi chown -R deploy:deploy /home/deploy/.ssh echo "==> Making scripts executable..." -chmod +x /opt/scripts/*.sh +chmod +x /opt/hantim/scripts/*.sh echo "==> Creating shared Docker network..." docker network create shared || true @@ -79,8 +79,8 @@ echo "==> Logging into Gitea registry..." echo "Run manually: docker login git.timothykim.net" echo "==> Starting services..." -cd /opt/docker/nginx && docker compose up -d -cd /opt/docker/timothykim.net && docker compose up -d +cd /opt/hantim/docker/nginx && docker compose up -d +cd /opt/hantim/docker/timothykim.net && docker compose up -d echo "==> Done. Don't forget to:" echo " 1. Add the deploy SSH public key to /home/deploy/.ssh/authorized_keys"