Refactor caddy check in 03_generate_secrets.sh

- Moved the caddy availability check to a later point in the script after the installation process.
- Improved script flow by ensuring caddy is checked only after attempting to install it, enhancing user experience.
This commit is contained in:
Yury Kossakovsky
2025-05-05 14:14:16 -06:00
parent 7c56ddc2f4
commit 9fbe779677

View File

@@ -11,12 +11,6 @@ if ! command -v openssl &> /dev/null; then
exit 1
fi
# Check for caddy
if ! command -v caddy &> /dev/null; then
log_error "caddy could not be found. Please ensure it is installed and available in your PATH." >&2
exit 1
fi
# --- Configuration ---
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
PROJECT_ROOT="$( cd "$SCRIPT_DIR/.." &> /dev/null && pwd )"
@@ -61,6 +55,12 @@ curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --yes --
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list
apt install -y caddy
# Check for caddy
if ! command -v caddy &> /dev/null; then
log_error "caddy could not be found. Please ensure it is installed and available in your PATH." >&2
exit 1
fi
# Prompt for the domain name
while true; do
read -p "Enter the primary domain name for your services (e.g., example.com): " DOMAIN