diff --git a/installer/install.sh b/installer/install.sh index ebc628a..09c511b 100644 --- a/installer/install.sh +++ b/installer/install.sh @@ -1215,3 +1215,84 @@ print_summary() { echo " docker compose -p $COMPOSE_PROJECT down # stop" echo "" } + +# --- Re-run and upgrade --- + +show_rerun_menu() { + local current_version + current_version=$(grep '^version=' "$INSTALL_DIR/cameleer.conf" 2>/dev/null | cut -d= -f2 || echo "unknown") + local current_host + current_host=$(grep '^public_host=' "$INSTALL_DIR/cameleer.conf" 2>/dev/null | cut -d= -f2 || echo "unknown") + + echo "" + echo -e "${BOLD}Existing Cameleer installation detected (v${current_version})${NC}" + echo " Install directory: $INSTALL_DIR" + echo " Public host: $current_host" + echo "" + + if [ "$MODE" = "silent" ]; then + RERUN_ACTION="${RERUN_ACTION:-upgrade}" + return + fi + + if [ -n "$RERUN_ACTION" ]; then return; fi + + local new_version="${VERSION:-$CAMELEER_DEFAULT_VERSION}" + echo " [1] Upgrade to v${new_version} (pull new images, update compose)" + echo " [2] Reconfigure (re-run interactive setup, preserve data)" + echo " [3] Reinstall (fresh install, WARNING: destroys data volumes)" + echo " [4] Cancel" + echo "" + + local choice + read -rp " Select [1]: " choice + case "${choice:-1}" in + 1) RERUN_ACTION="upgrade" ;; + 2) RERUN_ACTION="reconfigure" ;; + 3) RERUN_ACTION="reinstall" ;; + 4) echo "Cancelled."; exit 0 ;; + *) echo "Invalid choice."; exit 1 ;; + esac +} + +handle_rerun() { + case "$RERUN_ACTION" in + upgrade) + log_info "Upgrading installation..." + load_config_file "$INSTALL_DIR/cameleer.conf" + load_env_overrides + merge_config + generate_compose_file + docker_compose_pull + docker_compose_down + docker_compose_up + verify_health + generate_install_doc + print_summary + exit 0 + ;; + reconfigure) + log_info "Reconfiguring installation..." + return + ;; + reinstall) + if [ "${CONFIRM_DESTROY}" != "true" ]; then + echo "" + log_warn "This will destroy ALL data (databases, certificates, bootstrap)." + if ! prompt_yesno "Are you sure? This cannot be undone."; then + echo "Cancelled." + exit 0 + fi + fi + log_info "Reinstalling..." + docker_compose_down 2>/dev/null || true + (cd "$INSTALL_DIR" && docker compose -p "${COMPOSE_PROJECT:-cameleer-saas}" down -v 2>/dev/null || true) + rm -f "$INSTALL_DIR/.env" "$INSTALL_DIR/docker-compose.yml" \ + "$INSTALL_DIR/cameleer.conf" "$INSTALL_DIR/credentials.txt" \ + "$INSTALL_DIR/INSTALL.md" "$INSTALL_DIR/.env.bak" + rm -rf "$INSTALL_DIR/certs" + IS_RERUN=false + return + ;; + esac +}