diff --git a/README.md b/README.md index 84d6ca1..29c2540 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,15 @@ +## dendrite.daemon + +The core component of [Dendrite](https://kristianjborgwarth.github.io/dendrite.docs/). A Go server that manages the index for a local markdown vault and exposes it over JSON-RPC 2.0. + +## Installation + +```sh +curl -fsSL https://raw.githubusercontent.com/KristianJBorgwarth/dendrite.daemon/master/install.sh | sh +``` + +Supports Linux and macOS on amd64 and arm64. The script places the binary in `~/.local/bin` on Linux and `/usr/local/bin` on macOS. Re-run to update. + ## Documentation -See the [Dendrite docs](https://kristianjborgwarth.github.io/dendrite.docs/) for protocol reference and usage. +See the [Dendrite docs](https://kristianjborgwarth.github.io/dendrite.docs/) for the full protocol reference, method documentation, and setup guide. diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..429ff4f --- /dev/null +++ b/install.sh @@ -0,0 +1,68 @@ +#!/bin/sh +set -e + +REPO="KristianJBorgwarth/dendrite.daemon" +BINARY="dendrite" + +# Detect OS +OS="$(uname -s)" +case "$OS" in + Linux) GOOS="linux" ;; + Darwin) GOOS="darwin" ;; + *) + echo "Unsupported OS: $OS" + exit 1 + ;; +esac + +# Detect architecture +ARCHITECTURE="$(uname -m)" +case "$ARCHITECTURE" in + x86_64) GOARCH="amd64" ;; + arm64 | aarch64) GOARCH="arm64" ;; + *) + echo "Unsupported architecture: $ARCHITECTURE" + exit 1 + ;; +esac + +# Resolve install dir +if [ "$GOOS" = "darwin" ]; then + INSTALL_DIR="/usr/local/bin" +else + INSTALL_DIR="$HOME/.local/bin" + mkdir -p "$INSTALL_DIR" +fi + +# Fetch latest release tag +echo "Fetching latest release..." +TAG="$(curl -fsSL "https://api.github.com/repos/$REPO/releases/latest" \ + | grep '"tag_name"' \ + | sed 's/.*"tag_name": *"\(.*\)".*/\1/')" + +if [ -z "$TAG" ]; then + echo "Could not determine latest release tag." + exit 1 +fi + +ASSET="${BINARY}-${GOOS}-${GOARCH}" +URL="https://github.com/$REPO/releases/download/$TAG/$ASSET" + +echo "Downloading $ASSET ($TAG)..." +curl -fsSL "$URL" -o "$INSTALL_DIR/$BINARY" +chmod +x "$INSTALL_DIR/$BINARY" + +echo "" +echo "dendrite $TAG installed to $INSTALL_DIR/$BINARY" + +# Warn if install dir is not on PATH +case ":$PATH:" in + *":$INSTALL_DIR:"*) ;; + *) + echo "" + echo "Warning: $INSTALL_DIR is not on your PATH." + echo "Add the following to your shell profile:" + echo "" + echo " export PATH=\"$INSTALL_DIR:\$PATH\"" + ;; +esac