refactor(caddy): modularise deployment init

Split the monolithic init-caddy.sh into four ordered, idempotent
setup scripts for the Caddy deployment environment:

- install-base-deps: install required apt packages
- install-aws-cli: bootstrap AWS CLI v2
- install-caddy: fetch binary, create caddy:caddy, register systemd unit
- prepare-caddy-cicd: create bot deploy user + SSH, hand over web root
  with ACLs, write site Caddyfile and start the service
- Make the web root overridable via WEB_ROOT (default /var/www)
This commit is contained in:
zihluwang committed 2026-09-02 13:47:00 +08:00
1 parent ece62675b4
commit 8931598794
4 files changed
+182 -83

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
#
# Base Dependencies Installation for Debian/Ubuntu
# Installs the packages required by the other server initialisation scripts.
#
set -euo pipefail
# Ensure script is executed with root privileges
if [ "$(id -u)" -ne 0 ]; then
echo "Error: This script must be run as root." >&2
exit 1
fi
echo "==> Updating package index..."
apt-get update -qq
echo "==> Installing base dependencies (acl, libcap2-bin, rsync, curl, unzip)..."
apt-get install -y acl libcap2-bin rsync curl unzip
echo "========================================================="
echo " Base dependencies installed successfully!"
echo "========================================================="