From 8b9dcb25861bc91e24264196c50ca6e87506512d Mon Sep 17 00:00:00 2001 From: Jatin K Malik Date: Sun, 28 Dec 2025 16:04:59 -0800 Subject: [PATCH] fix: Install/uninstall scripts for curl | bash usage (#41) * fix: install/uninstall scripts for curl | bash usage Install script improvements: - Detect non-interactive mode (curl | bash) automatically - Skip interactive prompts in non-interactive mode - Add --no-whisper and -y/--yes flags for explicit control - Continue with defaults when stdin is not a tty Uninstall script improvements: - Clean up curl-installed files: - ~/.local/share/vocalinux-install (cloned repo) - ~/.local/share/vocalinux/venv (virtual environment) - ~/.local/bin/vocalinux (symlink) - ~/.local/bin/activate-vocalinux.sh - Add -y/--yes flag for non-interactive mode - Verify all curl-installed components are removed README updates: - Document curl installation with --with-whisper option - Add uninstall instructions for both methods - Clarify what gets installed where * feat: install Whisper by default in non-interactive mode - curl | bash now installs both VOSK and Whisper out of the box - Users can freely switch between engines in settings - Add --no-whisper flag for faster install (VOSK only) - Update README to reflect new default behavior * chore: remove install-whisper.sh (now part of install.sh) Whisper is installed by default via install.sh, making this separate script redundant. * chore: remove activate-vocalinux.sh (generated by install.sh) This file is dynamically created by install.sh based on the venv location, so the static template is not needed. --- README.md | 28 ++++++++- activate-vocalinux.sh | 5 -- install-whisper.sh | 130 ------------------------------------------ install.sh | 77 ++++++++++++++++++------- uninstall.sh | 118 ++++++++++++++++++++++++++++++-------- 5 files changed, 175 insertions(+), 183 deletions(-) delete mode 100755 activate-vocalinux.sh delete mode 100755 install-whisper.sh diff --git a/README.md b/README.md index 6c848eb..7425371 100644 --- a/README.md +++ b/README.md @@ -37,10 +37,19 @@ curl -fsSL https://raw.githubusercontent.com/jatinkrmalik/vocalinux/main/install ``` This will: -- Clone the repository -- Install all dependencies +- Clone the repository to `~/.local/share/vocalinux-install` +- Install all system dependencies - Set up a virtual environment in `~/.local/share/vocalinux/venv` +- Install **both VOSK and Whisper AI** speech engines - Create a symlink at `~/.local/bin/vocalinux` +- Download the default VOSK speech model + +> ⏱️ **Note**: Installation takes ~5-10 minutes due to Whisper AI dependencies (PyTorch). + +**Without Whisper (faster install, VOSK only):** +```bash +curl -fsSL https://raw.githubusercontent.com/jatinkrmalik/vocalinux/main/install.sh | bash -s -- --no-whisper +``` ### Alternative: Install from Source @@ -49,8 +58,11 @@ This will: git clone https://github.com/jatinkrmalik/vocalinux.git cd vocalinux -# Run the installer +# Run the installer (will prompt for Whisper) ./install.sh + +# Or with Whisper support +./install.sh --with-whisper ``` The installer handles everything: system dependencies, Python environment, speech models, and desktop integration. @@ -71,6 +83,16 @@ vocalinux Or launch it from your application menu! +### Uninstall + +```bash +# If installed via curl: +curl -fsSL https://raw.githubusercontent.com/jatinkrmalik/vocalinux/main/uninstall.sh | bash + +# If installed from source: +./uninstall.sh +``` + ## 📋 Requirements - **OS**: Ubuntu 22.04+ (other Linux distros may work) diff --git a/activate-vocalinux.sh b/activate-vocalinux.sh deleted file mode 100755 index 23b86b9..0000000 --- a/activate-vocalinux.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -# This script activates the Vocalinux virtual environment -source "$(dirname "$(realpath "$0")")/venv/bin/activate" -echo "Vocalinux virtual environment activated." -echo "To start the application, run: vocalinux" diff --git a/install-whisper.sh b/install-whisper.sh deleted file mode 100755 index 0f4229a..0000000 --- a/install-whisper.sh +++ /dev/null @@ -1,130 +0,0 @@ -#!/bin/bash -# VocaLinux Whisper Installation Helper Script -# This script helps install Whisper AI support for VocaLinux - -set -e - -# Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' # No Color - -# Print functions -print_info() { - echo -e "${BLUE}[INFO]${NC} $1" -} - -print_success() { - echo -e "${GREEN}[SUCCESS]${NC} $1" -} - -print_warning() { - echo -e "${YELLOW}[WARNING]${NC} $1" -} - -print_error() { - echo -e "${RED}[ERROR]${NC} $1" -} - -# Check if we're in the VocaLinux directory -if [ ! -f "setup.py" ] || [ ! -d "src/vocalinux" ]; then - print_error "This script must be run from the VocaLinux root directory" - exit 1 -fi - -print_info "VocaLinux Whisper Installation Helper" -echo "======================================" -echo "" - -# Check if virtual environment exists -if [ ! -d "venv" ]; then - print_error "Virtual environment not found. Please run ./install.sh first." - exit 1 -fi - -print_info "Found virtual environment: venv/" - -# Activate virtual environment -print_info "Activating virtual environment..." -source venv/bin/activate - -# Check current Python and pip -print_info "Python executable: $(which python)" -print_info "Pip version: $(pip --version)" - -# Check if Whisper is already installed -print_info "Checking current Whisper installation..." -if python -c "import whisper; print('Whisper version:', whisper.__version__)" 2>/dev/null; then - print_success "Whisper is already installed!" - python -c "import whisper; print('Available models:', whisper.available_models())" - exit 0 -fi - -print_warning "Whisper is not installed. Attempting installation..." - -# Try different installation methods -echo "" -print_info "Attempting Method 1: Standard pip installation..." -if pip install openai-whisper torch torchaudio; then - print_success "Whisper installed successfully using standard method!" -else - print_warning "Standard installation failed. Trying with trusted hosts..." - - print_info "Attempting Method 2: Installation with trusted hosts..." - if pip install openai-whisper torch torchaudio \ - --trusted-host pypi.org \ - --trusted-host pypi.python.org \ - --trusted-host files.pythonhosted.org; then - print_success "Whisper installed successfully using trusted hosts!" - else - print_warning "Trusted hosts method failed. Trying with --break-system-packages..." - - print_info "Attempting Method 3: Installation with --break-system-packages..." - if pip install openai-whisper torch torchaudio --break-system-packages; then - print_success "Whisper installed successfully with --break-system-packages!" - else - print_error "All installation methods failed." - echo "" - print_info "Manual installation options:" - echo "1. Fix SSL issues in your Python installation" - echo "2. Use conda: conda install pytorch torchaudio -c pytorch && pip install openai-whisper" - echo "3. Install from source: https://github.com/openai/whisper" - echo "4. Use system packages if available" - echo "" - print_info "For SSL issues, you may need to:" - echo "- Install ca-certificates: sudo apt install ca-certificates" - echo "- Reinstall Python with SSL support" - echo "- Use a different Python installation (pyenv, conda, etc.)" - exit 1 - fi - fi -fi - -# Verify installation -echo "" -print_info "Verifying Whisper installation..." -if python -c "import whisper; import torch; print('✅ Whisper and PyTorch imported successfully')"; then - print_success "Whisper installation verified!" - - # Show available models - python -c " -import whisper -import torch -print('Available Whisper models:', whisper.available_models()) -print('PyTorch version:', torch.__version__) -print('CUDA available:', torch.cuda.is_available()) -" - - echo "" - print_success "Whisper is now ready to use in VocaLinux!" - print_info "You can now:" - echo "1. Start VocaLinux: ./activate-vocalinux.sh && vocalinux" - echo "2. Open Settings and select Whisper as the speech engine" - echo "3. Choose a model size (base, small, medium recommended)" - -else - print_error "Whisper installation verification failed" - exit 1 -fi \ No newline at end of file diff --git a/install.sh b/install.sh index 3a85171..729713e 100755 --- a/install.sh +++ b/install.sh @@ -28,6 +28,12 @@ DEV_MODE="no" VENV_DIR="venv" SKIP_MODELS="no" WITH_WHISPER="no" +NON_INTERACTIVE="no" + +# Detect if running non-interactively (e.g., via curl | bash) +if [ ! -t 0 ]; then + NON_INTERACTIVE="yes" +fi while [[ $# -gt 0 ]]; do case $1 in @@ -51,6 +57,15 @@ while [[ $# -gt 0 ]]; do WITH_WHISPER="yes" shift ;; + --no-whisper) + WITH_WHISPER="no" + NON_INTERACTIVE="yes" # Skip the prompt + shift + ;; + -y|--yes) + NON_INTERACTIVE="yes" + shift + ;; --help) echo "Vocalinux Installer" echo "Usage: $0 [options]" @@ -60,6 +75,8 @@ while [[ $# -gt 0 ]]; do echo " --venv-dir=PATH Specify custom virtual environment directory (default: venv)" echo " --skip-models Skip downloading VOSK models during installation" echo " --with-whisper Install Whisper AI support (requires more disk space and time)" + echo " --no-whisper Skip Whisper installation (don't prompt)" + echo " -y, --yes Non-interactive mode (accept defaults)" echo " --help Show this help message" exit 0 ;; @@ -180,20 +197,28 @@ detect_distro if [[ "$DISTRO_FAMILY" != "ubuntu" ]]; then print_warning "This installer is primarily designed for Ubuntu-based systems. Your system: $DISTRO_NAME" print_warning "The application may still work, but you might need to install dependencies manually." - read -p "Do you want to continue anyway? (y/n) " -n 1 -r - echo - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - exit 1 - fi -else - # Check version for Ubuntu-based systems - if ! check_ubuntu_version; then + if [[ "$NON_INTERACTIVE" == "yes" ]]; then + print_info "Non-interactive mode: continuing anyway..." + else read -p "Do you want to continue anyway? (y/n) " -n 1 -r echo if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1 fi fi +else + # Check version for Ubuntu-based systems + if ! check_ubuntu_version; then + if [[ "$NON_INTERACTIVE" == "yes" ]]; then + print_info "Non-interactive mode: continuing anyway..." + else + read -p "Do you want to continue anyway? (y/n) " -n 1 -r + echo + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + exit 1 + fi + fi + fi fi # Function to check if a command exists @@ -321,7 +346,11 @@ install_system_dependencies() { print_warning "- AppIndicator3 support" print_warning "- PortAudio development libraries" print_warning "- Python virtual environment support" - read -p "Press Enter to continue once dependencies are installed, or Ctrl+C to cancel..." + if [[ "$NON_INTERACTIVE" != "yes" ]]; then + read -p "Press Enter to continue once dependencies are installed, or Ctrl+C to cancel..." + else + print_info "Non-interactive mode: continuing (dependencies may be missing)..." + fi ;; esac } @@ -502,15 +531,22 @@ setup_virtual_environment() { # Check if virtual environment already exists if [ -d "$VENV_DIR" ] && [ -f "$VENV_DIR/bin/activate" ]; then print_warning "Virtual environment already exists in $VENV_DIR" - read -p "Do you want to recreate it? (y/n) " -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]]; then - print_info "Removing existing virtual environment..." - rm -rf "$VENV_DIR" - else - print_info "Using existing virtual environment." + if [[ "$NON_INTERACTIVE" == "yes" ]]; then + # In non-interactive mode, reuse existing venv + print_info "Non-interactive mode: using existing virtual environment." source "$VENV_DIR/bin/activate" || { print_error "Failed to activate virtual environment"; exit 1; } return 0 + else + read -p "Do you want to recreate it? (y/n) " -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + print_info "Removing existing virtual environment..." + rm -rf "$VENV_DIR" + else + print_info "Using existing virtual environment." + source "$VENV_DIR/bin/activate" || { print_error "Failed to activate virtual environment"; exit 1; } + return 0 + fi fi fi @@ -607,15 +643,16 @@ install_python_package() { return 1 } - # Install Whisper if requested - if [ "$WITH_WHISPER" = "yes" ]; then - print_info "Installing Whisper support (this might take a while)..." + # Install Whisper - by default in non-interactive mode, or if explicitly requested + if [ "$WITH_WHISPER" = "yes" ] || [ "$NON_INTERACTIVE" = "yes" ]; then + print_info "Installing Whisper AI support (this might take a while ~5-10 min)..." + print_info "This enables high-accuracy speech recognition." pip install ".[whisper]" --log "$PIP_LOG_FILE" || { print_warning "Failed to install Whisper support." print_warning "Voice recognition will fall back to VOSK." } else - # Prompt for Whisper installation + # Prompt for Whisper installation (interactive mode only) read -p "Do you want to install Whisper AI support? This requires additional disk space. (y/n) " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then diff --git a/uninstall.sh b/uninstall.sh index 305ecd6..209523b 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -55,6 +55,12 @@ echo "" KEEP_CONFIG="no" KEEP_DATA="no" VENV_DIR="venv" +NON_INTERACTIVE="no" + +# Detect if running non-interactively +if [ ! -t 0 ]; then + NON_INTERACTIVE="yes" +fi while [[ $# -gt 0 ]]; do case $1 in @@ -70,6 +76,10 @@ while [[ $# -gt 0 ]]; do VENV_DIR="${1#*=}" shift ;; + -y|--yes) + NON_INTERACTIVE="yes" + shift + ;; --help) echo "Vocalinux Uninstaller" echo "Usage: $0 [options]" @@ -77,6 +87,7 @@ while [[ $# -gt 0 ]]; do echo " --keep-config Keep configuration files" echo " --keep-data Keep application data (models, etc.)" echo " --venv-dir=PATH Specify custom virtual environment directory (default: venv)" + echo " -y, --yes Non-interactive mode (no confirmation prompts)" echo " --help Show this help message" exit 0 ;; @@ -94,45 +105,83 @@ DATA_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/vocalinux" DESKTOP_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/applications" ICON_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/icons/hicolor/scalable/apps" +# Directories created by curl-based installation +CURL_INSTALL_DIR="$HOME/.local/share/vocalinux-install" +CURL_VENV_DIR="$HOME/.local/share/vocalinux/venv" +CURL_BIN_DIR="$HOME/.local/bin" + # Print uninstallation options echo "Uninstallation options:" -echo "- Virtual environment directory: $VENV_DIR" +echo "- Local virtual environment: $VENV_DIR" +echo "- Curl-installed venv: $CURL_VENV_DIR" +echo "- Curl-installed repo: $CURL_INSTALL_DIR" [[ "$KEEP_CONFIG" == "yes" ]] && echo "- Keeping configuration files" [[ "$KEEP_DATA" == "yes" ]] && echo "- Keeping application data" echo # Ask for confirmation -read -p "This will remove Vocalinux from your system. Continue? (y/n) " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]]; then - print_info "Uninstallation cancelled." - exit 0 +if [[ "$NON_INTERACTIVE" == "yes" ]]; then + print_info "Non-interactive mode: proceeding with uninstallation..." +else + read -p "This will remove Vocalinux from your system. Continue? (y/n) " -n 1 -r + echo + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + print_info "Uninstallation cancelled." + exit 0 + fi fi # Function to handle virtual environment removal remove_virtual_environment() { - if [ -d "$VENV_DIR" ]; then - print_info "Removing virtual environment..." - - # Deactivate the virtual environment if it's active - if [[ -n "$VIRTUAL_ENV" && "$VIRTUAL_ENV" == *"$VENV_DIR"* ]]; then - print_warning "Virtual environment is active. Deactivating..." - deactivate 2>/dev/null || { - print_warning "Failed to deactivate virtual environment. This is not critical." - } - fi - - # Remove the virtual environment directory - safe_remove "$VENV_DIR" "virtual environment directory" - else - print_info "Virtual environment not found: $VENV_DIR" + # Deactivate the virtual environment if it's active + if [[ -n "$VIRTUAL_ENV" ]]; then + print_warning "Virtual environment is active. Deactivating..." + deactivate 2>/dev/null || { + print_warning "Failed to deactivate virtual environment. This is not critical." + } fi + + # Remove local venv (if running from repo) + if [ -d "$VENV_DIR" ]; then + print_info "Removing local virtual environment..." + safe_remove "$VENV_DIR" "local virtual environment directory" + else + print_info "Local virtual environment not found: $VENV_DIR" + fi + + # Remove curl-installed venv + if [ -d "$CURL_VENV_DIR" ]; then + print_info "Removing curl-installed virtual environment..." + safe_remove "$CURL_VENV_DIR" "curl-installed virtual environment" + fi + + # Remove the vocalinux data directory if empty (contains venv) + local VOCALINUX_DATA_DIR="$HOME/.local/share/vocalinux" + if [ -d "$VOCALINUX_DATA_DIR" ] && [ -z "$(ls -A "$VOCALINUX_DATA_DIR" 2>/dev/null)" ]; then + safe_remove "$VOCALINUX_DATA_DIR" "empty vocalinux data directory" + fi +} + +# Function to remove curl-installed files +remove_curl_install_files() { + print_info "Removing curl-installation files..." + + # Remove cloned repository + safe_remove "$CURL_INSTALL_DIR" "cloned repository" + + # Remove symlink in ~/.local/bin + if [ -L "$CURL_BIN_DIR/vocalinux" ]; then + safe_remove "$CURL_BIN_DIR/vocalinux" "vocalinux symlink" + fi + + # Remove activation script in ~/.local/bin + safe_remove "$CURL_BIN_DIR/activate-vocalinux.sh" "activation script in ~/.local/bin" } # Function to remove application files remove_application_files() { - # Remove activation script - safe_remove "activate-vocalinux.sh" "activation script" + # Remove local activation script (if running from repo) + safe_remove "activate-vocalinux.sh" "local activation script" # Remove desktop entry safe_remove "$DESKTOP_DIR/vocalinux.desktop" "desktop entry" @@ -211,9 +260,27 @@ verify_uninstallation() { print_info "Verifying uninstallation..." local ISSUES=0 - # Check if virtual environment still exists + # Check if local virtual environment still exists if [ -d "$VENV_DIR" ]; then - print_warning "Virtual environment still exists: $VENV_DIR" + print_warning "Local virtual environment still exists: $VENV_DIR" + ((ISSUES++)) + fi + + # Check if curl-installed virtual environment still exists + if [ -d "$CURL_VENV_DIR" ]; then + print_warning "Curl-installed venv still exists: $CURL_VENV_DIR" + ((ISSUES++)) + fi + + # Check if cloned repository still exists + if [ -d "$CURL_INSTALL_DIR" ]; then + print_warning "Cloned repository still exists: $CURL_INSTALL_DIR" + ((ISSUES++)) + fi + + # Check if symlink still exists + if [ -L "$CURL_BIN_DIR/vocalinux" ]; then + print_warning "Vocalinux symlink still exists: $CURL_BIN_DIR/vocalinux" ((ISSUES++)) fi @@ -290,6 +357,7 @@ print_uninstallation_summary() { # Perform uninstallation steps remove_virtual_environment +remove_curl_install_files remove_application_files remove_config_and_data cleanup_build_artifacts