claude-rc/install.sh

53 lines
1.9 KiB
Bash
Raw Permalink Normal View History

#!/bin/sh
# install.sh — install the claude-rc system on this host (idempotent).
#
# - symlinks bin/* into the first of ~/.local/bin | ~/bin that is on $PATH
# - installs the systemd --user template unit (copied, so `systemctl enable`
# can manage its own symlinks cleanly)
# - seeds ~/.config/claude-rc/projects from projects.example if absent
#
# After install: enable linger once (so units start at boot without login):
# sudo loginctl enable-linger "$USER"
# then bring the registered servers up:
# claude-rc sync
set -eu
repo=$(cd "$(dirname "$0")" && pwd)
# --- bin symlinks ----------------------------------------------------------
target=""
for c in "$HOME/.local/bin" "$HOME/bin"; do
case ":$PATH:" in *":$c:"*) target=$c; break ;; esac
done
[ -n "$target" ] || target="$HOME/.local/bin"
mkdir -p "$target"
for f in "$repo"/bin/*; do
ln -sfn "$f" "$target/$(basename "$f")"
echo "link: $target/$(basename "$f")"
done
case ":$PATH:" in *":$target:"*) ;; *) echo "note: add $target to PATH" ;; esac
# --- systemd --user template unit ------------------------------------------
if command -v systemctl >/dev/null 2>&1; then
ud="$HOME/.config/systemd/user"
mkdir -p "$ud"
cp "$repo/units/claude-rc@.service" "$ud/claude-rc@.service"
echo "copy: $ud/claude-rc@.service"
systemctl --user daemon-reload && echo "ok: systemd --user daemon-reloaded"
else
echo "note: systemctl --user not available — persistent units are Linux-only"
fi
# --- registry --------------------------------------------------------------
reg="$HOME/.config/claude-rc/projects"
if [ ! -f "$reg" ]; then
mkdir -p "$(dirname "$reg")"
cp "$repo/projects.example" "$reg"
echo "seed: $reg (edit it, then: claude-rc sync)"
else
echo "ok: registry exists: $reg"
fi
echo
echo "done. next: 'sudo loginctl enable-linger $USER' (boot-start) then 'claude-rc sync'"