mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-29 00:55:43 +00:00
Adds a helper script that automatically runs docker exec against the active Eagle instance (blue or green), determined by checking nginx config. Usage: eagle-exec printenv GEMINI_API_KEY eagle-exec jcmd 1 VM.flags eagle-exec sh The script is deployed to /opt/eagle0/scripts/ and symlinked to /usr/local/bin/eagle-exec for easy access. Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
55 lines
1.5 KiB
Bash
Executable File
55 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Helper to run docker exec against the active Eagle instance.
|
|
# Automatically determines whether blue or green is active based on nginx config.
|
|
#
|
|
# Usage:
|
|
# ./scripts/eagle-exec.sh printenv GEMINI_API_KEY
|
|
# ./scripts/eagle-exec.sh jcmd 1 VM.flags
|
|
# ./scripts/eagle-exec.sh sh # Get a shell
|
|
#
|
|
# Or create an alias:
|
|
# alias eagle-exec='/opt/eagle0/scripts/eagle-exec.sh'
|
|
#
|
|
|
|
set -euo pipefail
|
|
|
|
APP_DIR="${APP_DIR:-/opt/eagle0}"
|
|
|
|
# Determine active instance from nginx config
|
|
get_active_instance() {
|
|
local backend
|
|
backend=$(docker exec nginx grep -o 'eagle-[a-z]*:40032' /etc/nginx/nginx.conf 2>/dev/null | head -1 || echo "")
|
|
|
|
if [ "$backend" = "eagle-blue:40032" ]; then
|
|
echo "eagle-blue"
|
|
elif [ "$backend" = "eagle-green:40032" ]; then
|
|
echo "eagle-green"
|
|
else
|
|
# Fallback: check which container is actually running
|
|
if docker inspect --format='{{.State.Running}}' eagle-blue 2>/dev/null | grep -q true; then
|
|
echo "eagle-blue"
|
|
elif docker inspect --format='{{.State.Running}}' eagle-green 2>/dev/null | grep -q true; then
|
|
echo "eagle-green"
|
|
else
|
|
echo ""
|
|
fi
|
|
fi
|
|
}
|
|
|
|
ACTIVE=$(get_active_instance)
|
|
|
|
if [ -z "$ACTIVE" ]; then
|
|
echo "Error: No active Eagle instance found" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ $# -eq 0 ]; then
|
|
echo "Active instance: $ACTIVE"
|
|
echo "Usage: $0 <command> [args...]"
|
|
echo "Example: $0 printenv GEMINI_API_KEY"
|
|
exit 0
|
|
fi
|
|
|
|
exec docker exec "$ACTIVE" "$@"
|