From fdf5db670977346060f4643930f41ca7c13bfef5 Mon Sep 17 00:00:00 2001 From: Clsan Date: Fri, 8 May 2026 16:30:32 +0900 Subject: [PATCH 1/3] Add Codex MCP setup for work machines --- common.sh | 28 +++++++++++++++++++++++++--- setup.sh | 10 +++++----- work_setup.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 8 deletions(-) diff --git a/common.sh b/common.sh index cff9c5c..1eb9e83 100644 --- a/common.sh +++ b/common.sh @@ -23,8 +23,30 @@ trap 'kill $CAFFEINATE_PID 2>/dev/null' EXIT # ============================================ # Helper Functions # ============================================ -add_to_zshrc() { - grep -qF "$1" ~/.zshrc 2>/dev/null || echo "$1" >> ~/.zshrc +append_block_if_missing() { + local file="$1" + local marker="$2" + + mkdir -p "$(dirname "$file")" + touch "$file" + + if grep -qF "$marker" "$file"; then + return 0 + fi + + if [[ -s "$file" ]]; then + printf "\n" >> "$file" + fi + cat >> "$file" +} + +append_line_if_missing() { + local file="$1" + local line="$2" + + append_block_if_missing "$file" "$line" </dev/null; then fi eval "$(/opt/homebrew/bin/brew shellenv)" -add_to_zshrc 'eval "$(/opt/homebrew/bin/brew shellenv)"' +append_line_if_missing "$HOME/.zshrc" 'eval "$(/opt/homebrew/bin/brew shellenv)"' echo "βœ… Homebrew ready" diff --git a/setup.sh b/setup.sh index dd495e4..8b2d710 100755 --- a/setup.sh +++ b/setup.sh @@ -12,7 +12,7 @@ source "$SCRIPT_DIR/common.sh" # ============================================ echo "πŸš€ Checking Starship..." brew_install starship -add_to_zshrc 'eval "$(starship init zsh)"' +append_line_if_missing "$HOME/.zshrc" 'eval "$(starship init zsh)"' echo "βœ… Starship ready" # ============================================ @@ -80,7 +80,7 @@ echo "βœ… Vim ready" # ============================================ echo "πŸ”„ Checking mise..." brew_install mise -add_to_zshrc 'eval "$(mise activate zsh)"' +append_line_if_missing "$HOME/.zshrc" 'eval "$(mise activate zsh)"' eval "$(mise activate bash)" echo "🐹 Setting up Go..." @@ -105,9 +105,9 @@ echo "🐍 Setting up Python..." brew_install pyenv brew_install uv -add_to_zshrc 'export PYENV_ROOT="$HOME/.pyenv"' -add_to_zshrc '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' -add_to_zshrc 'eval "$(pyenv init -)"' +append_line_if_missing "$HOME/.zshrc" 'export PYENV_ROOT="$HOME/.pyenv"' +append_line_if_missing "$HOME/.zshrc" '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' +append_line_if_missing "$HOME/.zshrc" 'eval "$(pyenv init -)"' echo "βœ… Python tools ready" diff --git a/work_setup.sh b/work_setup.sh index 070bad3..99956f3 100644 --- a/work_setup.sh +++ b/work_setup.sh @@ -23,6 +23,50 @@ echo "πŸ” Installing Okta Verify..." brew_install_cask okta-verify echo "βœ… Okta Verify ready" +# ============================================ +# Codex + Work MCP servers +# ============================================ +echo "πŸ€– Installing Codex and MCP tools..." +brew_install_cask codex +brew_install mcp-grafana + +append_line_if_missing "$HOME/.zshrc" 'export GRAFANA_URL="${GRAFANA_URL:-}"' +append_line_if_missing "$HOME/.zshrc" 'export GRAFANA_SERVICE_ACCOUNT_TOKEN="${GRAFANA_SERVICE_ACCOUNT_TOKEN:-}"' + +append_block_if_missing "$HOME/.codex/config.toml" "[mcp_servers.grafana]" <<'EOF' +[mcp_servers.grafana] +command = "/opt/homebrew/bin/mcp-grafana" +args = [] +env_vars = [ + "GRAFANA_URL", + "GRAFANA_SERVICE_ACCOUNT_TOKEN", +] +EOF +echo " ↳ Codex MCP 'grafana' configured" + +append_block_if_missing "$HOME/.codex/config.toml" "[mcp_servers.datadog]" <<'EOF' +[mcp_servers.datadog] +url = "https://mcp.datadoghq.com/api/unstable/mcp-server/mcp" +EOF +echo " ↳ Codex MCP 'datadog' configured" + +append_block_if_missing "$HOME/.codex/config.toml" "[mcp_servers.channel-teamchat]" <<'EOF' +[mcp_servers.channel-teamchat] +url = "https://cht-teamchat-mcp.dmz.channel.io/mcp" +EOF +echo " ↳ Codex MCP 'channel-teamchat' configured" + +echo " ↳ Grafana reads GRAFANA_URL and GRAFANA_SERVICE_ACCOUNT_TOKEN when Codex starts" +if [[ -n "$SETUP_NONINTERACTIVE" ]]; then + echo " ↳ SETUP_NONINTERACTIVE β€” Codex MCP OAuth login μŠ€ν‚΅" +elif command -v codex &>/dev/null; then + codex mcp login datadog || echo "⚠️ Datadog MCP login skipped" + codex mcp login channel-teamchat || echo "⚠️ Channel Teamchat MCP login skipped" +else + echo "⚠️ codex command not found. Open Codex once, then retry MCP login manually." +fi +echo "βœ… Codex ready" + # ============================================ # Interactive Section (μ‚¬λžŒ ν•„μš”ν•œ 단계 ν•œ λ²ˆμ—) # ============================================ From 23939a84f10e94fa24025dcb47e97ce0b8a9e153 Mon Sep 17 00:00:00 2001 From: Clsan Date: Fri, 8 May 2026 19:11:25 +0900 Subject: [PATCH 2/3] Retry cask installs after brew update --- common.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/common.sh b/common.sh index 1eb9e83..be03c41 100644 --- a/common.sh +++ b/common.sh @@ -54,7 +54,17 @@ brew_install() { } brew_install_cask() { - brew list --cask "$1" &>/dev/null || brew install --cask "$1" + local cask="$1" + + if brew list --cask "$cask" &>/dev/null; then + return 0 + fi + + brew install --cask "$cask" || { + echo "⚠️ Cask $cask install failed. Updating Homebrew and retrying..." + brew update + brew install --cask "$cask" + } } # λ‹€μš΄λ°›μ•„ μ‹€ν–‰ν•œ .sh νŒŒμΌλ“€μ„ λλ‚˜λ©΄ 정리 From 24ce0193862dec221d9bed8551b32ab57776fd63 Mon Sep 17 00:00:00 2001 From: Clsan Date: Fri, 8 May 2026 19:15:11 +0900 Subject: [PATCH 3/3] Rename setup workflow to ci --- .github/workflows/{lint.yml => ci.yml} | 4 ++-- common.sh | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) rename .github/workflows/{lint.yml => ci.yml} (92%) diff --git a/.github/workflows/lint.yml b/.github/workflows/ci.yml similarity index 92% rename from .github/workflows/lint.yml rename to .github/workflows/ci.yml index f3751a1..b1c8462 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: lint +name: ci on: pull_request: @@ -16,7 +16,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Run shellcheck - # SC2016 μ œμ™Έ: add_to_zshrc 'eval "$(...)"' 처럼 λ¦¬ν„°λŸ΄ κ·ΈλŒ€λ‘œ .zshrc 에 써야 ν•˜λŠ” μΌ€μ΄μŠ€κ°€ μ˜λ„λœ λ™μž‘ + # SC2016 μ œμ™Έ: append_line_if_missing 으둜 λ¦¬ν„°λŸ΄ κ·ΈλŒ€λ‘œ .zshrc 에 써야 ν•˜λŠ” μΌ€μ΄μŠ€κ°€ μ˜λ„λœ λ™μž‘ run: shellcheck --severity=warning --exclude=SC2016 *.sh syntax-check-macos: diff --git a/common.sh b/common.sh index be03c41..67ba170 100644 --- a/common.sh +++ b/common.sh @@ -57,9 +57,11 @@ brew_install_cask() { local cask="$1" if brew list --cask "$cask" &>/dev/null; then + echo " ↳ Cask $cask already installed" return 0 fi + echo " ↳ Installing cask $cask" brew install --cask "$cask" || { echo "⚠️ Cask $cask install failed. Updating Homebrew and retrying..." brew update