From da4147a8ca2ed92556eb56061a63e0cccb1984ce Mon Sep 17 00:00:00 2001 From: salmon Date: Sun, 9 Aug 2026 23:28:12 +0200 Subject: Add FreeBSD rc.d service, install completions only for installed shells --- install.sh | 103 +++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 63 insertions(+), 40 deletions(-) (limited to 'install.sh') diff --git a/install.sh b/install.sh index 25a1f52..9280507 100755 --- a/install.sh +++ b/install.sh @@ -19,52 +19,75 @@ echo "Stopping existing daemon..." systemctl --user stop rsplayer 2>/dev/null || true rsp stop-daemon 2>/dev/null || true -echo "Installing to /usr/bin/rsp..." -sudo install target/release/rsp /usr/bin/rsp +if [ "$(uname -s)" = "FreeBSD" ]; then + BIN="/usr/local/bin/rsp" + echo "Installing to ${BIN}..." + sudo install target/release/rsp "${BIN}" -echo "" -echo "Installing systemd service..." -mkdir -p ~/.config/systemd/user -cp rsplayer.service ~/.config/systemd/user/ - -if systemctl --user is-active default.target &>/dev/null; then - systemctl --user daemon-reload - echo "Activating the daemon…" - systemctl --user restart --now rsplayer.service + echo "" + echo "Installing rc.d service..." + sudo install -m 755 rsplayer.rc /usr/local/etc/rc.d/rsplayer + echo "Service installed. Enable it with:" + echo " sudo sysrc rsplayer_enable=YES" + echo " sudo sysrc rsplayer_user=$USER # the user that runs the rsp CLI" + echo " sudo service rsplayer start" else - echo "Service installed but not enabled (no user session running)" - echo "To enable later when logged in: systemctl --user enable rsplayer" + echo "Installing to /usr/bin/rsp..." + sudo install target/release/rsp /usr/bin/rsp + + echo "" + echo "Installing systemd service..." + mkdir -p ~/.config/systemd/user + cp rsplayer.service ~/.config/systemd/user/ + + if systemctl --user is-active default.target &>/dev/null; then + systemctl --user daemon-reload + echo "Activating the daemon…" + systemctl --user restart --now rsplayer.service + else + echo "Service installed but not enabled (no user session running)" + echo "To enable later when logged in: systemctl --user enable rsplayer" + fi fi echo "" -echo "Installing shell completions..." -shell_name=$(basename "${SHELL:-}") -case "$shell_name" in - bash) - dest="${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion/completions" - mkdir -p "$dest" - cp completions/rsp.bash "$dest/rsp" - echo " → Bash completions: $dest/rsp" - ;; - zsh) +echo "Installing shell completions (only for shells that are installed)..." +found=0 + +if command -v bash >/dev/null 2>&1; then + dest="${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion/completions" + mkdir -p "$dest" + "${BIN}" completions bash > "$dest/rsp" + echo " → Bash completions: $dest/rsp" + found=1 +fi + +if command -v zsh >/dev/null 2>&1; then + if [ "$(uname -s)" = "FreeBSD" ]; then + dest="/usr/local/share/zsh/site-functions/_rsp" + else dest="/usr/share/zsh/site-functions/_rsp" - tmpfile=$(mktemp) - /usr/bin/rsp completions zsh > "$tmpfile" - cat completions/_rsp >> "$tmpfile" - sudo cp "$tmpfile" "$dest" - rm -f "$tmpfile" - echo " → Zsh completions: $dest" - ;; - fish) - dest="$HOME/.config/fish/completions/rsp.fish" - mkdir -p "$(dirname "$dest")" - /usr/bin/rsp completions fish > "$dest" - echo " → Fish completions: $dest" - ;; - *) - echo " → Unrecognized shell '$shell_name'; generate with: rsp completions " - ;; -esac + fi + tmpfile=$(mktemp) + "${BIN}" completions zsh > "$tmpfile" + cat completions/_rsp >> "$tmpfile" + sudo cp "$tmpfile" "$dest" + rm -f "$tmpfile" + echo " → Zsh completions: $dest" + found=1 +fi + +if command -v fish >/dev/null 2>&1; then + dest="$HOME/.config/fish/completions/rsp.fish" + mkdir -p "$(dirname "$dest")" + "${BIN}" completions fish > "$dest" + echo " → Fish completions: $dest" + found=1 +fi + +if [ "$found" -eq 0 ]; then + echo " → No supported shell (bash/zsh/fish) found; generate manually with: rsp completions " +fi echo "" echo "Done!" -- cgit v1.2.3