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
|
## Quick install
|
||||||
|
|
||||||
```bash
|
```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:
|
Or clone and run:
|
||||||
|
|||||||
+24
-18
@@ -3,6 +3,14 @@
|
|||||||
# https://github.com/outis1one/openwhispr-easy-setup
|
# https://github.com/outis1one/openwhispr-easy-setup
|
||||||
# License: MIT
|
# 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
|
# Do NOT use set -e — we handle errors explicitly
|
||||||
|
|
||||||
readonly SCRIPT_VERSION="1.0.0"
|
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 GITHUB_API="https://api.github.com/repos/OpenWhispr/openwhispr/releases/latest"
|
||||||
readonly TMP_DIR="/tmp/openwhispr-install"
|
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 ─────────────────────────────────────────────────────
|
# ── Colours & formatting ─────────────────────────────────────────────────────
|
||||||
|
|
||||||
if [[ -t 1 ]]; then
|
if [[ -t 1 ]]; then
|
||||||
@@ -48,8 +49,8 @@ divider() { printf "${DIM}━━━━━━━━━━━━━━━━━━
|
|||||||
prompt_default() {
|
prompt_default() {
|
||||||
# Usage: prompt_default "prompt text" "default" VARNAME
|
# Usage: prompt_default "prompt text" "default" VARNAME
|
||||||
local prompt="$1" default="$2" varname="$3" reply
|
local prompt="$1" default="$2" varname="$3" reply
|
||||||
printf "%s [default: %s]: " "$prompt" "$default"
|
printf "%s [default: %s]: " "$prompt" "$default" > /dev/tty
|
||||||
read -r reply
|
read -r reply < /dev/tty
|
||||||
reply="${reply:-$default}"
|
reply="${reply:-$default}"
|
||||||
printf -v "$varname" '%s' "$reply"
|
printf -v "$varname" '%s' "$reply"
|
||||||
}
|
}
|
||||||
@@ -57,9 +58,9 @@ prompt_default() {
|
|||||||
prompt_hidden() {
|
prompt_hidden() {
|
||||||
# Usage: prompt_hidden "prompt text" VARNAME
|
# Usage: prompt_hidden "prompt text" VARNAME
|
||||||
local prompt="$1" varname="$2" reply
|
local prompt="$1" varname="$2" reply
|
||||||
printf "%s: " "$prompt"
|
printf "%s: " "$prompt" > /dev/tty
|
||||||
read -rs reply
|
read -rs reply < /dev/tty
|
||||||
printf "\n"
|
printf "\n" > /dev/tty
|
||||||
printf -v "$varname" '%s' "$reply"
|
printf -v "$varname" '%s' "$reply"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,8 +124,8 @@ This script will:
|
|||||||
6. Launch OpenWhispr for first-run setup
|
6. Launch OpenWhispr for first-run setup
|
||||||
INTRO
|
INTRO
|
||||||
divider
|
divider
|
||||||
printf "\nPress Enter to continue or Ctrl-C to cancel... "
|
printf "\nPress Enter to continue or Ctrl-C to cancel... " > /dev/tty
|
||||||
read -r
|
read -r < /dev/tty
|
||||||
|
|
||||||
# ══════════════════════════════════════════════════════════════════════════════
|
# ══════════════════════════════════════════════════════════════════════════════
|
||||||
# [2/8] Detect distro + arch
|
# [2/8] Detect distro + arch
|
||||||
@@ -183,8 +184,8 @@ fi
|
|||||||
|
|
||||||
if ! command_exists jq; then
|
if ! command_exists jq; then
|
||||||
warn "jq is required but not installed."
|
warn "jq is required but not installed."
|
||||||
printf "Install jq now? [Y/n]: "
|
printf "Install jq now? [Y/n]: " > /dev/tty
|
||||||
read -r jq_reply
|
read -r jq_reply < /dev/tty
|
||||||
jq_reply="${jq_reply:-Y}"
|
jq_reply="${jq_reply:-Y}"
|
||||||
if [[ "${jq_reply,,}" == "y" ]]; then
|
if [[ "${jq_reply,,}" == "y" ]]; then
|
||||||
case "$DISTRO_FAMILY" in
|
case "$DISTRO_FAMILY" in
|
||||||
@@ -526,8 +527,8 @@ case "$CLEANUP_CHOICE" in
|
|||||||
ollama pull llama3.1
|
ollama pull llama3.1
|
||||||
|
|
||||||
OLLAMA_INFO
|
OLLAMA_INFO
|
||||||
printf "Install Ollama now? [Y/n]: "
|
printf "Install Ollama now? [Y/n]: " > /dev/tty
|
||||||
read -r ollama_reply
|
read -r ollama_reply < /dev/tty
|
||||||
ollama_reply="${ollama_reply:-Y}"
|
ollama_reply="${ollama_reply:-Y}"
|
||||||
if [[ "${ollama_reply,,}" == "y" ]]; then
|
if [[ "${ollama_reply,,}" == "y" ]]; then
|
||||||
curl -fsSL https://ollama.ai/install.sh | sh || {
|
curl -fsSL https://ollama.ai/install.sh | sh || {
|
||||||
@@ -660,3 +661,8 @@ cat <<EOF
|
|||||||
EOF
|
EOF
|
||||||
divider
|
divider
|
||||||
printf "\n"
|
printf "\n"
|
||||||
|
|
||||||
|
} # end main()
|
||||||
|
|
||||||
|
# Call main — this ensures the entire script is parsed before execution
|
||||||
|
main "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user