mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-10-24 04:05:03 +00:00
Every interactive prompt takes a var_<app>_<name> override and treats a closed stdin like Enter (`|| true`), so an install keeps going after the console that started it is gone. Values the script cannot do without end with exit 64 and name the variable to set. Validation loops stop asking when nobody can answer instead of spinning on an empty read.
92 lines
2.5 KiB
Bash
92 lines
2.5 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# Copyright (c) 2021-2026 tteck
|
|
# Author: tteck (tteckster) | Co-Author: MickLesk (CanbiZ)
|
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
|
# Source: https://caddyserver.com/ | Github: https://github.com/caddyserver/caddy
|
|
|
|
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
|
|
color
|
|
verb_ip6
|
|
catch_errors
|
|
setting_up_container
|
|
network_check
|
|
update_os
|
|
|
|
setup_deb_based() {
|
|
fetch_and_deploy_gh_release "caddy" "caddyserver/caddy" "binary" "latest" "/opt/caddy" "caddy_*_linux_$(arch_resolve).deb"
|
|
systemctl enable -q --now caddy
|
|
|
|
prompt="${var_caddy_xcaddy:-}"
|
|
[[ -n "$prompt" ]] || read -r -p "${TAB3}Would you like to install xCaddy Addon? <y/N> " prompt || true
|
|
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
|
|
setup_go
|
|
fetch_and_deploy_gh_release "xcaddy" "caddyserver/xcaddy" "binary"
|
|
|
|
msg_info "Setup xCaddy"
|
|
$STD apt install -y git
|
|
$STD xcaddy build
|
|
msg_ok "Setup xCaddy"
|
|
fi
|
|
}
|
|
|
|
setup_alpine() {
|
|
msg_info "Installing Caddy"
|
|
$STD apk add --no-cache caddy caddy-openrc
|
|
cat <<EOF >/etc/caddy/Caddyfile
|
|
:80 {
|
|
# Set this path to your site's directory.
|
|
root * /var/www/html
|
|
|
|
# Enable the static file server.
|
|
file_server
|
|
|
|
# Another common task is to set up a reverse proxy:
|
|
# reverse_proxy localhost:8080
|
|
|
|
# Or serve a PHP site through php-fpm:
|
|
# php_fastcgi localhost:9000
|
|
}
|
|
EOF
|
|
mkdir -p /var/www/html
|
|
cat <<EOF >/var/www/html/index.html
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Caddy works!</title>
|
|
</head>
|
|
<body>
|
|
<h1>Hello Caddy!</h1>
|
|
<p>For more information, refer to the Caddy <a href="https://caddyserver.com/docs/">documentation</a><p>
|
|
</body>
|
|
</html>
|
|
EOF
|
|
msg_ok "Installed Caddy"
|
|
|
|
prompt="${var_caddy_xcaddy:-}"
|
|
[[ -n "$prompt" ]] || read -r -p "${TAB3}Would you like to install xCaddy Addon? <y/N> " prompt || true
|
|
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
|
|
GO_VERSION="$(curl -fsSL https://go.dev/VERSION?m=text | head -1 | cut -c3-)" setup_go
|
|
fetch_and_deploy_gh_release "xcaddy" "caddyserver/xcaddy" "prebuild" "latest" "/opt/xcaddy" "xcaddy_*_linux_$(arch_resolve).tar.gz"
|
|
ln -sf /opt/xcaddy/xcaddy /usr/local/bin/xcaddy
|
|
msg_info "Setup xCaddy"
|
|
cd /opt
|
|
$STD xcaddy build
|
|
msg_ok "Setup xCaddy"
|
|
fi
|
|
|
|
msg_info "Enabling Caddy Service"
|
|
$STD rc-update add caddy default
|
|
msg_ok "Enabled Caddy Service"
|
|
|
|
msg_info "Starting Caddy"
|
|
$STD service caddy start
|
|
msg_ok "Started Caddy"
|
|
}
|
|
|
|
run_os_setup
|
|
|
|
motd_ssh
|
|
customize
|
|
cleanup_lxc
|