171 lines
5.3 KiB
Bash
171 lines
5.3 KiB
Bash
#!/bin/bash
|
|
|
|
# Ollama CLI Installer
|
|
# Installs Ollama CLI, Ollama, and ComfyUI
|
|
|
|
set -e
|
|
|
|
echo "==========================================="
|
|
echo " Ollama CLI All-in-One Installer "
|
|
echo "==========================================="
|
|
echo ""
|
|
|
|
# 1. Check Prerequisites
|
|
echo "[*] Checking system..."
|
|
if ! command -v python3 &> /dev/null; then
|
|
echo "Error: Python 3 is required but not found."
|
|
exit 1
|
|
fi
|
|
|
|
if ! command -v git &> /dev/null; then
|
|
echo "Error: git is required but not found."
|
|
exit 1
|
|
fi
|
|
|
|
# 2. Install Ollama CLI
|
|
echo ""
|
|
echo "[*] Installing Ollama CLI..."
|
|
# Ensure we are in the directory containing pyproject.toml
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
|
cd "$SCRIPT_DIR"
|
|
|
|
if [ -f "pyproject.toml" ]; then
|
|
pip3 install .
|
|
echo "✅ Ollama CLI installed."
|
|
else
|
|
echo "Error: Could not find pyproject.toml. Make sure you run this script from the ollama-cli directory."
|
|
exit 1
|
|
fi
|
|
|
|
# 3. Install Ollama (Optional)
|
|
echo ""
|
|
echo "-------------------------------------------"
|
|
if command -v ollama &> /dev/null; then
|
|
echo "✅ Ollama is already installed."
|
|
else
|
|
read -p "Do you want to install Ollama (LLM Server)? (y/n) " -n 1 -r
|
|
echo ""
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
echo "[*] Installing Ollama..."
|
|
curl -fsSL https://ollama.com/install.sh | sh
|
|
echo "✅ Ollama installed."
|
|
else
|
|
echo "Skipping Ollama installation."
|
|
fi
|
|
fi
|
|
|
|
# 4. Install ComfyUI (Optional)
|
|
echo ""
|
|
echo "-------------------------------------------"
|
|
read -p "Do you want to install ComfyUI (Image Generation)? (y/n) " -n 1 -r
|
|
echo ""
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
INSTALL_DIR="$HOME/ComfyUI"
|
|
if [ -d "$INSTALL_DIR" ]; then
|
|
echo "⚠️ ComfyUI directory already exists at $INSTALL_DIR"
|
|
read -p "Update existing installation? (y/n) " -n 1 -r
|
|
echo ""
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
cd "$INSTALL_DIR"
|
|
git pull
|
|
pip3 install -r requirements.txt
|
|
echo "✅ ComfyUI updated."
|
|
fi
|
|
else
|
|
echo "[*] Cloning ComfyUI to $INSTALL_DIR..."
|
|
git clone https://github.com/comfyanonymous/ComfyUI.git "$INSTALL_DIR"
|
|
cd "$INSTALL_DIR"
|
|
echo "[*] Installing ComfyUI dependencies..."
|
|
pip3 install -r requirements.txt
|
|
echo "✅ ComfyUI installed."
|
|
|
|
# 5. Download Image Generation Model
|
|
echo ""
|
|
echo "[*] Downloading Image Generation Model (DreamShaper 8)..."
|
|
MODEL_DIR="models/checkpoints"
|
|
mkdir -p "$MODEL_DIR"
|
|
MODEL_PATH="$MODEL_DIR/dreamshaper_8.safetensors"
|
|
if [ ! -f "$MODEL_PATH" ]; then
|
|
echo " This may take a few minutes (approx. 2GB)..."
|
|
curl -L "https://huggingface.co/Lykon/DreamShaper/resolve/main/DreamShaper_8_pruned.safetensors" -o "$MODEL_PATH"
|
|
echo "✅ Model downloaded."
|
|
else
|
|
echo "✅ Model already exists."
|
|
fi
|
|
|
|
echo ""
|
|
echo "[!] To use Image Generation, you must start ComfyUI:"
|
|
echo " cd $INSTALL_DIR"
|
|
echo " python3 main.py"
|
|
fi
|
|
|
|
# Update config to point to ComfyUI
|
|
python3 -c "
|
|
import json
|
|
import os
|
|
config_path = os.path.expanduser('~/.ollama-cli-config.json')
|
|
if os.path.exists(config_path):
|
|
with open(config_path, 'r') as f:
|
|
config = json.load(f)
|
|
else:
|
|
config = {}
|
|
config['comfy_url'] = 'http://127.0.0.1:8188'
|
|
with open(config_path, 'w') as f:
|
|
json.dump(config, f, indent=2)
|
|
"
|
|
else
|
|
echo "Skipping ComfyUI installation."
|
|
fi
|
|
|
|
# 6. Install Piper TTS
|
|
echo ""
|
|
echo "-------------------------------------------"
|
|
read -p "Do you want to install Piper TTS (High-Quality Voice)? (y/n) " -n 1 -r
|
|
echo ""
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
PIPER_DIR="$HOME/.ollama-cli/piper"
|
|
mkdir -p "$PIPER_DIR"
|
|
cd "$PIPER_DIR"
|
|
|
|
if [ ! -f "piper" ]; then
|
|
echo "[*] Downloading Piper binary..."
|
|
# Detect architecture for Piper download
|
|
OS_TYPE=$(uname -s | tr '[:upper:]' '[:lower:]')
|
|
ARCH_TYPE=$(uname -m)
|
|
if [[ "$OS_TYPE" == "darwin" ]]; then
|
|
# macOS uses the apple silicon or intel build
|
|
curl -L "https://github.com/rhasspy/piper/releases/download/v1.2.0/piper_macos_x86_64.tar.gz" -o piper.tar.gz
|
|
else
|
|
curl -L "https://github.com/rhasspy/piper/releases/download/v1.2.0/piper_amd64.tar.gz" -o piper.tar.gz
|
|
fi
|
|
tar -xzf piper.tar.gz
|
|
# Move binary to top level
|
|
mv piper/piper .
|
|
mv piper/lib* . || true
|
|
rm -rf piper piper.tar.gz
|
|
fi
|
|
|
|
if [ ! -f "voice.onnx" ]; then
|
|
echo "[*] Downloading High-Quality Voice Model (en_US-lessac-medium)..."
|
|
curl -L "https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_US/lessac/medium/en_US-lessac-medium.onnx" -o voice.onnx
|
|
curl -L "https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_US/lessac/medium/en_US-lessac-medium.onnx.json" -o voice.onnx.json
|
|
fi
|
|
echo "✅ Piper TTS installed."
|
|
else
|
|
echo "Skipping Piper installation."
|
|
fi
|
|
|
|
echo ""
|
|
echo "==========================================="
|
|
echo " Installation Complete! 🚀 "
|
|
echo "==========================================="
|
|
echo ""
|
|
echo "To start the CLI, run:"
|
|
echo " ollama-cli"
|
|
echo ""
|
|
if command -v ollama &> /dev/null; then
|
|
echo "Ensure Ollama is running:"
|
|
echo " ollama serve"
|
|
fi
|
|
echo ""
|