#!/usr/bin/env bash # DictIA ASR Proxy — Setup script # Installs the GCP GPU proxy for cloud deployments. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" INSTALL_DIR="${ASR_PROXY_DIR:-$SCRIPT_DIR}" SERVICE_USER="${ASR_PROXY_USER:-$(whoami)}" echo "=== DictIA ASR Proxy Setup ===" echo "Install directory: $INSTALL_DIR" echo "Service user: $SERVICE_USER" echo # 1. Create virtual environment if [ ! -d "$INSTALL_DIR/venv" ]; then echo "[1/4] Creating Python virtual environment..." python3 -m venv "$INSTALL_DIR/venv" else echo "[1/4] Virtual environment already exists." fi # 2. Install dependencies echo "[2/4] Installing Python dependencies..." "$INSTALL_DIR/venv/bin/pip" install --quiet --upgrade pip "$INSTALL_DIR/venv/bin/pip" install --quiet -r "$INSTALL_DIR/requirements.txt" # 3. GCP credentials if [ ! -f "$INSTALL_DIR/gcp-credentials.json" ]; then echo "[3/4] GCP credentials not found." echo " Place your GCP service account or OAuth credentials at:" echo " $INSTALL_DIR/gcp-credentials.json" echo echo " For service account: download JSON from GCP Console > IAM > Service Accounts" echo " For user credentials: run 'gcloud auth application-default login' and copy the file" echo read -rp " Path to credentials file (or press Enter to skip): " CREDS_PATH if [ -n "$CREDS_PATH" ] && [ -f "$CREDS_PATH" ]; then cp "$CREDS_PATH" "$INSTALL_DIR/gcp-credentials.json" chmod 600 "$INSTALL_DIR/gcp-credentials.json" echo " Credentials copied." else echo " Skipped. You must add credentials before starting the proxy." fi else echo "[3/4] GCP credentials found." fi # 4. Install systemd service echo "[4/4] Installing systemd service..." SERVICE_FILE="/etc/systemd/system/asr-proxy.service" cat > /tmp/asr-proxy.service <