#!/bin/bash # Standard Deployment configuration wizard and .env writer. set -euo pipefail prompt_standard_core_config() { print_step_header 3 "$WIZARD_TOTAL" "Core configuration" tui_print_box "Standard Deployment" "One public URL and one host port — ideal for homelabs and quick installs." local default_site="http://localhost:8015" while true; do SITE_URL="$(prompt_with_default "Public site URL" "$default_site")" if validate_url "$SITE_URL"; then break fi log_error "Enter a valid http:// or https:// URL" done SITE_URL="${SITE_URL%/}" HOST_PORT="$(extract_port_from_url "$SITE_URL" "8015")" local port_override port_override="$(tui_input "Host port to bind [${HOST_PORT}]" "$HOST_PORT")" HOST_PORT="${port_override:-$HOST_PORT}" log_success "Site: $SITE_URL (port $HOST_PORT)" POSTGRES_PASSWORD="$(generate_secure_password 32)" log_success "Generated secure database password" if tui_confirm "Change default admin credentials (admin/admin)?" "y"; then DJANGO_ADMIN_USERNAME="$(prompt_with_default "Admin username" "admin")" DJANGO_ADMIN_PASSWORD="$(generate_secure_password 24)" DJANGO_ADMIN_EMAIL="$(prompt_with_default "Admin email" "admin@example.com")" else DJANGO_ADMIN_USERNAME="admin" DJANGO_ADMIN_PASSWORD="admin" DJANGO_ADMIN_EMAIL="admin@example.com" log_warning "Using default admin/admin — change after first login" fi echo "" } write_env_standard() { local target="$ENV_FILE" { echo "# AdventureLog Standard Deployment — generated by installer" echo "POSTGRES_PASSWORD=$(format_env_value "$POSTGRES_PASSWORD")" echo "SITE_URL=$(format_env_value "$SITE_URL")" echo "HOST_PORT=$(format_env_value "$HOST_PORT")" echo "DJANGO_ADMIN_USERNAME=$(format_env_value "$DJANGO_ADMIN_USERNAME")" echo "DJANGO_ADMIN_PASSWORD=$(format_env_value "$DJANGO_ADMIN_PASSWORD")" echo "DJANGO_ADMIN_EMAIL=$(format_env_value "$DJANGO_ADMIN_EMAIL")" } > "$target" save_optional_env_to_file "$target" log_success "Wrote $target" } show_standard_review() { local opt_count=0 [[ -v OPTIONAL_ENV_LINES ]] && opt_count="${#OPTIONAL_ENV_LINES[@]}" print_step_header 5 "$WIZARD_TOTAL" "Review & confirm" print_section "Configuration summary" print_summary_row "Setup" "Standard Deployment" print_summary_row "Site URL" "$SITE_URL" print_summary_row "Host port" "$HOST_PORT" print_summary_row "PostGIS image" "$POSTGIS_IMAGE" print_summary_row "Admin user" "$DJANGO_ADMIN_USERNAME" print_summary_row "Optional features" "$opt_count configured" echo "" if ! tui_confirm "Proceed with installation?" "y"; then log_info "Installation cancelled." exit 0 fi } save_credentials_file() { if [[ "$DRY_RUN" == true ]]; then return 0 fi if ! tui_confirm "Save credentials to credentials.txt (mode 600)?" "y"; then return 0 fi cat > credentials.txt << EOF AdventureLog credentials — $(date) Site URL: ${SITE_URL} Admin username: ${DJANGO_ADMIN_USERNAME} Admin password: ${DJANGO_ADMIN_PASSWORD} Database password: ${POSTGRES_PASSWORD} EOF chmod 600 credentials.txt log_success "Saved credentials.txt (keep this secure)" } print_standard_success() { print_success_banner log_success "AdventureLog is installed and ready." echo "" print_section "Your instance" print_summary_row "Open" "$SITE_URL" print_summary_row "Admin user" "$DJANGO_ADMIN_USERNAME" print_summary_row "Admin password" "$DJANGO_ADMIN_PASSWORD" print_summary_row "Config file" "$(pwd)/${ENV_FILE}" echo "" print_next_steps \ "Open ${SITE_URL} in your browser" \ "Sign in and change the default admin password" \ "Re-run the installer anytime for updates: curl -sSL https://get.adventurelog.app | bash" \ "View logs: docker logs ${LOG_CONTAINER} -f" print_footer } run_standard_install_wizard() { SETUP_TYPE="standard" resolve_compose_settings prompt_standard_core_config run_port_checks run_optional_features_wizard write_postgis_override show_standard_review }