add install.sh (v2.1.3 one-line installer release)
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266#!/usr/bin/env bash## Local DE Coach β one-line cross-platform installer (v1.0.0)## curl -fsSL https://istias.tech/install.sh | bash# curl -fsSL https://istias.tech/install.sh | bash -s -- --model vosk-small## What it does, end to end:# 1. Detects your OS + package manager (Arch pacman / Debian-Ubuntu apt /# Fedora dnf / macOS brew / Windows β WSL2 guidance).# 2. Installs the system dependencies (python3, ffmpeg, node, npm, git...).# 3. Downloads the project ZIP β NO GitHub login needed (HuggingFace mirror,# GitHub codeload fallback).# 4. Runs ./setup.sh β the interactive model menu appears, you pick the ASR# model, setup continues by itself until fully finished.# 5. Prints your START / STOP commands β you only have to remember two.## Flags:# --model <name> skip the menu: distil | turbo-de | vosk-de | vosk-small | large-de# -y, --yes non-interactive (no questions, defaults everywhere)# --dir <path> install location (default: ./local-de-coach next to where you run it)# --no-sysdeps don't touch system packages (deps already installed)# --dry-run show the plan, change nothing# --zip-url <url> override download URL (advanced)# --help#set -euo pipefail
# βββ Colors (TTY-aware) βββββββββββββββββββββββββββββββββββββββββββββββββββββif [[ -t 1 ]]; then RED=$'\033[0;31m'; GREEN=$'\033[0;32m'; YELLOW=$'\033[0;33m' BLUE=$'\033[0;34m'; CYAN=$'\033[0;36m'; BOLD=$'\033[1m'; NC=$'\033[0m'else RED=''; GREEN=''; YELLOW=''; BLUE=''; CYAN=''; BOLD=''; NC=''fiRULE="ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"hr() { printf " ${DIM}%s${NC}\n" "$RULE" 2>/dev/null || printf " %s\n" "$RULE"; }log() { printf " ${BLUE}Β·${NC} %s\n" "$*"; }ok() { printf " ${GREEN}β${NC} %s\n" "$*"; }warn(){ printf " ${YELLOW}!${NC} %s\n" "$*"; }err() { printf " ${RED}β${NC} %s\n" "$*" >&2; exit 1; }info(){ printf " ${CYAN}β${NC} %s\n" "$*"; }# DIM may be unset in the non-TTY branch above β define it unconditionally.DIM="${DIM:-}"
VERSION_ZIP="Local-DE-Coach-2.1.3.zip"ZIP_PRIMARY="https://huggingface.co/Local-DE-Coach/app/resolve/main/${VERSION_ZIP}"ZIP_FALLBACK="https://huggingface.co/Local-DE-Coach/app/resolve/main/Local-DE-Coach-latest.zip"
MODEL_ARG=""ASSUME_YES=falseNO_SYSDEPS=falseDRY_RUN=falseDEST_DIR=""ZIP_URL="$ZIP_PRIMARY"
usage() { sed -n '2,30p' "$0" | sed 's/^# \{0,1\}//'; exit 0; }
while [[ $# -gt 0 ]]; do case "$1" in --model) [[ $# -lt 2 ]] && err "--model needs a value"; MODEL_ARG="$2"; shift 2 ;; --model=*) MODEL_ARG="${1#--model=}"; shift ;; -y|--yes) ASSUME_YES=true; shift ;; --no-sysdeps) NO_SYSDEPS=true; shift ;; --dry-run) DRY_RUN=true; shift ;; --dir) [[ $# -lt 2 ]] && err "--dir needs a path"; DEST_DIR="$2"; shift 2 ;; --zip-url) [[ $# -lt 2 ]] && err "--zip-url needs a URL"; ZIP_URL="$2"; shift 2 ;; -h|--help) usage ;; *) err "unknown option: $1 (try --help)" ;; esacdone
# βββ Banner βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββprintf "\n${BOLD} Local DE Coach β installer${NC}\n"hr
# βββ 1. Detect OS + package manager βββββββββββββββββββββββββββββββββββββββββOS_NAME="$(uname -s)"ARCH="$(uname -m)"PKG_MGR=""; OS_LABEL=""
case "$OS_NAME" in Linux) OS_LABEL="Linux (${ARCH})" if command -v apt-get >/dev/null 2>&1; then PKG_MGR="apt" elif command -v pacman >/dev/null 2>&1; then PKG_MGR="pacman" elif command -v dnf >/dev/null 2>&1; then PKG_MGR="dnf" elif command -v yum >/dev/null 2>&1; then PKG_MGR="dnf" elif command -v zypper >/dev/null 2>&1; then PKG_MGR="zypper" fi # WSL marker if grep -qi microsoft /proc/version 2>/dev/null; then OS_LABEL="${OS_LABEL} β WSL2"; fi ;; Darwin) OS_LABEL="macOS (${ARCH})"; PKG_MGR="brew" ;; MINGW*|MSYS*|CYGWIN*) printf "\n${RED}β Windows shell detected (Git Bash / MSYS).${NC}\n" printf "\n ${BOLD}Local DE Coach on Windows β use WSL2 (takes 3 minutes):${NC}\n\n" printf " 1. Open PowerShell ${BOLD}as Administrator${NC} and run:\n" printf " wsl --install -d Ubuntu\n" printf " 2. Reboot when asked, open the ${BOLD}Ubuntu${NC} app, create a user.\n" printf " 3. Inside Ubuntu run the SAME one-line command:\n" printf " ${CYAN}curl -fsSL https://istias.tech/install.sh | bash${NC}\n\n" exit 1 ;; *) err "unsupported OS: $OS_NAME (use Linux, macOS, or Windows via WSL2)" ;;esac
log "Detected: ${BOLD}${OS_LABEL}${NC} Β· package manager: ${BOLD}${PKG_MGR:-none}${NC}"if [[ -z "$PKG_MGR" ]]; then warn "No known package manager found β continuing WITHOUT system-dep install." warn "Make sure you already have: python3 + pip + venv, ffmpeg, node β₯18, npm, git." NO_SYSDEPS=truefi
# βββ 2. System dependencies βββββββββββββββββββββββββββββββββββββββββββββββββSUDO=""if [[ $EUID -ne 0 ]] && command -v sudo >/dev/null 2>&1; then SUDO="sudo"; fi
missing_cmds() { local miss=() for c in "$@"; do command -v "$c" >/dev/null 2>&1 || miss+=("$c"); done [[ ${#miss[@]} -eq 0 ]] && return 0 || printf '%s\n' "${miss[@]}"}
node_ok() { command -v node >/dev/null 2>&1 && [[ "$(node -v | sed 's/v\([0-9]*\).*/\1/')" -ge 18 ]]; }
# packages per manager: (cmd-needed β package(s))install_sysdeps() { case "$PKG_MGR" in pacman) $SUDO pacman -Sy --needed --noconfirm curl python python-pip ffmpeg libsndfile base-devel nodejs npm git aria2 unzip ;; apt) $SUDO apt-get update -qq $SUDO DEBIAN_FRONTEND=noninteractive apt-get install -y -qq \ curl ca-certificates python3 python3-venv python3-pip ffmpeg \ libsndfile1 build-essential git aria2 unzip # Debian/Ubuntu often ship node < 18 β use NodeSource 20.x when needed if ! node_ok; then warn "node β₯18 not found β installing NodeSource 20.x" curl -fsSL https://deb.nodesource.com/setup_20.x | $SUDO -E bash - $SUDO DEBIAN_FRONTEND=noninteractive apt-get install -y -qq nodejs fi ;; dnf) $SUDO dnf install -y curl python3 python3-pip ffmpeg nodejs npm \ gcc-c++ make git libsndfile unzip 2>/dev/null \ || $SUDO dnf install -y curl python3 python3-pip nodejs npm gcc-c++ make git unzip node_ok || { warn "node β₯18 missing β see https://nodejs.org (dnf repo too old)"; return 1; } ;; zypper) $SUDO zypper install -y curl python3 python3-pip python3-venv ffmpeg nodejs npm \ gcc-c++ make git libsndfile1 unzip ;; brew) command -v brew >/dev/null 2>&1 || { warn "Homebrew missing β install it first:" warn ' /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"' return 1; } brew install curl python ffmpeg node git unzip aria2 ;; esac}
if $NO_SYSDEPS; then ok "System deps: skipped (--no-sysdeps)"else info "Step 1/4 Β· system dependencies" $DRY_RUN && { log "(dry-run) would run: install_sysdeps via $PKG_MGR"; } || { install_sysdeps || err "system dependency install failed β fix the error above or re-run with --no-sysdeps" } # sanity check the critical tools if ! $DRY_RUN; then MISSING="$(missing_cmds python3 pip3 ffmpeg git || true)" if [[ -n "$MISSING" ]]; then warn "still missing after install: $MISSING" $ASSUME_YES || { printf " continue anyway? [y/N] "; read -r ANSWER < /dev/tty || ANSWER=n [[ "$ANSWER" == y || "$ANSWER" == Y ]] || err "aborted β install the tools above and re-run"; } fi fi ok "System deps ready"fi
# βββ 3. Download + extract the project (NO GitHub login) ββββββββββββββββββββinfo "Step 2/4 Β· download the project (no login needed)"if [[ -z "$DEST_DIR" ]]; then DEST_DIR="${LOCAL_DE_COACH_DIR:-$PWD/local-de-coach}"fiDEST_DIR="$(mkdir -p "$DEST_DIR" && cd "$DEST_DIR" && pwd)"
if $DRY_RUN; then log "(dry-run) would download: $ZIP_URL" log "(dry-run) would extract into: $DEST_DIR"else dl() { curl -fL --retry 3 --retry-delay 2 --connect-timeout 20 -o "$1" "$2"; } TMP_ZIP="$DEST_DIR/.download.zip" log "downloading $VERSION_ZIP ..." if ! dl "$TMP_ZIP" "$ZIP_URL"; then warn "primary mirror failed β trying fallback" dl "$TMP_ZIP" "$ZIP_FALLBACK" || err "download failed β check your internet and re-run" fi # verify it is a real zip (> 500 KB) using python3 (unzip is not always installed) python3 - "$TMP_ZIP" <<'PY' || err "downloaded file is not a valid ZIP β re-run"import sys, zipfile, osp = sys.argv[1]assert os.path.getsize(p) > 500_000, "zip too small"with zipfile.ZipFile(p) as z: assert z.testzip() is None, "zip corrupt"print("zip OK:", len(z.namelist()), "files")PY EXTRACT_INTO="$DEST_DIR/app" if [[ -d "$EXTRACT_INTO" ]]; then mv "$EXTRACT_INTO" "${EXTRACT_INTO}.bak.$(date +%s)" warn "existing app/ moved aside (*.bak.*)" fi mkdir -p "$EXTRACT_INTO" python3 -c "import zipfile,sys; zipfile.ZipFile(sys.argv[1]).extractall(sys.argv[2])" "$TMP_ZIP" "$EXTRACT_INTO" rm -f "$TMP_ZIP" ok "extracted β $EXTRACT_INTO"fiAPP_DIR="$DEST_DIR/app"
# βββ 4. Model selection + setup (runs until fully finished) ββββββββββββββοΏ½οΏ½ββinfo "Step 3/4 Β· model selection + full setup"if $DRY_RUN; then log "(dry-run) would run: ./setup.sh --no-sysdeps ${MODEL_ARG:+--model $MODEL_ARG}" log " model menu: distil (default) / turbo-de / vosk-de / vosk-small (β€512MB RAM) / large-de"else chmod +x "$APP_DIR/setup.sh" "$APP_DIR/DE-Coach" 2>/dev/null || true SETUP_ARGS=(--no-sysdeps) if [[ -n "$MODEL_ARG" ]]; then SETUP_ARGS+=(--model "$MODEL_ARG"); fi
# `curl | bash` consumes stdin with the script β reattach stdin to the # terminal so setup.sh's interactive model menu still works. if ! $ASSUME_YES && [[ -t 0 || -e /dev/tty ]]; then log "opening the model menu β pick what you want:" bash "$APP_DIR/setup.sh" "${SETUP_ARGS[@]}" < /dev/tty else log "non-interactive mode β running setup with default model (distil)" bash "$APP_DIR/setup.sh" "${SETUP_ARGS[@]}" --model "${MODEL_ARG:-distil}" fifi
# βββ 5. Finish β the only commands the user needs βββββββββββββββββββββββββββinfo "Step 4/4 Β· writing your command cheat-sheet"CHEAT="$DEST_DIR/COMMANDS.txt"cat > "$CHEAT" <<EOFLocal DE Coach β your commands==============================
cd $APP_DIR
./DE-Coach --start START the app β open http://127.0.0.1:33111 ./DE-Coach --server START for LAN/VPS (reachable from other devices) ./DE-Coach --stop STOP everything ./DE-Coach --dev dev mode (live logs in this terminal)
Logs: ./logs/ Switch ASR model: ./setup.sh --model vosk-small (or distil / turbo-de / vosk-de / large-de) Re-run setup: ./setup.sh --no-sysdepsEOFok "cheat-sheet saved β $CHEAT"
printf "\n"printf " ${GREEN}${BOLD}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}\n"printf " ${GREEN}${BOLD} Install complete!${NC}\n"printf " ${GREEN}${BOLD}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}\n\n"printf " ${BOLD}Your commands${NC} (also saved in COMMANDS.txt):\n\n"printf " ${CYAN}cd $APP_DIR${NC}\n\n"printf " ${GREEN}./DE-Coach --start${NC} ${DIM}# START β http://127.0.0.1:33111${NC}\n"printf " ${GREEN}./DE-Coach --server${NC} ${DIM}# START for LAN / VPS (0.0.0.0)${NC}\n"printf " ${GREEN}./DE-Coach --stop${NC} ${DIM}# STOP everything${NC}\n\n"printf " ${DIM}Switch model later: ./setup.sh --model <name> (nothing is re-downloaded)${NC}\n"printf "\n"install.shAdded+266