install.sh RawHistoryFolder
1#!/bin/sh
2set -e
3
4# Dumber installer script
5# Usage: curl -fsSL https://dumber.bnema.dev/install | sh
6
7REPO="bnema/dumber"
8
9# Prefer ~/.local/bin if it exists and is in PATH, otherwise /usr/local/bin
10if [ -d "$HOME/.local/bin" ]; then
11 INSTALL_DIR="$HOME/.local/bin"
12 case ":$PATH:" in
13 *":$HOME/.local/bin:"*) ;;
14 *) echo "Warning: $HOME/.local/bin is not in your PATH" ;;
15 esac
16else
17 INSTALL_DIR="/usr/local/bin"
18fi
19
20echo "Installing Dumber..."
21
22# Check OS
23OS=$(uname -s | tr '[:upper:]' '[:lower:]')
24if [ "$OS" != "linux" ]; then
25 echo "Error: Only Linux is supported. Detected: $OS"
26 exit 1
27fi
28
29# Check architecture
30ARCH=$(uname -m)
31if [ "$ARCH" != "x86_64" ] && [ "$ARCH" != "amd64" ]; then
32 echo "Error: Only x86_64 is supported. Detected: $ARCH"
33 exit 1
34fi
35
36echo "Detected: linux/x86_64"
37
38TARBALL="dumber_linux_x86_64.tar.gz"
39DOWNLOAD_URL="https://github.com/${REPO}/releases/latest/download/${TARBALL}"
40
41# Create temporary directory
42TMP_DIR=$(mktemp -d)
43trap 'rm -rf "$TMP_DIR"' EXIT
44
45# Download checksums file
46CHECKSUMS_URL="https://github.com/${REPO}/releases/latest/download/checksums.txt"
47echo "Downloading checksums..."
48if ! curl -fsSL "$CHECKSUMS_URL" -o "$TMP_DIR/checksums.txt"; then
49 echo "Error: Failed to download checksums file"
50 exit 1
51fi
52
53echo "Downloading ${TARBALL}..."
54if ! curl -fsSL "$DOWNLOAD_URL" -o "$TMP_DIR/$TARBALL"; then
55 echo "Error: Failed to download ${TARBALL}"
56 exit 1
57fi
58
59# Verify checksum
60echo "Verifying checksum..."
61EXPECTED_CHECKSUM=$(grep -E "[[:space:]]${TARBALL}\$" "$TMP_DIR/checksums.txt" | awk '{print $1}')
62if [ -z "$EXPECTED_CHECKSUM" ]; then
63 echo "Error: Could not find checksum for ${TARBALL}"
64 exit 1
65fi
66
67if command -v sha256sum >/dev/null 2>&1; then
68 ACTUAL_CHECKSUM=$(sha256sum "$TMP_DIR/$TARBALL" | awk '{print $1}')
69else
70 echo "Error: sha256sum not found"
71 exit 1
72fi
73
74if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then
75 echo "Error: Checksum verification failed!"
76 echo "Expected: $EXPECTED_CHECKSUM"
77 echo "Actual: $ACTUAL_CHECKSUM"
78 exit 1
79fi
80echo "Checksum verified."
81
82echo "Extracting..."
83tar -xzf "$TMP_DIR/$TARBALL" -C "$TMP_DIR"
84
85# Find the dumber binary (handles versioned subdirectory)
86BINARY=$(find "$TMP_DIR" -name "dumber" -type f -executable | head -1)
87if [ -z "$BINARY" ]; then
88 echo "Error: Could not find dumber binary in archive"
89 exit 1
90fi
91
92echo "Installing to ${INSTALL_DIR}..."
93if [ -w "$INSTALL_DIR" ]; then
94 mv "$BINARY" "$INSTALL_DIR/dumber"
95else
96 echo "sudo required to install to ${INSTALL_DIR}"
97 sudo mv "$BINARY" "$INSTALL_DIR/dumber"
98fi
99
100# Verify installation
101if command -v dumber >/dev/null 2>&1; then
102 echo ""
103 echo "Dumber installed successfully!"
104 dumber about
105else
106 echo ""
107 echo "Installation complete. Add ${INSTALL_DIR} to your PATH if needed."
108fi