feat: add Caddy install script for Debian/Ubuntu/Raspbian

This commit is contained in:
ecss committed 2026-08-05 02:54:27 -05:00
1 parent 6d1b8c4553
commit 1f37c07c28
1 file changed
+51
+51
View File
@@ -0,0 +1,51 @@
#!/bin/bash
set -euo pipefail
# Install Caddy web server on Debian/Ubuntu/Raspbian using the official
# Cloudsmith apt repository.
# Follows the official docs:
# https://caddyserver.com/docs/install#debian-ubuntu-raspbian
if [ "$EUID" -ne 0 ]; then
echo "Please run as root (sudo)." >&2
exit 1
fi
. /etc/os-release
case "$ID" in
debian|ubuntu|raspbian) ;;
*)
echo "Unsupported distribution: $ID (only Debian, Ubuntu and Raspbian are supported)." >&2
exit 1
;;
esac
ARCH="$(dpkg --print-architecture)"
case "$ARCH" in
amd64|arm64|armhf) ;;
*)
echo "Unsupported architecture: $ARCH" >&2
exit 1
;;
esac
export DEBIAN_FRONTEND=noninteractive
echo "==> Installing prerequisites"
apt-get update
apt-get install -y debian-keyring debian-archive-keyring apt-transport-https curl
echo "==> Adding Caddy's official GPG key"
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
chmod o+r /usr/share/keyrings/caddy-stable-archive-keyring.gpg
echo "==> Adding Caddy apt repository"
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list >/dev/null
chmod o+r /etc/apt/sources.list.d/caddy-stable.list
echo "==> Installing Caddy"
apt-get update
apt-get install -y caddy
echo "Caddy installed. Service status: systemctl status caddy"