Codex setup with credentials
sh
What it runs
The whole script, exactly as it will execute in your workspace. Nothing is hidden — read it before you run it.
#!/usr/bin/env sh
set -e
# ── helpers ────────────────────────────────────────────────────────────────────
log() { printf '[setup] %s\n' "$*"; }
warn() { printf '[setup] WARNING: %s\n' "$*" >&2; }
die() { printf '[setup] ERROR: %s\n' "$*" >&2; exit 1; }
# ── install jq if missing ──────────────────────────────────────────────────────
if ! command -v jq >/dev/null 2>&1; then
log "jq not found; attempting install..."
if command -v apt-get >/dev/null 2>&1; then sudo apt-get update -qq && sudo apt-get install -y jq
elif command -v dnf >/dev/null 2>&1; then sudo dnf install -y jq
elif command -v yum >/dev/null 2>&1; then sudo yum install -y jq
elif command -v pacman >/dev/null 2>&1; then sudo pacman -Sy --noconfirm jq
elif command -v zypper >/dev/null 2>&1; then sudo zypper install -y jq
elif command -v brew >/dev/null 2>&1; then brew install jq
else die "no supported package manager found; install jq manually and re-run"
fi
command -v jq >/dev/null 2>&1 || die "jq installation appeared to succeed but jq is still not on PATH"
log "jq installed: $(jq --version)"
fi
# ── create ~/.codex if needed ─────────────────────────────────────────────────
mkdir -p "$HOME/.codex"
# ── write credentials ──────────────────────────────────────────────────────────
CREDS="$HOME/.codex/auth.json"
cat > "$CREDS" <<'EOF'
@[secret:5a86027a-9c95-45ae-b10d-d8ec98dc0f3b]
EOF
log "wrote $CREDS"
# ── configure Context7 MCP for Codex ──────────────────────────────────────────
if command -v codex >/dev/null 2>&1; then
if codex mcp list 2>/dev/null | grep -q '^context7'; then
log "Context7 MCP already configured"
else
log "Adding Context7 MCP to Codex..."
codex mcp add context7 -- npx -y @upstash/context7-mcp
log "Context7 MCP added"
fi
else
warn "codex CLI not found; skipping Context7 MCP installation"
fi
# ── summary ────────────────────────────────────────────────────────────────────
log "done. updated:"
log " $CLAUDE_JSON"
log " $CREDS"How to get it
Open your DevGrail workspace, go to Scripts → Official scripts, and choose Download. It is copied into your own library, where you can edit it, run it, or set it as a workspace default — the copy is yours, and later changes here do not touch it.