9e8f1bbeed
Dashboard / frontend (push) Failing after 0s
Dashboard / api (push) Failing after 0s
Lint PowerShell / powershell-lint (ubuntu-latest) (push) Failing after 1s
Python Lint / Lint Python with Ruff (push) Failing after 1s
ShellCheck / Lint shell scripts (push) Failing after 1s
Matrix Smoke / linux-smoke (push) Failing after 1s
Matrix Smoke / distro: cachyos (push) Failing after 15s
Matrix Smoke / distro: linux-mint-21.3 (push) Failing after 15s
Matrix Smoke / distro: debian-12 (push) Failing after 5m21s
Matrix Smoke / distro: fedora-41 (push) Failing after 4m56s
Matrix Smoke / distro: ubuntu-24.04 (push) Failing after 2m13s
Matrix Smoke / distro: rocky-9 (push) Failing after 10m39s
Matrix Smoke / distro: manjaro (push) Failing after 12m11s
Matrix Smoke / distro: opensuse-tw (push) Failing after 11m53s
Matrix Smoke / distro: archlinux (push) Failing after 20m3s
Matrix Smoke / distro: ubuntu-22.04 (push) Failing after 13m49s
Validate .env Schema / tier-1-env-validation (push) Successful in 52s
Validate .env Schema / tier-2-env-validation (push) Successful in 44s
Validate .env Schema / tier-3-env-validation (push) Successful in 52s
Validate .env Schema / tier-4-env-validation (push) Successful in 51s
Validate Extensions Catalog / Check catalog is up-to-date (push) Failing after 9m47s
Secret Scan / Scan for secrets (push) Failing after 21m4s
Validate Docker Compose / Validate Docker Compose files (push) Has been cancelled
Python Type Check / Type check with mypy (push) Has been cancelled
Validate .env Schema / tier-0-env-validation (push) Has been cancelled
Test Linux / integration-smoke (push) Has been cancelled
Lint PowerShell / powershell-lint (windows-latest) (push) Has been cancelled
Matrix Smoke / macos-smoke (push) Has been cancelled
93 lines
2.8 KiB
Bash
Executable File
93 lines
2.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# ============================================================================
|
|
# ODS Mode Switch
|
|
# ============================================================================
|
|
# Usage: ./mode-switch.sh <local|cloud|hybrid> [--status]
|
|
#
|
|
# Switches ODS between local/cloud/hybrid modes by updating .env.
|
|
# This is the backend for `ods mode <mode>`.
|
|
# ============================================================================
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
ENV_FILE="$SCRIPT_DIR/.env"
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
CYAN='\033[0;36m'
|
|
NC='\033[0m'
|
|
|
|
log() { echo -e "${CYAN}[ods-mode]${NC} $1"; }
|
|
success() { echo -e "${GREEN}✓${NC} $1"; }
|
|
warn() { echo -e "${YELLOW}⚠${NC} $1"; }
|
|
error() { echo -e "${RED}✗${NC} $1" >&2; exit 1; }
|
|
|
|
# Update or add a key=value in .env
|
|
# Uses awk index() instead of sed to avoid delimiter collisions
|
|
env_set() {
|
|
local key="$1" val="$2"
|
|
if grep -q "^${key}=" "$ENV_FILE" 2>/dev/null; then
|
|
awk -v k="$key" -v v="$val" '{
|
|
if (index($0, k "=") == 1) print k "=" v; else print
|
|
}' "$ENV_FILE" > "${ENV_FILE}.tmp" && cat "${ENV_FILE}.tmp" > "$ENV_FILE" && rm -f "${ENV_FILE}.tmp"
|
|
else
|
|
echo "${key}=${val}" >> "$ENV_FILE"
|
|
fi
|
|
}
|
|
|
|
show_status() {
|
|
local current
|
|
current=$(grep "^ODS_MODE=" "$ENV_FILE" 2>/dev/null | cut -d= -f2)
|
|
echo "Current mode: ${current:-local}"
|
|
echo ""
|
|
echo "Available modes:"
|
|
echo " local — Local inference via llama-server (requires GPU/CPU)"
|
|
echo " cloud — Cloud APIs via LiteLLM (requires API keys)"
|
|
echo " hybrid — Local primary, cloud fallback"
|
|
}
|
|
|
|
switch_mode() {
|
|
local mode="$1"
|
|
|
|
# Validate
|
|
case "$mode" in
|
|
local|cloud|hybrid) ;;
|
|
*) error "Unknown mode: $mode. Use: local, cloud, hybrid" ;;
|
|
esac
|
|
|
|
[[ -f "$ENV_FILE" ]] || error ".env not found at $ENV_FILE"
|
|
|
|
# Update .env
|
|
env_set "ODS_MODE" "$mode"
|
|
|
|
if [[ "$mode" == "local" ]]; then
|
|
env_set "LLM_API_URL" "http://llama-server:8080"
|
|
else
|
|
env_set "LLM_API_URL" "http://litellm:4000"
|
|
# Auto-enable litellm extension
|
|
local litellm_cf="$SCRIPT_DIR/extensions/services/litellm/compose.yaml"
|
|
local litellm_disabled="${litellm_cf}.disabled"
|
|
if [[ -f "$litellm_disabled" && ! -f "$litellm_cf" ]]; then
|
|
mv "$litellm_disabled" "$litellm_cf"
|
|
success "Auto-enabled litellm for $mode mode"
|
|
fi
|
|
fi
|
|
|
|
success "Switched to $mode mode."
|
|
log "Run 'ods restart' to apply."
|
|
}
|
|
|
|
# Called directly or sourced
|
|
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
|
case "${1:---status}" in
|
|
--status|-s|status) show_status ;;
|
|
--help|-h|help)
|
|
echo "Usage: mode-switch.sh <local|cloud|hybrid|--status>"
|
|
;;
|
|
*) switch_mode "${1:-}" ;;
|
|
esac
|
|
fi
|