Merge pull request #3 from outis1one/claude/create-bash-installer-GSmST
Claude/create bash installer g sm st
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
## Quick install
|
||||
|
||||
```bash
|
||||
bash <(curl -fsSL https://raw.githubusercontent.com/outis1one/openwhispr-easy-setup/main/setup-openwhispr.sh)
|
||||
curl -fsSL https://raw.githubusercontent.com/outis1one/openwhispr-easy-setup/main/setup-openwhispr.sh -o /tmp/setup-openwhispr.sh && bash /tmp/setup-openwhispr.sh
|
||||
```
|
||||
|
||||
Or clone and run:
|
||||
|
||||
+24
-18
@@ -3,6 +3,14 @@
|
||||
# https://github.com/outis1one/openwhispr-easy-setup
|
||||
# License: MIT
|
||||
|
||||
# ── Wrap everything in main() so bash reads the entire script before executing.
|
||||
# This prevents the "line-by-line interpreted as commands" bug when run via:
|
||||
# bash <(curl -fsSL ...) or curl ... | bash
|
||||
# Without this wrapper, bash may lose track of the script source after a read
|
||||
# from /dev/tty and start feeding remaining script lines to the shell prompt.
|
||||
|
||||
main() {
|
||||
|
||||
# Do NOT use set -e — we handle errors explicitly
|
||||
|
||||
readonly SCRIPT_VERSION="1.0.0"
|
||||
@@ -11,13 +19,6 @@ readonly MARKER="# Added by openwhispr-easy-setup"
|
||||
readonly GITHUB_API="https://api.github.com/repos/OpenWhispr/openwhispr/releases/latest"
|
||||
readonly TMP_DIR="/tmp/openwhispr-install"
|
||||
|
||||
# ── Ensure interactive input works when piped (bash <(curl ...)) ──────────────
|
||||
# When run via bash <(curl ...), stdin is the curl stream, not the terminal.
|
||||
# We must read user input from /dev/tty instead.
|
||||
if [[ ! -t 0 ]] && [[ -e /dev/tty ]]; then
|
||||
exec < /dev/tty
|
||||
fi
|
||||
|
||||
# ── Colours & formatting ─────────────────────────────────────────────────────
|
||||
|
||||
if [[ -t 1 ]]; then
|
||||
@@ -48,8 +49,8 @@ divider() { printf "${DIM}━━━━━━━━━━━━━━━━━━
|
||||
prompt_default() {
|
||||
# Usage: prompt_default "prompt text" "default" VARNAME
|
||||
local prompt="$1" default="$2" varname="$3" reply
|
||||
printf "%s [default: %s]: " "$prompt" "$default"
|
||||
read -r reply
|
||||
printf "%s [default: %s]: " "$prompt" "$default" > /dev/tty
|
||||
read -r reply < /dev/tty
|
||||
reply="${reply:-$default}"
|
||||
printf -v "$varname" '%s' "$reply"
|
||||
}
|
||||
@@ -57,9 +58,9 @@ prompt_default() {
|
||||
prompt_hidden() {
|
||||
# Usage: prompt_hidden "prompt text" VARNAME
|
||||
local prompt="$1" varname="$2" reply
|
||||
printf "%s: " "$prompt"
|
||||
read -rs reply
|
||||
printf "\n"
|
||||
printf "%s: " "$prompt" > /dev/tty
|
||||
read -rs reply < /dev/tty
|
||||
printf "\n" > /dev/tty
|
||||
printf -v "$varname" '%s' "$reply"
|
||||
}
|
||||
|
||||
@@ -123,8 +124,8 @@ This script will:
|
||||
6. Launch OpenWhispr for first-run setup
|
||||
INTRO
|
||||
divider
|
||||
printf "\nPress Enter to continue or Ctrl-C to cancel... "
|
||||
read -r
|
||||
printf "\nPress Enter to continue or Ctrl-C to cancel... " > /dev/tty
|
||||
read -r < /dev/tty
|
||||
|
||||
# ══════════════════════════════════════════════════════════════════════════════
|
||||
# [2/8] Detect distro + arch
|
||||
@@ -183,8 +184,8 @@ fi
|
||||
|
||||
if ! command_exists jq; then
|
||||
warn "jq is required but not installed."
|
||||
printf "Install jq now? [Y/n]: "
|
||||
read -r jq_reply
|
||||
printf "Install jq now? [Y/n]: " > /dev/tty
|
||||
read -r jq_reply < /dev/tty
|
||||
jq_reply="${jq_reply:-Y}"
|
||||
if [[ "${jq_reply,,}" == "y" ]]; then
|
||||
case "$DISTRO_FAMILY" in
|
||||
@@ -526,8 +527,8 @@ case "$CLEANUP_CHOICE" in
|
||||
ollama pull llama3.1
|
||||
|
||||
OLLAMA_INFO
|
||||
printf "Install Ollama now? [Y/n]: "
|
||||
read -r ollama_reply
|
||||
printf "Install Ollama now? [Y/n]: " > /dev/tty
|
||||
read -r ollama_reply < /dev/tty
|
||||
ollama_reply="${ollama_reply:-Y}"
|
||||
if [[ "${ollama_reply,,}" == "y" ]]; then
|
||||
curl -fsSL https://ollama.ai/install.sh | sh || {
|
||||
@@ -660,3 +661,8 @@ cat <<EOF
|
||||
EOF
|
||||
divider
|
||||
printf "\n"
|
||||
|
||||
} # end main()
|
||||
|
||||
# Call main — this ensures the entire script is parsed before execution
|
||||
main "$@"
|
||||
|
||||
Reference in New Issue
Block a user