feat: implémentation complete v0.1.0 — daemon de sync clipboard bidirectionnel
CI / Lint (push) Failing after 14m46s
CI / Test (push) Failing after 4m23s
CI / Build (darwin/amd64) (push) Skipped
CI / Build (linux/amd64) (push) Skipped
CI / Build (windows/amd64) (push) Skipped
CI / Build (darwin/arm64) (push) Skipped
CI / Build (linux/arm64) (push) Skipped
CI / Build (windows/arm64) (push) Skipped
CI / Release (push) Skipped
CI / Lint (push) Failing after 14m46s
CI / Test (push) Failing after 4m23s
CI / Build (darwin/amd64) (push) Skipped
CI / Build (linux/amd64) (push) Skipped
CI / Build (windows/amd64) (push) Skipped
CI / Build (darwin/arm64) (push) Skipped
CI / Build (linux/arm64) (push) Skipped
CI / Build (windows/arm64) (push) Skipped
CI / Release (push) Skipped
This commit is contained in:
+134
-54
@@ -1,70 +1,150 @@
|
||||
#!/usr/bin/env bash
|
||||
# clip-sync one-liner installer
|
||||
# curl -sSL https://git.dracodev.net/Projets/clip-sync/raw/branch/main/install.sh | bash
|
||||
# clip-sync install.sh
|
||||
# One-liner install: curl -sSL URL | bash
|
||||
#
|
||||
# Detects OS and architecture, downloads the correct binary,
|
||||
# installs to ~/.local/bin/, and creates a default config.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REPO="https://git.dracodev.net/Projets/clip-sync"
|
||||
VERSION="${CLIP_SYNC_VERSION:-latest}"
|
||||
BINARY="clip-sync"
|
||||
INSTALL_DIR="${HOME}/.local/bin"
|
||||
CONFIG_DIR="${HOME}/.config/clip-sync"
|
||||
BIN_DIR="${HOME}/.local/bin"
|
||||
CONFIG_FILE="${CONFIG_DIR}/peers.toml"
|
||||
|
||||
# --- 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
|
||||
# ── Detect platform ────────────────────────────────────────────────────
|
||||
|
||||
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
|
||||
detect_platform() {
|
||||
local os arch
|
||||
|
||||
echo "→ clip-sync installer: ${OS}/${ARCH}"
|
||||
case "$(uname -s)" in
|
||||
Linux) os="linux" ;;
|
||||
Darwin) os="darwin" ;;
|
||||
MINGW*|MSYS*|CYGWIN*) os="windows" ;;
|
||||
*)
|
||||
echo "clip-sync: unsupported OS: $(uname -s)"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# --- download or build ---
|
||||
mkdir -p "$BIN_DIR" "$CONFIG_DIR"
|
||||
case "$(uname -m)" in
|
||||
x86_64|amd64) arch="amd64" ;;
|
||||
aarch64|arm64) arch="arm64" ;;
|
||||
*)
|
||||
echo "clip-sync: unsupported architecture: $(uname -m)"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# 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"
|
||||
echo "${os}-${arch}"
|
||||
}
|
||||
|
||||
# ── Download binary ────────────────────────────────────────────────────
|
||||
|
||||
download_binary() {
|
||||
local platform="$1"
|
||||
local bin_name="${BINARY}-${platform}"
|
||||
local download_url
|
||||
|
||||
if [ "$VERSION" = "latest" ]; then
|
||||
# Try latest release
|
||||
download_url="${REPO}/releases/download/latest/${bin_name}"
|
||||
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"
|
||||
download_url="${REPO}/releases/download/${VERSION}/${bin_name}"
|
||||
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
|
||||
# Windows binary has .exe extension
|
||||
if [[ "$platform" == windows-* ]]; then
|
||||
bin_name="${bin_name}.exe"
|
||||
download_url="${download_url}.exe"
|
||||
fi
|
||||
|
||||
# --- PATH hint ---
|
||||
if [[ ":$PATH:" != *":${BIN_DIR}:"* ]]; then
|
||||
echo "clip-sync: downloading ${download_url}..."
|
||||
|
||||
if command -v curl &>/dev/null; then
|
||||
curl -fSL --progress-bar -o "${INSTALL_DIR}/${BINARY}" "${download_url}" || {
|
||||
echo "clip-sync: download failed. Try building from source:"
|
||||
echo " git clone ${REPO} && cd clip-sync && make install"
|
||||
exit 1
|
||||
}
|
||||
elif command -v wget &>/dev/null; then
|
||||
wget -q --show-progress -O "${INSTALL_DIR}/${BINARY}" "${download_url}" || {
|
||||
echo "clip-sync: download failed. Try building from source:"
|
||||
echo " git clone ${REPO} && cd clip-sync && make install"
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
echo "clip-sync: curl or wget required for download"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
chmod +x "${INSTALL_DIR}/${BINARY}"
|
||||
echo "clip-sync: installed to ${INSTALL_DIR}/${BINARY}"
|
||||
}
|
||||
|
||||
# ── Create default config ──────────────────────────────────────────────
|
||||
|
||||
create_config() {
|
||||
if [ -f "${CONFIG_FILE}" ]; then
|
||||
echo "clip-sync: config already exists at ${CONFIG_FILE} (skipping)"
|
||||
return
|
||||
fi
|
||||
|
||||
mkdir -p "${CONFIG_DIR}"
|
||||
cat > "${CONFIG_FILE}" <<'EOF'
|
||||
# clip-sync peers configuration
|
||||
# ~/.config/clip-sync/peers.toml
|
||||
#
|
||||
# Environment overrides:
|
||||
# CLIP_SYNC_PORT=9137 override daemon.port
|
||||
# CLIP_SYNC_POLL_MS=500 override daemon.poll_interval_ms
|
||||
|
||||
[daemon]
|
||||
port = 9137
|
||||
poll_interval_ms = 500
|
||||
|
||||
# Add your peers here:
|
||||
# [[peers]]
|
||||
# name = "example"
|
||||
# addr = "192.168.1.x:9137"
|
||||
EOF
|
||||
|
||||
echo "clip-sync: created default config at ${CONFIG_FILE}"
|
||||
echo "clip-sync: edit it to add your peers, then run: ${BINARY}"
|
||||
}
|
||||
|
||||
# ── Main ────────────────────────────────────────────────────────────────
|
||||
|
||||
main() {
|
||||
echo "clip-sync installer"
|
||||
echo "==================="
|
||||
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"
|
||||
mkdir -p "${INSTALL_DIR}"
|
||||
|
||||
local platform
|
||||
platform=$(detect_platform)
|
||||
echo "clip-sync: detected platform: ${platform}"
|
||||
|
||||
download_binary "${platform}"
|
||||
create_config
|
||||
|
||||
# Check if install dir is in PATH
|
||||
if ! echo "${PATH}" | tr ':' '\n' | grep -qF "${INSTALL_DIR}"; then
|
||||
echo ""
|
||||
echo "clip-sync: NOTE: ${INSTALL_DIR} is not in your PATH."
|
||||
echo " Add this to your shell config:"
|
||||
echo " export PATH=\"\${HOME}/.local/bin:\${PATH}\""
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "clip-sync: installation complete!"
|
||||
echo " 1. Edit ${CONFIG_FILE} to add your peers"
|
||||
echo " 2. Run: ${BINARY}"
|
||||
echo ""
|
||||
echo " For service installation, see README.md"
|
||||
}
|
||||
|
||||
main
|
||||
|
||||
Reference in New Issue
Block a user