From 4cfd7159bfa1ff6a588e18856a8dd81b216ab262 Mon Sep 17 00:00:00 2001 From: Axodouble Date: Thu, 14 May 2026 05:42:14 +0000 Subject: [PATCH] Updated install scripts --- README.md | 62 ++++++++++++++++++++++++++++++---------------------- install.sh | 64 ++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 81 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 9260685..cde3513 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,16 @@ A single static binary contains the daemon, the CLI, and everything in between. Inter-node traffic is mutual TLS with SSH-style fingerprint trust — no central CA, no shared secret. +## Installation + +### From pre-built binary + +This can be done in one step, either by downloading the latest release from +the [Gitea releases page](https://git.cer.sh/axodouble/quptime/releases) or by running the following script: +```sh +curl -fsSL https://git.cer.sh/Axodouble/QUptime/raw/branch/master/install.sh | sudo bash +``` + ## Why Most uptime monitors are either a SaaS or a single box that, by @@ -210,17 +220,17 @@ every two seconds. Keybindings: -| Key | Action | -|---|---| -| `↑` / `↓` | move cursor within a tab | -| `Tab` / `Shift+Tab` | next / previous tab | -| `1` / `2` / `3` | jump to Peers / Checks / Alerts | -| `r` | force-refresh | -| `a` | add (opens a picker on Checks/Alerts; node form on Peers) | -| `d` | remove the selected row (confirmation prompt) | -| `t` | send a test message to the selected alert | -| `D` | toggle the selected alert's `default` flag | -| `q` / `Ctrl+C` | quit | +| Key | Action | +| ------------------- | --------------------------------------------------------- | +| `↑` / `↓` | move cursor within a tab | +| `Tab` / `Shift+Tab` | next / previous tab | +| `1` / `2` / `3` | jump to Peers / Checks / Alerts | +| `r` | force-refresh | +| `a` | add (opens a picker on Checks/Alerts; node form on Peers) | +| `d` | remove the selected row (confirmation prompt) | +| `t` | send a test message to the selected alert | +| `D` | toggle the selected alert's `default` flag | +| `q` / `Ctrl+C` | quit | Forms run the same control-plane methods the CLI does, so any side effect (a mutation, a node add, an alert test) ends up routed through @@ -247,21 +257,21 @@ qu alert add smtp ops --host ... --from ... --to ... \ Available template variables: -| Variable | Meaning | -|---|---| -| `{{.Check.Name}}` | check name | -| `{{.Check.Type}}` | `http` / `tcp` / `icmp` | -| `{{.Check.Target}}` | URL or host:port being probed | -| `{{.Check.ID}}` | UUID | -| `{{.From}}` | previous state (`up` / `down` / `unknown`) | -| `{{.To}}` | new state | -| `{{.Verb}}` | `UP` / `DOWN` / `RECOVERED` | -| `{{.Snapshot.Reports}}` | total per-node reports counted | -| `{{.Snapshot.OKCount}}` | how many reported OK | -| `{{.Snapshot.NotOK}}` | how many reported failure | -| `{{.Snapshot.Detail}}` | first failure detail string | -| `{{.NodeID}}` | master that dispatched | -| `{{.When}}` | RFC3339 timestamp | +| Variable | Meaning | +| ----------------------- | ------------------------------------------ | +| `{{.Check.Name}}` | check name | +| `{{.Check.Type}}` | `http` / `tcp` / `icmp` | +| `{{.Check.Target}}` | URL or host:port being probed | +| `{{.Check.ID}}` | UUID | +| `{{.From}}` | previous state (`up` / `down` / `unknown`) | +| `{{.To}}` | new state | +| `{{.Verb}}` | `UP` / `DOWN` / `RECOVERED` | +| `{{.Snapshot.Reports}}` | total per-node reports counted | +| `{{.Snapshot.OKCount}}` | how many reported OK | +| `{{.Snapshot.NotOK}}` | how many reported failure | +| `{{.Snapshot.Detail}}` | first failure detail string | +| `{{.NodeID}}` | master that dispatched | +| `{{.When}}` | RFC3339 timestamp | `qu alert test ` exercises the template against a synthetic "homepage going DOWN" transition, so you can verify rendering before diff --git a/install.sh b/install.sh index 6fe9435..74599e1 100644 --- a/install.sh +++ b/install.sh @@ -1,24 +1,50 @@ #!/bin/bash -# Check if ~/.local/bin exists, if not, create it -if [ ! -d "$HOME/.local/bin" ]; then - mkdir -p "$HOME/.local/bin" -fi +# Helper function which echo's all commands before executing them in grayscale prefixed with > +echo_cmd() { + echo -e "\033[90m> $1\033[0m" + eval "$1" +} -# Check if ~/.local/bin is in the PATH, if not, give the user a command to add it -if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then - echo "Please add the following line to your shell configuration file (e.g., ~/.bashrc, ~/.zshrc) to include ~/.local/bin in your PATH:" - echo 'export PATH="$HOME/.local/bin:$PATH"' - echo "After adding the line, please restart your terminal or run 'source ~/.bashrc' (or the appropriate command for your shell) to apply the changes." -fi - -# Download the binary from git.cer.sh/axodouble/quptime -# Check whether curl or wget is available -if command -v curl > /dev/null; then - curl -L -o "$HOME/.local/bin/quptime" "https://git.cer.sh/axodouble/quptime/-/raw/main/quptime" -elif command -v wget > /dev/null; then - wget -O "$HOME/.local/bin/quptime" "https://git.cer.sh/axodouble/quptime/-/raw/main/quptime" +# Check if the user is allowed to write to /usr/local/bin, if so, install qu there, else error out and ask the user to install qu manually +if [ -w "/usr/local/bin" ]; then + # Download the latest release binary from the Git repository and save it to /usr/local/bin/qu + if command -v curl > /dev/null; then + release_tag=$(curl -s https://git.cer.sh/api/v1/repos/axodouble/quptime/releases/latest | jq -r '.tag_name') + echo_cmd "curl -L -o \"/usr/local/bin/qu\" \"https://git.cer.sh/axodouble/quptime/releases/latest/download/qu-$(release_tag)-$(uname -m)\"" + echo_cmd "chmod +x \"/usr/local/bin/qu\"" + echo "> qu has been installed to /usr/local/bin/qu" + exit 0 + else + echo "Error: curl is not installed. Please install curl and try again." + exit 1 + fi else - echo "Error: Neither curl nor wget is installed. Please install one of these tools to download the quptime binary." + echo "Error: You are not allowed to write to /usr/local/bin. Please install qu manually, or run this script with sudo." exit 1 -fi \ No newline at end of file +fi + +# Check if the user has systemd, if so create a systemd service file for qu serve +if command -v systemctl > /dev/null; then + echo "> Creating systemd service file for qu serve..." + cat < /etc/systemd/system/qu-serve.service +[Unit] +Description=QUptime Serve +After=network.target + +[Service] +ExecStart=/usr/local/bin/qu serve +Restart=always +User=$(whoami) + +[Install] +WantedBy=multi-user.target +EOL + echo_cmd "systemctl daemon-reload" + echo_cmd "systemctl enable qu-serve.service" + echo "> qu serve service has been created and enabled. You can start it with 'systemctl start qu-serve.service'" +else + echo "> Warning: systemd is not available on this system. qu serve will not be automatically started on boot. You can start it manually with '/usr/local/bin/qu serve'" +fi + +echo "Installation complete, before starting `qu serve`, make sure to run `qu init` and read the documentation."