#!/usr/bin/env bash # clip-sync one-liner installer # curl -sSL https://git.dracodev.net/Projets/clip-sync/raw/branch/main/install.sh | bash set -euo pipefail REPO="https://git.dracodev.net/Projets/clip-sync" CONFIG_DIR="${HOME}/.config/clip-sync" BIN_DIR="${HOME}/.local/bin" # --- detect OS/arch --- OS=$(uname -s | tr '[:upper:]' '[:lower:]') ARCH=$(uname -m) case "$ARCH" in x86_64) ARCH="amd64" ;; aarch64) ARCH="arm64" ;; armv7l) ARCH="arm" ;; esac case "$OS" in linux) BINARY="clip-sync-linux-${ARCH}" ;; darwin) BINARY="clip-sync-darwin-${ARCH}" ;; mingw*|msys*|cygwin*) OS="windows"; BINARY="clip-sync-windows-${ARCH}.exe" ;; esac echo "→ clip-sync installer: ${OS}/${ARCH}" # --- download or build --- mkdir -p "$BIN_DIR" "$CONFIG_DIR" # Try release download first (v1.0.0+) DOWNLOAD_URL="${REPO}/releases/download/latest/${BINARY}" if command -v curl &>/dev/null; then if curl -fSL --max-time 30 "$DOWNLOAD_URL" -o "${BIN_DIR}/clip-sync" 2>/dev/null; then echo "✓ Downloaded ${BINARY}" chmod +x "${BIN_DIR}/clip-sync" else echo "⚠ Release not found, building from source (need Go)..." # Fallback: build from source TMPDIR=$(mktemp -d) git clone "$REPO" "$TMPDIR" 2>/dev/null || { echo "✗ git clone failed. Install Go and git, or wait for v1.0.0 release."; exit 1; } cd "$TMPDIR" go build -o "${BIN_DIR}/clip-sync" . rm -rf "$TMPDIR" echo "✓ Built from source" fi elif command -v wget &>/dev/null; then wget -q --timeout=30 "$DOWNLOAD_URL" -O "${BIN_DIR}/clip-sync" && chmod +x "${BIN_DIR}/clip-sync" && echo "✓ Downloaded ${BINARY}" || echo "⚠ Download failed" fi # --- config --- if [ ! -f "${CONFIG_DIR}/peers.toml" ]; then curl -sSL "${REPO}/raw/branch/main/peers.example.toml" -o "${CONFIG_DIR}/peers.toml" 2>/dev/null || true echo "✓ Created ${CONFIG_DIR}/peers.toml (edit your peers!)" else echo "• Config already exists: ${CONFIG_DIR}/peers.toml" fi # --- PATH hint --- if [[ ":$PATH:" != *":${BIN_DIR}:"* ]]; then echo "" echo "⚠ Add to your PATH:" echo " export PATH=\"${BIN_DIR}:\$PATH\"" echo " (add this to ~/.bashrc or ~/.zshrc)" fi echo "" echo "✓ clip-sync installed!" echo " 1. Edit ${CONFIG_DIR}/peers.toml — add your machines" echo " 2. Run: clip-sync" echo " 3. (Optional) Set up as a service for auto-start"