Skip to content

Add one-shot CLI installation bash script#21

Merged
stympy merged 10 commits intomainfrom
claude/add-install-script-WtUoi
Mar 11, 2026
Merged

Add one-shot CLI installation bash script#21
stympy merged 10 commits intomainfrom
claude/add-install-script-WtUoi

Conversation

@stympy
Copy link
Copy Markdown
Member

@stympy stympy commented Jan 19, 2026

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
  • No sudo required — installs to ~/.local/bin by default for non-root users, /usr/local/bin when run as root
  • Supports --install-dir to override the install directory
  • Prints a hint if the install directory is not in $PATH
  • Systemd service is opt-in via --service flag (requires root)
  • Accepts API key via --api-key flag or prompts interactively (when --service is used)
  • Supports --interval flag for custom reporting intervals (when --service is used)
  • Warns if --api-key or --interval are used without --service
  • Applies security hardening to the systemd service unit

Usage

# Install the binary (no sudo required)
curl -sSL .../install.sh | bash

# Install and set up as a systemd service
curl -sSL .../install.sh | sudo bash -s -- --service --api-key YOUR_API_KEY

🤖 Generated with Claude Code

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
@stympy stympy self-assigned this Jan 19, 2026
Copilot AI review requested due to automatic review settings January 19, 2026 15:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread install.sh
Comment thread install.sh
Comment thread install.sh
Comment thread install.sh
Comment thread install.sh
Comment thread install.sh Outdated
Comment thread install.sh
Comment thread install.sh
Comment thread install.sh Outdated
Comment thread install.sh Outdated
@excid3
Copy link
Copy Markdown

excid3 commented Mar 3, 2026

@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.

stympy and others added 3 commits March 3, 2026 13:38
- 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>
@stympy stympy requested review from a team and Copilot March 3, 2026 22:08
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread install.sh
Comment thread install.sh Outdated
Comment thread install.sh
Comment thread install.sh
Comment thread install.sh
stympy and others added 2 commits March 3, 2026 14:21
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>
@stympy
Copy link
Copy Markdown
Member Author

stympy commented Mar 3, 2026

@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.

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

@excid3
Copy link
Copy Markdown

excid3 commented Mar 3, 2026

Thanks @stympy! Just tested and it worked like a charm. 💖

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@joshuap joshuap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stympy code looks good, a few thoughts:

  1. Would this be useful to desktop linux users and/or macOS users who aren't using Homebrew?
  2. 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.

@joshuap
Copy link
Copy Markdown
Member

joshuap commented Mar 4, 2026

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.

@stympy
Copy link
Copy Markdown
Member Author

stympy commented Mar 4, 2026

@stympy code looks good, a few thoughts:

  1. Would this be useful to desktop linux users and/or macOS users who aren't using Homebrew?
  2. 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.

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.

Comment thread README.md Outdated

### 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):
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joshuap how about this?

Suggested change
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):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stympy and others added 2 commits March 11, 2026 14:23
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>
@stympy stympy merged commit 6adfd21 into main Mar 11, 2026
4 checks passed
@stympy stympy deleted the claude/add-install-script-WtUoi branch April 6, 2026 16:08
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.

5 participants