From 4fc9f1385e98894294cc46373ed206f596fc8850 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 24 May 2026 13:56:42 +0000 Subject: [PATCH] setup: fix openwebui detection and doubled y/n prompt * check_tool openwebui now does an HTTP probe via curl, treating any response (including 401/403) as reachable. The previous /dev/tcp socket check failed silently in shells without that feature, making install_tool falsely claim OpenWebUI wasn't running. * _sv_confirm in kickoff.sh was rendering "[Y] [Y]" because it baked the default into the prompt and then _sv_read appended it again. It now formats a proper "Y/n" / "y/N" hint like _it_confirm does. --- kickoff.sh | 10 ++++++++-- scripts/install_tool.sh | 20 +++++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/kickoff.sh b/kickoff.sh index 2a843f0..44c3a26 100644 --- a/kickoff.sh +++ b/kickoff.sh @@ -87,8 +87,14 @@ _clk_setup() { } _sv_confirm() { - local prompt="$1" default="${2:-N}" v - v="$(_sv_read "$prompt [$default]" "$default")" + local prompt="$1" default="${2:-N}" v hint + case "${default^^}" in + Y|YES) hint="Y/n" ;; + *) hint="y/N" ;; + esac + printf '%s [%s]: ' "$prompt" "$hint" >&4 + IFS= read -r v <&3 || v="" + v="${v:-$default}" case "${v,,}" in y|yes) return 0 ;; *) return 1 ;; esac } diff --git a/scripts/install_tool.sh b/scripts/install_tool.sh index 54d4127..d626662 100755 --- a/scripts/install_tool.sh +++ b/scripts/install_tool.sh @@ -179,10 +179,28 @@ check_tool() { ;; openwebui) local endpoint="${CLK_OPENWEBUI_ENDPOINT:-http://localhost:8080}" + # Prefer an HTTP probe — many minimal shells lack /dev/tcp, and we + # care that OpenWebUI is *responding*, not just that a port is open. + # Any HTTP status (including 401/403 for authenticated instances) + # counts as reachable. + if _it_has curl; then + local code + code="$(curl -sS -o /dev/null -m 4 -w '%{http_code}' "$endpoint" 2>/dev/null || echo 000)" + [ "$code" != "000" ] && return 0 + # Also try the health endpoint that OpenWebUI exposes. + code="$(curl -sS -o /dev/null -m 4 -w '%{http_code}' "${endpoint%/}/health" 2>/dev/null || echo 000)" + [ "$code" != "000" ] && return 0 + fi + # Fallback: raw TCP probe for environments without curl. local host port host="$(echo "$endpoint" | sed -E 's|^https?://||; s|/.*||; s|:.*||')" port="$(echo "$endpoint" | sed -nE 's|^https?://[^:/]+:([0-9]+).*|\1|p')" - port="${port:-8080}" + if [ -z "$port" ]; then + case "$endpoint" in + https://*) port=443 ;; + *) port=8080 ;; + esac + fi (echo > "/dev/tcp/$host/$port") 2>/dev/null ;; *)