Skip to content

feat(make): one-command install-powermetrics-sudo + uninstall targets#336

Merged
Defilan merged 1 commit intomainfrom
feat/install-powermetrics-sudo-make-target
Apr 27, 2026
Merged

feat(make): one-command install-powermetrics-sudo + uninstall targets#336
Defilan merged 1 commit intomainfrom
feat/install-powermetrics-sudo-make-target

Conversation

@Defilan
Copy link
Copy Markdown
Member

@Defilan Defilan commented Apr 27, 2026

Summary

Adds two Makefile targets so the NOPASSWD sudoers install for `--apple-power-enabled` is a one-liner instead of a 5-line shell incantation:

  • `make install-powermetrics-sudo`
  • `make uninstall-powermetrics-sudo`

Why

PR #334 shipped the Apple power gauges and a security-audited sudoers fragment, but the README install steps were:

```bash
TMP=$(mktemp)
sed "s/LLMKUBE_USER/$(whoami)/" deployment/macos/sudoers.d/llmkube-powermetrics > "$TMP"
sudo visudo -cf "$TMP"
sudo install -m 0440 -o root -g wheel "$TMP" /etc/sudoers.d/llmkube-powermetrics
rm "$TMP"
```

That's a friction wall for a feature most users will only ever opt into to feed InferCost. Make targets reduce it to one command without hiding anything: sudo still prompts (consent visible), the granted command is read back via `sudo -ln | grep powermetrics` so the operator can verify scope, and the README still documents the fully manual install for inspection.

What's in it

  • New `install-powermetrics-sudo` target. Renders the `LLMKUBE_USER` placeholder for `whoami`, syntax-checks via `visudo -cf` (refuses to install malformed files rather than break sudo), atomically installs to `/etc/sudoers.d/llmkube-powermetrics` with `0440 root:wheel`, then echoes the granted command back so the operator can verify exactly what was authorized.
  • New `uninstall-powermetrics-sudo` target. Single `sudo rm` plus a one-line note about what the agent will see going forward.
  • README updated to lead with the make targets, with the manual install retained below for operators who want to inspect each step.

Privilege model

Unchanged. Pinned argv (`/usr/bin/powermetrics --samplers cpu_power,gpu_power -i [0-9]*` only), single binary, opt-in via `--apple-power-enabled` flag. The make target collapses keystrokes; it does not change what's granted.

Test plan

  • `make help` shows both new targets in the Metal Agent section
  • `make install-powermetrics-sudo` on a fresh M5 Max with no prior sudoers entry: prompts for password, validates syntax, installs file with correct mode/owner, echoes back the granted command
  • `sudo -ln | grep powermetrics` shows the pinned-argv grant
  • `make uninstall-powermetrics-sudo` removes the file cleanly
  • Reviewers: run on your own Mac if you have one

…ers install

The sudoers fragment for --apple-power-enabled was working but the
README install was a 5-line sed/visudo/install dance. New make targets
collapse it to one command each:

  make install-powermetrics-sudo
  make uninstall-powermetrics-sudo

The install target renders the __LLMKUBE_USER__ placeholder for the
current user, syntax-checks via 'visudo -cf' (refuses to install
malformed files rather than break sudo), and atomically installs to
/etc/sudoers.d/llmkube-powermetrics with 0440 root:wheel ownership.
The granted command is then echoed back via 'sudo -ln | grep
powermetrics' so the operator can verify exactly what was authorized.

Privilege model is unchanged: pinned argv, single binary, opt-in.
The make target only collapses the keystrokes; it does not hide
anything. README still documents the fully manual install for
operators who want to inspect each step.

Signed-off-by: Christopher Maher <chris@mahercode.io>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Defilan Defilan merged commit af48077 into main Apr 27, 2026
18 checks passed
@Defilan Defilan deleted the feat/install-powermetrics-sudo-make-target branch April 27, 2026 04:34
@github-actions github-actions Bot mentioned this pull request Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant