Upload install.sh with huggingface_hub
Browse files1234563 unmodified lines1011121314151617181920212223244 unmodified lines29303132333435363738394041424344454647484950511 unmodified line535455565758596061626364656667686970717273747576779 unmodified lines8788899091929394959624 unmodified lines12112212312412512612712812913013113213313413513613712 unmodified lines1501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911927 unmodified lines2002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392406 unmodified lines247248249250251252253254255256257258259260261262263264265266#!/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-small3 unmodified lines# 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)4 unmodified lines# βββ Colors (TTY-aware) βββββββββββββββββββββββββββββββββββββββββββββββββββββif [[ -t 1 ]]; thenRED=$'\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'elseRED=''; 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=false1 unmodified lineDRY_RUN=falseDEST_DIR=""ZIP_URL="$ZIP_PRIMARY"usage() { sed -n '2,30p' "$0" | sed 's/^# \{0,1\}//'; exit 0; }while [[ $# -gt 0 ]]; docase "$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 βββββββββββββββββββββββββββββββββββββββββ9 unmodified lineselif 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 markerif 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"24 unmodified linesnode_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" inpacman)$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 neededif ! node_ok; thenwarn "node β₯18 not found β installing NodeSource 20.x"curl -fsSL https://deb.nodesource.com/setup_20.x | $SUDO -E bash -12 unmodified lineswarn "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; thenok "System deps: skipped (--no-sysdeps)"elseinfo "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 toolsif ! $DRY_RUN; thenMISSING="$(missing_cmds python3 pip3 ffmpeg git || true)"if [[ -n "$MISSING" ]]; thenwarn "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"; }fifiok "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" ]]; thenDEST_DIR="${LOCAL_DE_COACH_DIR:-$PWD/local-de-coach}"fiDEST_DIR="$(mkdir -p "$DEST_DIR" && cd "$DEST_DIR" && pwd)"if $DRY_RUN; thenlog "(dry-run) would download: $ZIP_URL"log "(dry-run) would extract into: $DEST_DIR"elsedl() { 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"; thenwarn "primary mirror failed β trying fallback"dl "$TMP_ZIP" "$ZIP_FALLBACK" || err "download failed β check your internet and re-run"7 unmodified linesassert z.testzip() is None, "zip corrupt"print("zip OK:", len(z.namelist()), "files")PYEXTRACT_INTO="$DEST_DIR/app"if [[ -d "$EXTRACT_INTO" ]]; thenmv "$EXTRACT_INTO" "${EXTRACT_INTO}.bak.$(date +%s)"warn "existing app/ moved aside (*.bak.*)"fimkdir -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; thenlog "(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"elsechmod +x "$APP_DIR/setup.sh" "$APP_DIR/DE-Coach" 2>/dev/null || trueSETUP_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 ]]; thenlog "opening the model menu β pick what you want:"bash "$APP_DIR/setup.sh" "${SETUP_ARGS[@]}" < /dev/ttyelselog "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 commands6 unmodified lines./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"1234563 unmodified lines101112131415161718192021222324252627282930313233344 unmodified lines394041424344454647484950515253545556575859601 unmodified line626364656667686970717273747576777879808182838485868788899091929394959 unmodified lines10510610710810911011111211324 unmodified lines13813914014114214314414514614714814915015115212 unmodified lines1651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243257 unmodified lines3333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374386 unmodified lines445446447448449450451452453454455456457458459460461462463464465466467468469#!/usr/bin/env bash## Local DE Coach β one-line cross-platform installer (v1.1.0)## curl -fsSL https://istias.tech/install.sh | bash# curl -fsSL https://istias.tech/install.sh | bash -s -- --model vosk-small3 unmodified lines# 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,# same URL every time β always the newest version).# 4. If an install already exists β you pick:# [1] UPDATE it (keeps venv, models, your model choice β code only)# [2] CHANGE the ASR model only (no download if already on disk)# [3] FRESH install (wipe + reinstall)# 5. Runs ./setup.sh β the interactive model menu appears, models already# on disk are marked, you can also pick "use an already-downloaded# model". Setup continues by itself until fully finished.# 6. Prints your START / STOP commands β you only have to remember two.## Re-running the SAME one-liner later = update to the newest version.## 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, or the last install)# --update force UPDATE mode on an existing install# --change-model only switch the ASR model on an existing install (fast)# --fresh wipe + reinstall (no venv / model preservation)# --no-sysdeps don't touch system packages (deps already installed)# --dry-run show the plan, change nothing# --zip-url <url> override download URL (advanced)4 unmodified lines# βββ Colors (TTY-aware) βββββββββββββββββββββββββββββββββββββββββββββββββββββif [[ -t 1 ]]; thenRED=$'\033[0;31m'; GREEN=$'\033[0;32m'; YELLOW=$'\033[0;33m'BLUE=$'\033[0;34m'; CYAN=$'\033[0;36m'; BOLD=$'\033[1m'DIM=$'\033[2m'; NC=$'\033[0m'elseRED=''; GREEN=''; YELLOW=''; BLUE=''; CYAN=''; BOLD=''; DIM=''; NC=''fiRULE="ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"hr() { printf " ${DIM}%s${NC}\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" "$*"; }ZIP_PRIMARY="https://huggingface.co/Local-DE-Coach/app/resolve/main/Local-DE-Coach-latest.zip"ZIP_FALLBACK="https://huggingface.co/Local-DE-Coach/app/resolve/main/Local-DE-Coach-2.1.4.zip"POINTER="$HOME/.cache/local-de-coach/last-install"MODEL_ARG=""ASSUME_YES=false1 unmodified lineDRY_RUN=falseDEST_DIR=""ZIP_URL="$ZIP_PRIMARY"ACTION="" # "" | update | model | freshusage() { sed -n '2,33p' "$0" | sed 's/^# \{0,1\}//'; exit 0; }while [[ $# -gt 0 ]]; docase "$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 ;;--update) ACTION="update"; shift ;;--change-model|--model-only) ACTION="model"; shift ;;--fresh) ACTION="fresh"; shift ;;-h|--help) usage ;;*) err "unknown option: $1 (try --help)" ;;esacdonecase "$MODEL_ARG" in""|distil|turbo-de|vosk-de|vosk-small|large-de) : ;;*) err "unknown model '$MODEL_ARG' β pick: distil | turbo-de | vosk-de | vosk-small | large-de" ;;esac# βββ Banner βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββprintf "\n${BOLD} Local DE Coach β installer v1.1.0${NC}\n"hr# βββ 1. Detect OS + package manager βββββββββββββββββββββββββββββββββββββββββ9 unmodified lineselif command -v yum >/dev/null 2>&1; then PKG_MGR="dnf"elif command -v zypper >/dev/null 2>&1; then PKG_MGR="zypper"fiif 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"24 unmodified linesnode_ok() { command -v node >/dev/null 2>&1 && [[ "$(node -v | sed 's/v\([0-9]*\).*/\1/')" -ge 18 ]]; }install_sysdeps() {case "$PKG_MGR" inpacman)$SUDO pacman -Sy --needed --noconfirm curl python python-pip ffmpeg libsndfile base-devel nodejs npm git 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 unzipif ! node_ok; thenwarn "node β₯18 not found β installing NodeSource 20.x"curl -fsSL https://deb.nodesource.com/setup_20.x | $SUDO -E bash -12 unmodified lineswarn "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 ;;esac}if [[ "$ACTION" != "model" ]]; thenif $NO_SYSDEPS; thenok "System deps: skipped (--no-sysdeps)"elseinfo "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"}if ! $DRY_RUN; thenMISSING="$(missing_cmds python3 pip3 ffmpeg git || true)"if [[ -n "$MISSING" ]]; thenwarn "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"; }fifiok "System deps ready"fifi# βββ 3. Where is the project? (new / existing install) ββββββββββββββββββββββ# Resolve install dir: --dir flag > ./local-de-coach > last installif [[ -z "$DEST_DIR" ]]; thenif [[ -d "${LOCAL_DE_COACH_DIR:-$PWD/local-de-coach}/app" ]]; thenDEST_DIR="${LOCAL_DE_COACH_DIR:-$PWD/local-de-coach}"elif [[ -f "$POINTER" ]] && [[ -d "$(cat "$POINTER" 2>/dev/null)/app" ]]; thenDEST_DIR="$(cat "$POINTER")"log "found your existing install: $DEST_DIR"elseDEST_DIR="${LOCAL_DE_COACH_DIR:-$PWD/local-de-coach}"fifiDEST_DIR="$(mkdir -p "$DEST_DIR" && cd "$DEST_DIR" && pwd)"APP_DIR="$DEST_DIR/app"EXISTING=falseAPP_VERSION=""; APP_MODEL=""if [[ -f "$APP_DIR/setup.sh" ]]; thenEXISTING=trueAPP_VERSION="$(sed -n 's/.*setup script (v\([0-9.]*\)).*/\1/p' "$APP_DIR/setup.sh" | head -1)"if [[ -f "$APP_DIR/backend/setup_state.json" ]]; thenAPP_MODEL="$(sed -n 's/.*"default_score_model": *"\([^"]*\)".*/\1/p' "$APP_DIR/backend/setup_state.json" | head -1)"[[ "$APP_MODEL" == "vosk" ]] && APP_MODEL="vosk-small"fifi# βββ Choose the action when an install already exists ββββββββββββββββββββββif [[ "$ACTION" == "model" && "$EXISTING" != "true" ]]; thenerr "no existing install at $APP_DIR β run the installer normally first"fiif [[ -z "$ACTION" ]]; thenif [[ "$EXISTING" == "true" ]]; thenif $ASSUME_YES; thenACTION="update"elseecho ""printf " ${BOLD}Existing install found${NC} ${DIM}${APP_DIR} (v${APP_VERSION:-?}${APP_MODEL:+ Β· model: ${APP_MODEL}})${NC}\n"hrprintf " ${BOLD}1${NC}) ${BOLD}Update${NC} to the newest version ${DIM}(keeps venv, models, settings)${NC}\n"printf " ${BOLD}2${NC}) ${BOLD}Change the ASR model only${NC} ${DIM}(already-downloaded models = no download)${NC}\n"printf " ${BOLD}3${NC}) ${BOLD}Fresh install${NC} ${DIM}(wipe + reinstall everything)${NC}\n"echo ""printf " ${CYAN}Choice [1-3, Enter=1]:${NC} "if [[ -t 0 ]]; then read -r CHOICE || CHOICE="1"; else CHOICE="1"; ficase "${CHOICE:-1}" in1) ACTION="update" ;;2) ACTION="model" ;;3) ACTION="fresh" ;;*) err "invalid choice '${CHOICE}'" ;;esacfielseACTION="install"fifi# βββ 4a. CHANGE-MODEL-ONLY fast path ββββββββββββββββββββββββββββββββββββββββif [[ "$ACTION" == "model" ]]; theninfo "Step 2/4 Β· change the ASR model (fast path β no code changes)"SETUP_ARGS=(--change-model)[[ -n "$MODEL_ARG" ]] && SETUP_ARGS+=(--model "$MODEL_ARG")if $DRY_RUN; thenlog "(dry-run) would run: setup.sh ${SETUP_ARGS[*]}"elsechmod +x "$APP_DIR/setup.sh" 2>/dev/null || trueif ! $ASSUME_YES && [[ -t 0 || -e /dev/tty ]]; thenbash "$APP_DIR/setup.sh" "${SETUP_ARGS[@]}" < /dev/ttyelse[[ -n "$MODEL_ARG" ]] || err "--yes needs --model <name> for --change-model"bash "$APP_DIR/setup.sh" "${SETUP_ARGS[@]}"fifi# ββ finish (same cheat-sheet as the main path)info "Step 3/4 Β· writing your command cheat-sheet"write_cheatsheet_and_finish() {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)Change ASR model: ./setup.sh --change-model(menu: download a new one OR use analready-downloaded model β no re-download)Switch model directly: ./setup.sh --model vosk-small (fits 500 MB RAM)Update to newest: curl -fsSL https://istias.tech/install.sh | bashLogs: ./logs/EOFok "cheat-sheet saved β $CHEAT"printf "\n"printf " ${GREEN}${BOLD}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}\n"printf " ${GREEN}${BOLD} Done β model switched!${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 --stop${NC} ${DIM}# STOP everything${NC}\n\n"printf " ${DIM}Update later (same URL): curl -fsSL https://istias.tech/install.sh | bash${NC}\n"printf "\n"}write_cheatsheet_and_finishexit 0fi# βββ 4b. Download + extract (UPDATE or INSTALL/FRESH) ββββββββββββββββββββββif [[ "$ACTION" == "update" ]]; theninfo "Step 2/4 Β· download the update (same URL, newest version)"elseinfo "Step 2/4 Β· download the project (no login needed)"fiif pgrep -f "uvicorn.*server:app" >/dev/null 2>&1 || pgrep -f "DE-Coach" >/dev/null 2>&1; thenwarn "the app seems to be RUNNING right now β updating files is safe,"warn "but restart it afterwards: ./DE-Coach --stop && ./DE-Coach --start"fiif $DRY_RUN; thenlog "(dry-run) would download: $ZIP_URL"log "(dry-run) would extract into: $DEST_DIR (action: $ACTION)"elsedl() { curl -fL --retry 3 --retry-delay 2 --connect-timeout 20 -o "$1" "$2"; }TMP_ZIP="$DEST_DIR/.download.zip"log "downloading latest version ..."if ! dl "$TMP_ZIP" "$ZIP_URL"; thenwarn "primary mirror failed β trying fallback"dl "$TMP_ZIP" "$ZIP_FALLBACK" || err "download failed β check your internet and re-run"7 unmodified linesassert z.testzip() is None, "zip corrupt"print("zip OK:", len(z.namelist()), "files")PY# extract into a staging dir, then swap β preserves venv + node_modulesSTAGE="$DEST_DIR/.app.new"rm -rf "$STAGE"mkdir -p "$STAGE"python3 -c "import zipfile,sys; zipfile.ZipFile(sys.argv[1]).extractall(sys.argv[2])" "$TMP_ZIP" "$STAGE"rm -f "$TMP_ZIP"# handle zips that ship a single top-level folderif [[ ! -f "$STAGE/setup.sh" ]]; thensub="$(find "$STAGE" -mindepth 1 -maxdepth 1 -type d | head -1)"if [[ -n "$sub" && -f "$sub/setup.sh" ]]; thenmv "$sub" "$STAGE/.inner" && rm -rf "$STAGE" && mv "$STAGE/.inner" "$STAGE"fifi[[ -f "$STAGE/setup.sh" ]] || err "extracted zip has no setup.sh β unexpected layout"NEW_VERSION="$(sed -n 's/.*setup script (v\([0-9.]*\)).*/\1/p' "$STAGE/setup.sh" | head -1)"ok "downloaded version: v${NEW_VERSION:-?}"fi# βββ 4c. Swap the code (preserving venv / node_modules / setup_state) ββββββif $DRY_RUN; thenlog "(dry-run) would swap code into $APP_DIR (action: $ACTION)"elseif [[ "$EXISTING" == "true" && "$ACTION" == "update" ]]; thenif [[ -n "$APP_VERSION" && "$APP_VERSION" == "$NEW_VERSION" ]]; thenlog "already at v$NEW_VERSION β refreshing files anyway (idempotent)"elselog "updating: v${APP_VERSION:-?} β v${NEW_VERSION:-?}"firm -rf "$DEST_DIR/app.bak"mv "$APP_DIR" "$DEST_DIR/app.bak"mv "$STAGE" "$APP_DIR"mkdir -p "$APP_DIR/backend" "$APP_DIR/frontend"# preserve: venv, node_modules, setup_state (remembers your model)if [[ -d "$DEST_DIR/app.bak/backend/.venv" ]]; thenmv "$DEST_DIR/app.bak/backend/.venv" "$APP_DIR/backend/.venv" && ok "kept: Python venv (no re-download of pip packages)"fiif [[ -d "$DEST_DIR/app.bak/frontend/node_modules" ]]; thenmv "$DEST_DIR/app.bak/frontend/node_modules" "$APP_DIR/frontend/node_modules" && ok "kept: node_modules (no re-download of npm packages)"fiif [[ -f "$DEST_DIR/app.bak/backend/setup_state.json" ]]; thencp "$DEST_DIR/app.bak/backend/setup_state.json" "$APP_DIR/backend/setup_state.json" \&& ok "kept: your model choice (${APP_MODEL:-unknown})"fiwarn "previous version backed up at $DEST_DIR/app.bak (removed after setup succeeds)"else# fresh install (or install over nothing)if [[ -d "$APP_DIR" ]]; thenrm -rf "$DEST_DIR/app.bak"mv "$APP_DIR" "$DEST_DIR/app.bak"warn "old app/ moved aside to app.bak"fimv "$STAGE" "$APP_DIR"ok "extracted β $APP_DIR"fifi# βββ 5. Model selection + setup (runs until fully finished) ββββββββββββββββinfo "Step 3/4 Β· model selection + full setup"if $DRY_RUN; thenlog "(dry-run) would run: ./setup.sh --no-sysdeps ${MODEL_ARG:+--model $MODEL_ARG}"log " model menu marks already-downloaded models and has a"log " 'use an already-downloaded model' option (zero download)"elsechmod +x "$APP_DIR/setup.sh" "$APP_DIR/DE-Coach" 2>/dev/null || trueSETUP_ARGS=(--no-sysdeps)if [[ -n "$MODEL_ARG" ]]; thenSETUP_ARGS+=(--model "$MODEL_ARG")elif $ASSUME_YES && [[ -n "$APP_MODEL" ]]; then# non-interactive update: keep whatever model the user already hadSETUP_ARGS+=(--model "$APP_MODEL")log "non-interactive update β keeping model: $APP_MODEL"elif $ASSUME_YES; then# non-interactive fresh install: default to the low-RAM-safe modelSETUP_ARGS+=(--model vosk-small)log "non-interactive fresh install β defaulting to vosk-small (lowest RAM, ~400 MB)"log " override with: curl -fsSL https://istias.tech/install.sh | bash -s -- --model <name>"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 ]]; thenlog "opening the model menu β pick what you want (Enter keeps your model):"bash "$APP_DIR/setup.sh" "${SETUP_ARGS[@]}" < /dev/tty \|| { [[ -d "$DEST_DIR/app.bak" ]] && warn "setup failed β your previous install is safe at: $DEST_DIR/app.bak"err "setup failed β see the output above"; }elsebash "$APP_DIR/setup.sh" "${SETUP_ARGS[@]}" \|| { [[ -d "$DEST_DIR/app.bak" ]] && warn "setup failed β your previous install is safe at: $DEST_DIR/app.bak"err "setup failed β see the output above"; }fi# setup succeeded β the backup can go[[ -d "$DEST_DIR/app.bak" ]] && rm -rf "$DEST_DIR/app.bak" && ok "old version cleaned up (app.bak removed)"fi# βββ 6. Finish β the only commands the user needs ββββββββββββββββββββββββββinfo "Step 4/4 Β· writing your command cheat-sheet"mkdir -p "$(dirname "$POINTER")" 2>/dev/null || trueprintf '%s' "$DEST_DIR" > "$POINTER" 2>/dev/null || trueCHEAT="$DEST_DIR/COMMANDS.txt"cat > "$CHEAT" <<EOFLocal DE Coach β your commands6 unmodified lines./DE-Coach --stop STOP everything./DE-Coach --dev dev mode (live logs in this terminal)Change ASR model: ./setup.sh --change-model(menu: download a new one OR use analready-downloaded model β no re-download)Switch model directly: ./setup.sh --model vosk-small (fits 500 MB RAM)Update to newest: curl -fsSL https://istias.tech/install.sh | bashLogs: ./logs/EOFok "cheat-sheet saved β $CHEAT"printf "\n"printf " ${GREEN}${BOLD}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}\n"printf " ${GREEN}${BOLD} Install complete! (v${NEW_VERSION:-?})${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}Change model later: ./setup.sh --change-model (already-downloaded = no download)${NC}\n"printf " ${DIM}Update later (same URL): curl -fsSL https://istias.tech/install.sh | bash${NC}\n"printf "\n"
install.sh+277-74