Created
October 22, 2025 23:54
-
-
Save caoer/89e8c8af89a49698d1eef25f671fc57c to your computer and use it in GitHub Desktop.
ccc-statusd installation script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # ccc-statusd installation script | |
| # Usage: curl -fsSL https://raw.githubusercontent.com/caoer/ccc-statusd/main/install.sh | bash | |
| set -e | |
| REPO="caoer/ccc-statusd" | |
| INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}" | |
| VERSION="${VERSION:-latest}" | |
| # Detect OS and architecture | |
| detect_platform() { | |
| OS=$(uname -s | tr '[:upper:]' '[:lower:]') | |
| ARCH=$(uname -m) | |
| case "$OS" in | |
| darwin) OS="darwin" ;; | |
| linux) OS="linux" ;; | |
| *) echo "Unsupported OS: $OS"; exit 1 ;; | |
| esac | |
| case "$ARCH" in | |
| x86_64|amd64) ARCH="amd64" ;; | |
| arm64|aarch64) ARCH="arm64" ;; | |
| *) echo "Unsupported architecture: $ARCH"; exit 1 ;; | |
| esac | |
| echo "Detected platform: $OS-$ARCH" | |
| } | |
| # Get latest version tag | |
| get_latest_version() { | |
| if command -v gh &> /dev/null; then | |
| VERSION=$(gh release list -R "$REPO" --limit 1 | awk '{print $1}') | |
| elif [ -n "$GITHUB_TOKEN" ]; then | |
| VERSION=$(curl -fsSL -H "Authorization: token $GITHUB_TOKEN" \ | |
| "https://api.github.com/repos/$REPO/releases/latest" | \ | |
| grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/') | |
| else | |
| echo "Error: Cannot determine latest version" | |
| echo "Please install 'gh' CLI or set GITHUB_TOKEN environment variable" | |
| exit 1 | |
| fi | |
| if [ -z "$VERSION" ]; then | |
| echo "Error: Could not determine latest version" | |
| exit 1 | |
| fi | |
| echo "Installing version: $VERSION" | |
| } | |
| # Download binary | |
| download_binary() { | |
| BINARY_NAME="ccc-statusd-$OS-$ARCH" | |
| # Try gh CLI first | |
| if command -v gh &> /dev/null; then | |
| echo "Downloading using gh CLI..." | |
| gh release download "$VERSION" -R "$REPO" -p "$BINARY_NAME" -O /tmp/ccc-statusd | |
| elif [ -n "$GITHUB_TOKEN" ]; then | |
| echo "Downloading using GITHUB_TOKEN..." | |
| curl -fsSL -H "Authorization: token $GITHUB_TOKEN" \ | |
| "https://github.com/$REPO/releases/download/$VERSION/$BINARY_NAME" \ | |
| -o /tmp/ccc-statusd | |
| else | |
| echo "Error: Authentication required" | |
| echo "Install 'gh' CLI and authenticate, or set GITHUB_TOKEN environment variable" | |
| exit 1 | |
| fi | |
| } | |
| # Install binary | |
| install_binary() { | |
| mkdir -p "$INSTALL_DIR" | |
| # Stop running daemon if exists | |
| if command -v ccc-statusd &> /dev/null; then | |
| echo "Stopping running daemon..." | |
| ccc-statusd stop 2>/dev/null || true | |
| fi | |
| mv /tmp/ccc-statusd "$INSTALL_DIR/ccc-statusd" | |
| chmod +x "$INSTALL_DIR/ccc-statusd" | |
| echo "✓ Installed to: $INSTALL_DIR/ccc-statusd" | |
| } | |
| # Verify installation | |
| verify_installation() { | |
| if ! echo "$PATH" | grep -q "$INSTALL_DIR"; then | |
| echo "" | |
| echo "⚠️ Warning: $INSTALL_DIR is not in your PATH" | |
| echo "Add this to your shell profile (~/.bashrc, ~/.zshrc, etc.):" | |
| echo " export PATH=\"$INSTALL_DIR:\$PATH\"" | |
| fi | |
| VERSION_OUTPUT=$("$INSTALL_DIR/ccc-statusd" version) | |
| echo "" | |
| echo "✓ Installation successful: $VERSION_OUTPUT" | |
| echo "" | |
| echo "Next steps:" | |
| echo " 1. Start daemon: ccc-statusd start" | |
| echo " 2. Install hooks: ccc-statusd hook install" | |
| echo " 3. Check status: ccc-statusd status" | |
| } | |
| # Main | |
| main() { | |
| echo "Installing ccc-statusd..." | |
| echo "" | |
| detect_platform | |
| if [ "$VERSION" = "latest" ]; then | |
| get_latest_version | |
| fi | |
| download_binary | |
| install_binary | |
| verify_installation | |
| } | |
| main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment