alpine-caddy: move config creation to install step

This commit is contained in:
cobaltgit 2025-09-17 10:18:33 +01:00
parent 7e5cbc4072
commit 3fd2f00a91

View File

@ -15,21 +15,6 @@ update_os
msg_info "Installing Caddy" msg_info "Installing Caddy"
$STD apk add --no-cache caddy caddy-openrc $STD apk add --no-cache caddy caddy-openrc
msg_ok "Installed Caddy"
read -r -p "${TAB3}Would you like to install xCaddy Addon? <y/N> " prompt
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
GO_VERSION="$(curl -fsSL https://go.dev/VERSION?m=text | head -1 | cut -c3-)" setup_go
msg_info "Setup xCaddy"
cd /opt
RELEASE=$(curl -fsSL https://api.github.com/repos/caddyserver/xcaddy/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
curl -fsSL "https://github.com/caddyserver/xcaddy/releases/download/${RELEASE}/xcaddy_${RELEASE:1}_linux_amd64.tar.gz" -o "xcaddy_${RELEASE:1}_linux_amd64.tar.gz"
$STD tar xzf xcaddy_"${RELEASE:1}"_linux_amd64.tar.gz -C /usr/local/bin xcaddy
rm -rf /opt/xcaddy*
$STD xcaddy build
msg_ok "Setup xCaddy"
fi
cat<<EOF>/etc/caddy/Caddyfile cat<<EOF>/etc/caddy/Caddyfile
# The Caddyfile is an easy way to configure your Caddy web server. # The Caddyfile is an easy way to configure your Caddy web server.
# #
@ -71,6 +56,21 @@ cat<<EOF>/var/www/html/index.html
</body> </body>
</html> </html>
EOF EOF
msg_ok "Installed Caddy"
read -r -p "${TAB3}Would you like to install xCaddy Addon? <y/N> " prompt
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
GO_VERSION="$(curl -fsSL https://go.dev/VERSION?m=text | head -1 | cut -c3-)" setup_go
msg_info "Setup xCaddy"
cd /opt
RELEASE=$(curl -fsSL https://api.github.com/repos/caddyserver/xcaddy/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
curl -fsSL "https://github.com/caddyserver/xcaddy/releases/download/${RELEASE}/xcaddy_${RELEASE:1}_linux_amd64.tar.gz" -o "xcaddy_${RELEASE:1}_linux_amd64.tar.gz"
$STD tar xzf xcaddy_"${RELEASE:1}"_linux_amd64.tar.gz -C /usr/local/bin xcaddy
rm -rf /opt/xcaddy*
$STD xcaddy build
msg_ok "Setup xCaddy"
fi
msg_info "Enabling Caddy Service" msg_info "Enabling Caddy Service"
$STD rc-update add caddy default $STD rc-update add caddy default
msg_ok "Enabled Caddy Service" msg_ok "Enabled Caddy Service"