- Add Next.js app structure with base configs, linting, and formatting - Implement LiveKit Meet page, types, and utility functions - Add Docker, Compose, and deployment scripts for backend and token server - Provide E2E and smoke test scaffolding with Puppeteer and Playwright helpers - Include CSS modules and global styles for UI - Add postMessage and studio integration utilities - Update package.json with dependencies and scripts for development and testing
78 lines
3.0 KiB
Bash
78 lines
3.0 KiB
Bash
#!/usr/bin/env bash
|
|
# scripts/update_token_server_env.sh
|
|
# Safe helper to update LIVEKIT_API_KEY / LIVEKIT_API_SECRET in a .env used by docker-compose and recreate the token-server service.
|
|
# Usage:
|
|
# ./scripts/update_token_server_env.sh --env-file /path/to/.env --compose-file /path/to/docker-compose.yml --service token-server --livekit-key KEY --livekit-secret SECRET
|
|
# The script will backup the env file before editing and then run `docker compose -f <compose> up -d --no-deps --force-recreate <service>`
|
|
|
|
set -euo pipefail
|
|
show_usage(){
|
|
cat <<EOF
|
|
Usage: $0 --env-file PATH --compose-file PATH --service NAME --livekit-key KEY --livekit-secret SECRET
|
|
This will update LIVEKIT_API_KEY and LIVEKIT_API_SECRET in the provided env file and recreate the service using docker compose.
|
|
EOF
|
|
}
|
|
|
|
ENV_FILE=""
|
|
COMPOSE_FILE=""
|
|
SERVICE_NAME="token-server"
|
|
LIVEKIT_KEY=""
|
|
LIVEKIT_SECRET=""
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
--env-file) ENV_FILE="$2"; shift 2;;
|
|
--compose-file) COMPOSE_FILE="$2"; shift 2;;
|
|
--service) SERVICE_NAME="$2"; shift 2;;
|
|
--livekit-key) LIVEKIT_KEY="$2"; shift 2;;
|
|
--livekit-secret) LIVEKIT_SECRET="$2"; shift 2;;
|
|
-h|--help) show_usage; exit 0;;
|
|
*) echo "Unknown arg $1"; show_usage; exit 2;;
|
|
esac
|
|
done
|
|
|
|
if [[ -z "$ENV_FILE" || -z "$COMPOSE_FILE" || -z "$LIVEKIT_KEY" || -z "$LIVEKIT_SECRET" ]]; then
|
|
echo "ERROR: missing required arguments" >&2
|
|
show_usage
|
|
exit 2
|
|
fi
|
|
|
|
if [[ ! -f "$ENV_FILE" ]]; then
|
|
echo "ERROR: env file not found: $ENV_FILE" >&2
|
|
exit 2
|
|
fi
|
|
if [[ ! -f "$COMPOSE_FILE" ]]; then
|
|
echo "ERROR: compose file not found: $COMPOSE_FILE" >&2
|
|
exit 2
|
|
fi
|
|
|
|
BACKUP="${ENV_FILE}.bak.$(date +%Y%m%d%H%M%S)"
|
|
cp "$ENV_FILE" "$BACKUP"
|
|
echo "Backed up $ENV_FILE -> $BACKUP"
|
|
|
|
# Replace or add keys
|
|
grep -q '^LIVEKIT_API_KEY=' "$ENV_FILE" && sed -i "s/^LIVEKIT_API_KEY=.*/LIVEKIT_API_KEY=${LIVEKIT_KEY}/" "$ENV_FILE" || echo "LIVEKIT_API_KEY=${LIVEKIT_KEY}" >> "$ENV_FILE"
|
|
grep -q '^LIVEKIT_API_SECRET=' "$ENV_FILE" && sed -i "s/^LIVEKIT_API_SECRET=.*/LIVEKIT_API_SECRET=${LIVEKIT_SECRET}/" "$ENV_FILE" || echo "LIVEKIT_API_SECRET=${LIVEKIT_SECRET}" >> "$ENV_FILE"
|
|
|
|
echo "Updated LIVEKIT_API_KEY and LIVEKIT_API_SECRET in $ENV_FILE"
|
|
|
|
echo "Recreating service $SERVICE_NAME using docker compose..."
|
|
# Use docker compose if available
|
|
if command -v docker-compose >/dev/null 2>&1; then
|
|
docker-compose -f "$COMPOSE_FILE" up -d --no-deps --force-recreate "$SERVICE_NAME"
|
|
elif command -v docker >/dev/null 2>&1 && docker compose version >/dev/null 2>&1; then
|
|
docker compose -f "$COMPOSE_FILE" up -d --no-deps --force-recreate "$SERVICE_NAME"
|
|
else
|
|
echo "ERROR: docker compose not found. Please restart the service manually (docker compose or docker-compose)" >&2
|
|
exit 2
|
|
fi
|
|
|
|
echo "Service recreated. Waiting 5s for health checks..."
|
|
sleep 5
|
|
|
|
echo "Run the verify script to check token-server and LiveKit connectivity:
|
|
./scripts/verify_token_server_after_update.sh --session-room e2e_room --session-user e2e_user --token-server-url https://avanzacast-servertokens.bfzqqk.easypanel.host"
|
|
|
|
exit 0
|
|
|