#!/usr/bin/env bash # Run on xNAS after building the clean backend source into the pinned image. # Credentials stay on the NAS. Existing checkout, library and certs are retained. set -euo pipefail deployment_source=/mnt/user/dev/hope-voice-deploy-68f4c46 deployment_data=/mnt/user/dev/hope-voice-api deployment_image=${HOPE_DEPLOY_IMAGE:-hope-voice-api-voice:68f4c46-ios-audio} test -f "$deployment_data/.env" docker image inspect "$deployment_image" >/dev/null if docker container inspect voice >/dev/null 2>&1; then echo 'A voice container already exists; inspect it before replacing it.' >&2 exit 1 fi # Recover the OpenWebUI credential used by this exact backend deployment source. LLM_API_KEY=$(sed -n 's/.*-e LLM_API_KEY=\([^ ]*\).*/\1/p' "$deployment_source/.gitea/workflows/rebuild.yml") test -n "$LLM_API_KEY" export LLM_API_KEY export LLM_BASE_URL=http://192.168.86.2:3005/api export LLM_MODEL=qwen2.5-vl-3b docker run -d --name voice --network host --restart unless-stopped \ --env-file "$deployment_data/.env" \ --env LLM_BASE_URL --env LLM_MODEL --env LLM_API_KEY \ --env LIVEKIT_URL=http://localhost:7880 \ --env VOICE_USERS_FILE=/etc/hope/users.json \ --env VOICE_DEFAULT_USER=shane --env MEDIA_DIR=/data/media \ --env MEDIA_SERVER_PORT=8093 --env WEB_PORT=9178 \ --env YTDLP_COOKIES=/data/media/cookies.txt \ --volume "$deployment_data/certs:/etc/voice/certs" \ --volume "$deployment_data/skills:/skills" \ --volume "$deployment_data/media:/data/media" \ --volume "$deployment_source/livekit.yaml:/etc/livekit.yaml:ro" \ --health-cmd='curl -sfk https://localhost:9178/ -o /dev/null && curl -sf http://localhost:7880/ -o /dev/null && curl -sf http://localhost:8093/media/api/healthz -o /dev/null' \ --health-interval=15s --health-timeout=5s --health-retries=3 --health-start-period=30s \ "$deployment_image"