mirror of
https://github.com/kossakovsky/n8n-install.git
synced 2026-03-07 22:33:11 +00:00
Enhance domain input handling in 03_generate_secrets.sh and update apply_update.sh
- Introduced logic to infer the current domain from N8N_HOSTNAME or SUPABASE_HOSTNAME for user prompts in 03_generate_secrets.sh. - Improved user prompts to display the current domain as a default suggestion, enhancing user experience. - Updated apply_update.sh to ensure the .env file is checked and updated by calling 03_generate_secrets.sh during the update process.
This commit is contained in:
@@ -91,27 +91,45 @@ if ! command -v caddy &> /dev/null; then
|
||||
fi
|
||||
|
||||
# Prompt for the domain name
|
||||
CURRENT_DOMAIN=""
|
||||
# Try to infer current domain from N8N_HOSTNAME or SUPABASE_HOSTNAME for the prompt
|
||||
if [[ -n "${existing_env_vars[N8N_HOSTNAME]}" ]]; then
|
||||
CURRENT_DOMAIN=$(echo "${existing_env_vars[N8N_HOSTNAME]}" | sed -E 's/^[a-zA-Z0-9-]+\.(.+)/\1/')
|
||||
elif [[ -n "${existing_env_vars[SUPABASE_HOSTNAME]}" ]]; then
|
||||
CURRENT_DOMAIN=$(echo "${existing_env_vars[SUPABASE_HOSTNAME]}" | sed -E 's/^[a-zA-Z0-9-]+\.(.+)/\1/')
|
||||
fi
|
||||
|
||||
while true; do
|
||||
echo ""
|
||||
read -p "Enter the primary domain name for your services (e.g., example.com): " DOMAIN
|
||||
prompt_text="Enter the primary domain name for your services (e.g., example.com)"
|
||||
if [[ -n "$CURRENT_DOMAIN" ]]; then
|
||||
prompt_text+=" [current: $CURRENT_DOMAIN]: "
|
||||
else
|
||||
prompt_text+=": "
|
||||
fi
|
||||
read -p "$prompt_text" DOMAIN_INPUT
|
||||
|
||||
DOMAIN_TO_USE="${DOMAIN_INPUT:-$CURRENT_DOMAIN}"
|
||||
|
||||
# Validate domain input
|
||||
if [[ -z "$DOMAIN" ]]; then
|
||||
if [[ -z "$DOMAIN_TO_USE" ]]; then
|
||||
log_error "Domain name cannot be empty." >&2
|
||||
continue # Ask again
|
||||
fi
|
||||
|
||||
# Basic check for likely invalid domain characters (very permissive)
|
||||
if [[ "$DOMAIN" =~ [^a-zA-Z0-9.-] ]]; then
|
||||
log_warning "Warning: Domain name contains potentially invalid characters: '$DOMAIN'" >&2
|
||||
if [[ "$DOMAIN_TO_USE" =~ [^a-zA-Z0-9.-] ]]; then
|
||||
log_warning "Warning: Domain name contains potentially invalid characters: '$DOMAIN_TO_USE'" >&2
|
||||
fi
|
||||
|
||||
echo ""
|
||||
read -p "Are you sure '$DOMAIN' is correct? (y/N): " confirm_domain
|
||||
read -p "Are you sure '$DOMAIN_TO_USE' is correct? (y/N): " confirm_domain
|
||||
if [[ "$confirm_domain" =~ ^[Yy]$ ]]; then
|
||||
DOMAIN="$DOMAIN_TO_USE" # Set the final DOMAIN variable
|
||||
break # Confirmed, exit loop
|
||||
else
|
||||
log_info "Please try entering the domain name again."
|
||||
# CURRENT_DOMAIN remains for the next prompt iteration if user wants to retry with current default
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
@@ -27,6 +27,15 @@ fi
|
||||
|
||||
cd "$PROJECT_ROOT"
|
||||
|
||||
# --- Call 03_generate_secrets.sh in update mode ---
|
||||
log_info "Ensuring .env file is up-to-date with all variables..."
|
||||
bash "$SCRIPT_DIR/03_generate_secrets.sh" --update || {
|
||||
log_error "Failed to update .env configuration via 03_generate_secrets.sh. Update process cannot continue."
|
||||
exit 1
|
||||
}
|
||||
log_success ".env file checked and updated."
|
||||
# --- End of .env update ---
|
||||
|
||||
# Stop all services for project 'localai'
|
||||
log_info "Stopping all services for project 'localai'..."
|
||||
PROJECT_CONTAINERS=$(docker ps -a -q --filter "label=com.docker.compose.project=localai")
|
||||
|
||||
Reference in New Issue
Block a user