Add one-shot CLI installation bash script#21
Conversation
Add install.sh that allows users to install the Honeybadger CLI with a single curl command. The script: - Detects OS (Linux/macOS) and architecture (x86_64/arm64) - Downloads the appropriate release from GitHub (latest by default) - Supports specifying a specific version with --version flag - Installs binary to /usr/local/bin - Configures systemd service for the metrics agent - Accepts API key via --api-key flag or prompts interactively - Supports --interval flag for custom reporting intervals - Includes --no-service flag for binary-only installation - Applies security hardening to the systemd service unit
There was a problem hiding this comment.
Pull request overview
This PR adds a comprehensive bash installation script (install.sh) that enables one-command installation of the Honeybadger CLI from GitHub releases. The script handles platform detection, binary download and installation, and optional systemd service configuration for automated metrics reporting.
Changes:
- Adds install.sh with platform detection for Linux/macOS and architecture detection for x86_64/arm64
- Implements automatic download of CLI binaries from GitHub releases with version selection support
- Includes systemd service configuration with security hardening for continuous metrics reporting
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@stympy any idea when you'll have time to finish this up? Would love to add this to Hatchbox for monitoring hosts, database backups, and cron for customers. |
- Validate --interval is a positive integer - Validate flag arguments aren't empty or another flag - Hide API key input during interactive prompt (read -s) - Move temp directory cleanup trap to main for proper scoping - Stop existing service before overwriting during reinstall - Fix usage() to exit with error code when called from error path - Remove unused version_number variable - Track service installation state to avoid redundant check_systemd call in print_summary Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Read API key from /dev/tty so prompt works in curl|bash piped execution - Set rootCmd.Version so cobra's --version flag works for post-install check - Add sudo to all curl|bash usage examples since script requires root Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- G704: endpoint URL is user-configured via flag/env, not tainted - G101: test struct fields are not real credentials Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The inline #nosec comment on the struct definition wasn't suppressing gosec G101 warnings on individual test case literals. Use the proper golangci-lint v2 linters.exclusions.rules config to exclude G101 from test files instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add --fail flag to curl download so HTTP 404/500 errors fail fast instead of writing error pages that cause confusing tar extraction failures - Create install directory with mkdir -p for minimal distros where /usr/local/bin may not exist - Pre-create systemd service file with 600 permissions via install(1) so the API key is never exposed with default umask permissions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Thanks for the nudge! I spent some time on it today, and I think it's ready to go. I tested as follows, and it worked as expected: # Load the script content from the branch
curl -sSL https://raw.githubusercontent.com/honeybadger-io/cli/2d3ad5d2289a057a0da1a1afec475d38cceaba00/install.sh | sudo bash |
|
Thanks @stympy! Just tested and it worked like a charm. 💖 |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
@stympy code looks good, a few thoughts:
- Would this be useful to desktop linux users and/or macOS users who aren't using Homebrew?
- Either way, would it make sense to not install the service by default, and have a flag to opt in to it? The readme says "optionally", which I think is confusing when you have to add a flag to skip the agent.
|
I ask because it's becoming common to use a bash script as an install path for CLI devtools, and I could see people not reading and just running this and then being confused. |
Yeah, it could be useful to people who aren't using Homebrew — I hadn't considered that. My original intent for this work was to have an installation method that was geared towards automated provisioning of servers, not desktop users. |
|
|
||
| ### Install Script | ||
|
|
||
| On Linux, you can use the install script to download the binary and optionally set up a systemd service for the [metrics agent](#reporting-api-commands): |
There was a problem hiding this comment.
@joshuap how about this?
| On Linux, you can use the install script to download the binary and optionally set up a systemd service for the [metrics agent](#reporting-api-commands): | |
| On Linux, you can use the install script to download the binary and set up a systemd service for the [metrics agent](#reporting-api-commands): |
There was a problem hiding this comment.
I'm good if you want to go with that. It might be a nice addition in the future to make it a universal installer for desktops and servers (or we could have two scripts I suppose).
There was a problem hiding this comment.
It might be better as two scripts... a desktop user is probably going to want to use the personal token rather than the project api key that this installer expects.
There was a problem hiding this comment.
Separate makes sense to me. For example, in Hatchbox I plan to add a "Monitor with Honeybadger" option on database backups and cron jobs but I don't know if I'd necessarily want those to add the systemd service. I would expect that to be a monitoring feature to enable on the cluster or server.
There was a problem hiding this comment.
Thanks for the input! I'm leaning towards a single script, but with the systemd service as opt-in with a flag like --agent-service.
Flip systemd service setup from opt-out (--no-service) to opt-in (--service), and support installing without sudo by defaulting to ~/.local/bin for non-root users. Adds --install-dir override, PATH detection hint, and warnings when service-only flags are used without --service. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add install.sh that allows users to install the Honeybadger CLI with a single curl command. The script:
--versionflag~/.local/binby default for non-root users,/usr/local/binwhen run as root--install-dirto override the install directory$PATH--serviceflag (requires root)--api-keyflag or prompts interactively (when--serviceis used)--intervalflag for custom reporting intervals (when--serviceis used)--api-keyor--intervalare used without--serviceUsage
🤖 Generated with Claude Code