change repo path from /opt to /opt/hantim
/opt already exists on Linux systems and git clone refuses to clone into a non-empty directory.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# hantim-server
|
# hantim-server
|
||||||
|
|
||||||
Server provisioning and app management for the hantim webserver. This repo
|
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.
|
scripts, and Gitea Actions workflows for each app.
|
||||||
|
|
||||||
## Repo structure
|
## Repo structure
|
||||||
@@ -26,9 +26,9 @@ On a fresh Rocky Linux 9 (or compatible) install:
|
|||||||
```bash
|
```bash
|
||||||
dnf install -y epel-release
|
dnf install -y epel-release
|
||||||
dnf install -y git git-crypt
|
dnf install -y git git-crypt
|
||||||
git clone <repo-url> /opt
|
git clone <repo-url> /opt/hantim
|
||||||
git-crypt unlock /path/to/git-crypt-key
|
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
|
`setup.sh` installs Docker, creates a `deploy` user, sets up the shared Docker
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
case "$SSH_ORIGINAL_COMMAND" in
|
case "$SSH_ORIGINAL_COMMAND" in
|
||||||
deploy-nginx) /opt/scripts/deploy-nginx.sh ;;
|
deploy-nginx) /opt/hantim/scripts/deploy-nginx.sh ;;
|
||||||
deploy-timothykim) /opt/scripts/deploy-timothykim.sh ;;
|
deploy-timothykim) /opt/hantim/scripts/deploy-timothykim.sh ;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown command: $SSH_ORIGINAL_COMMAND"
|
echo "Unknown command: $SSH_ORIGINAL_COMMAND"
|
||||||
echo "Available: deploy-nginx, deploy-timothykim"
|
echo "Available: deploy-nginx, deploy-timothykim"
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
#!/bin/bash
|
#!/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
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
#!/bin/bash
|
#!/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
|
||||||
|
|||||||
+2
-2
@@ -33,12 +33,12 @@ EOF
|
|||||||
echo "Creating scripts/deploy-$APP.sh..."
|
echo "Creating scripts/deploy-$APP.sh..."
|
||||||
cat > "$REPO_ROOT/scripts/deploy-$APP.sh" <<EOF
|
cat > "$REPO_ROOT/scripts/deploy-$APP.sh" <<EOF
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
cd /opt && git pull && cd docker/$APP && docker compose pull && docker compose up -d
|
cd /opt/hantim && git pull && cd docker/$APP && docker compose pull && docker compose up -d
|
||||||
EOF
|
EOF
|
||||||
chmod +x "$REPO_ROOT/scripts/deploy-$APP.sh"
|
chmod +x "$REPO_ROOT/scripts/deploy-$APP.sh"
|
||||||
|
|
||||||
echo "Adding $APP to deploy-dispatch.sh..."
|
echo "Adding $APP to deploy-dispatch.sh..."
|
||||||
sed -i "/^ \*)$/i\\ deploy-$APP) /opt/scripts/deploy-$APP.sh ;;" \
|
sed -i "/^ \*)$/i\\ deploy-$APP) /opt/hantim/scripts/deploy-$APP.sh ;;" \
|
||||||
"$REPO_ROOT/scripts/deploy-dispatch.sh"
|
"$REPO_ROOT/scripts/deploy-dispatch.sh"
|
||||||
|
|
||||||
echo "Creating .gitea/workflows/deploy-$APP.yml..."
|
echo "Creating .gitea/workflows/deploy-$APP.yml..."
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# Server setup script for a fresh Rocky Linux 9 (or compatible) install.
|
# Server setup script for a fresh Rocky Linux 9 (or compatible) install.
|
||||||
# Run as root after cloning the repo to /opt/.
|
# Run as root after cloning the repo to /opt/hantim.
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# 1. dnf install -y epel-release && dnf install -y git git-crypt
|
# 1. dnf install -y epel-release && dnf install -y git git-crypt
|
||||||
# 2. git clone <repo-url> /opt
|
# 2. git clone <repo-url> /opt/hantim
|
||||||
# 3. git-crypt unlock /path/to/git-crypt-key
|
# 3. git-crypt unlock /path/to/git-crypt-key
|
||||||
# 4. /opt/setup.sh
|
# 4. /opt/hantim/setup.sh
|
||||||
#
|
#
|
||||||
|
|
||||||
errors=()
|
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")
|
errors+=("git-crypt is not installed. Run: dnf install -y epel-release && dnf install -y git git-crypt")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$(pwd)" != "/opt" ] && [ "$(dirname "$(readlink -f "$0")")" != "/opt" ]; then
|
if [ "$(pwd)" != "/opt/hantim" ] && [ "$(dirname "$(readlink -f "$0")")" != "/opt/hantim" ]; then
|
||||||
errors+=("Repo does not appear to be cloned to /opt. Run: git clone <repo-url> /opt")
|
errors+=("Repo does not appear to be cloned to /opt/hantim. Run: git clone <repo-url> /opt/hantim")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if git-crypt status &>/dev/null && git-crypt status 2>/dev/null | grep -q '^\*\*\*ENCRYPTED\*\*\*'; then
|
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 ""
|
||||||
echo "Please complete the initial setup before running this script:"
|
echo "Please complete the initial setup before running this script:"
|
||||||
echo " 1. dnf install -y epel-release && dnf install -y git git-crypt"
|
echo " 1. dnf install -y epel-release && dnf install -y git git-crypt"
|
||||||
echo " 2. git clone <repo-url> /opt"
|
echo " 2. git clone <repo-url> /opt/hantim"
|
||||||
echo " 3. git-crypt unlock /path/to/git-crypt-key"
|
echo " 3. git-crypt unlock /path/to/git-crypt-key"
|
||||||
echo " 4. /opt/setup.sh"
|
echo " 4. /opt/hantim/setup.sh"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Issues found:"
|
echo "Issues found:"
|
||||||
for err in "${errors[@]}"; do
|
for err in "${errors[@]}"; do
|
||||||
@@ -64,13 +64,13 @@ mkdir -p /home/deploy/.ssh
|
|||||||
chmod 700 /home/deploy/.ssh
|
chmod 700 /home/deploy/.ssh
|
||||||
if [ ! -f /home/deploy/.ssh/authorized_keys ]; then
|
if [ ! -f /home/deploy/.ssh/authorized_keys ]; then
|
||||||
echo "WARNING: Add the CI public key manually:"
|
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 <KEY>'
|
echo ' command="/opt/hantim/scripts/deploy-dispatch.sh",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty ssh-ed25519 <KEY>'
|
||||||
echo " into /home/deploy/.ssh/authorized_keys"
|
echo " into /home/deploy/.ssh/authorized_keys"
|
||||||
fi
|
fi
|
||||||
chown -R deploy:deploy /home/deploy/.ssh
|
chown -R deploy:deploy /home/deploy/.ssh
|
||||||
|
|
||||||
echo "==> Making scripts executable..."
|
echo "==> Making scripts executable..."
|
||||||
chmod +x /opt/scripts/*.sh
|
chmod +x /opt/hantim/scripts/*.sh
|
||||||
|
|
||||||
echo "==> Creating shared Docker network..."
|
echo "==> Creating shared Docker network..."
|
||||||
docker network create shared || true
|
docker network create shared || true
|
||||||
@@ -79,8 +79,8 @@ echo "==> Logging into Gitea registry..."
|
|||||||
echo "Run manually: docker login git.timothykim.net"
|
echo "Run manually: docker login git.timothykim.net"
|
||||||
|
|
||||||
echo "==> Starting services..."
|
echo "==> Starting services..."
|
||||||
cd /opt/docker/nginx && docker compose up -d
|
cd /opt/hantim/docker/nginx && docker compose up -d
|
||||||
cd /opt/docker/timothykim.net && docker compose up -d
|
cd /opt/hantim/docker/timothykim.net && docker compose up -d
|
||||||
|
|
||||||
echo "==> Done. Don't forget to:"
|
echo "==> Done. Don't forget to:"
|
||||||
echo " 1. Add the deploy SSH public key to /home/deploy/.ssh/authorized_keys"
|
echo " 1. Add the deploy SSH public key to /home/deploy/.ssh/authorized_keys"
|
||||||
|
|||||||
Reference in New Issue
Block a user