Files
zed-bridge/install.sh
T
2026-07-16 12:08:54 +10:00

52 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# install.sh — build and install zed-bridge on Linux Mint / Ubuntu
set -euo pipefail
BINARY_NAME="zed-bridge"
INSTALL_DIR="$HOME/.local/bin"
CONFIG_DIR="$HOME/.config/zed-bridge"
SERVICE_DIR="$HOME/.config/systemd/user"
echo "==> Checking for Rust toolchain..."
if ! command -v cargo &>/dev/null; then
echo " Rust not found. Install from https://rustup.rs then re-run this script."
exit 1
fi
echo "==> Building release binary..."
cargo build --release
echo "==> Installing binary to $INSTALL_DIR/$BINARY_NAME"
mkdir -p "$INSTALL_DIR"
cp "target/release/$BINARY_NAME" "$INSTALL_DIR/$BINARY_NAME"
chmod +x "$INSTALL_DIR/$BINARY_NAME"
echo "==> Installing systemd user service..."
mkdir -p "$SERVICE_DIR"
cp "zed-bridge.service" "$SERVICE_DIR/$BINARY_NAME.service"
echo "==> Setting up config (if not already present)..."
mkdir -p "$CONFIG_DIR"
if [ ! -f "$CONFIG_DIR/config.json" ]; then
cp config.example.json "$CONFIG_DIR/config.json"
echo ""
echo " *** Config created at $CONFIG_DIR/config.json ***"
echo " Edit it to add your repo paths, then continue."
echo ""
else
echo " Config already exists — not overwriting."
fi
echo "==> Enabling and starting service..."
systemctl --user daemon-reload
systemctl --user enable "$BINARY_NAME"
systemctl --user start "$BINARY_NAME"
echo ""
echo "✅ Done! Service status:"
systemctl --user status "$BINARY_NAME" --no-pager
echo ""
echo "Test it: curl 'http://localhost:7654/health'"
echo "Logs: journalctl --user -u $BINARY_NAME -f"