aboutsummaryrefslogtreecommitdiffstats
path: root/install.sh
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xinstall.sh103
1 files changed, 63 insertions, 40 deletions
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..."
19systemctl --user stop rsplayer 2>/dev/null || true 19systemctl --user stop rsplayer 2>/dev/null || true
20rsp stop-daemon 2>/dev/null || true 20rsp stop-daemon 2>/dev/null || true
21 21
22echo "Installing to /usr/bin/rsp..." 22if [ "$(uname -s)" = "FreeBSD" ]; then
23sudo install target/release/rsp /usr/bin/rsp 23 BIN="/usr/local/bin/rsp"
24 echo "Installing to ${BIN}..."
25 sudo install target/release/rsp "${BIN}"
24 26
25echo "" 27 echo ""
26echo "Installing systemd service..." 28 echo "Installing rc.d service..."
27mkdir -p ~/.config/systemd/user 29 sudo install -m 755 rsplayer.rc /usr/local/etc/rc.d/rsplayer
28cp rsplayer.service ~/.config/systemd/user/ 30 echo "Service installed. Enable it with:"
29 31 echo " sudo sysrc rsplayer_enable=YES"
30if systemctl --user is-active default.target &>/dev/null; then 32 echo " sudo sysrc rsplayer_user=$USER # the user that runs the rsp CLI"
31 systemctl --user daemon-reload 33 echo " sudo service rsplayer start"
32 echo "Activating the daemon…"
33 systemctl --user restart --now rsplayer.service
34else 34else
35 echo "Service installed but not enabled (no user session running)" 35 echo "Installing to /usr/bin/rsp..."
36 echo "To enable later when logged in: systemctl --user enable rsplayer" 36 sudo install target/release/rsp /usr/bin/rsp
37
38 echo ""
39 echo "Installing systemd service..."
40 mkdir -p ~/.config/systemd/user
41 cp rsplayer.service ~/.config/systemd/user/
42
43 if systemctl --user is-active default.target &>/dev/null; then
44 systemctl --user daemon-reload
45 echo "Activating the daemon…"
46 systemctl --user restart --now rsplayer.service
47 else
48 echo "Service installed but not enabled (no user session running)"
49 echo "To enable later when logged in: systemctl --user enable rsplayer"
50 fi
37fi 51fi
38 52
39echo "" 53echo ""
40echo "Installing shell completions..." 54echo "Installing shell completions (only for shells that are installed)..."
41shell_name=$(basename "${SHELL:-}") 55found=0
42case "$shell_name" in 56
43 bash) 57if command -v bash >/dev/null 2>&1; then
44 dest="${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion/completions" 58 dest="${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion/completions"
45 mkdir -p "$dest" 59 mkdir -p "$dest"
46 cp completions/rsp.bash "$dest/rsp" 60 "${BIN}" completions bash > "$dest/rsp"
47 echo " → Bash completions: $dest/rsp" 61 echo " → Bash completions: $dest/rsp"
48 ;; 62 found=1
49 zsh) 63fi
64
65if command -v zsh >/dev/null 2>&1; then
66 if [ "$(uname -s)" = "FreeBSD" ]; then
67 dest="/usr/local/share/zsh/site-functions/_rsp"
68 else
50 dest="/usr/share/zsh/site-functions/_rsp" 69 dest="/usr/share/zsh/site-functions/_rsp"
51 tmpfile=$(mktemp) 70 fi
52 /usr/bin/rsp completions zsh > "$tmpfile" 71 tmpfile=$(mktemp)
53 cat completions/_rsp >> "$tmpfile" 72 "${BIN}" completions zsh > "$tmpfile"
54 sudo cp "$tmpfile" "$dest" 73 cat completions/_rsp >> "$tmpfile"
55 rm -f "$tmpfile" 74 sudo cp "$tmpfile" "$dest"
56 echo " → Zsh completions: $dest" 75 rm -f "$tmpfile"
57 ;; 76 echo " → Zsh completions: $dest"
58 fish) 77 found=1
59 dest="$HOME/.config/fish/completions/rsp.fish" 78fi
60 mkdir -p "$(dirname "$dest")" 79
61 /usr/bin/rsp completions fish > "$dest" 80if command -v fish >/dev/null 2>&1; then
62 echo " → Fish completions: $dest" 81 dest="$HOME/.config/fish/completions/rsp.fish"
63 ;; 82 mkdir -p "$(dirname "$dest")"
64 *) 83 "${BIN}" completions fish > "$dest"
65 echo " → Unrecognized shell '$shell_name'; generate with: rsp completions <bash|zsh|fish|powershell|elvish>" 84 echo " → Fish completions: $dest"
66 ;; 85 found=1
67esac 86fi
87
88if [ "$found" -eq 0 ]; then
89 echo " → No supported shell (bash/zsh/fish) found; generate manually with: rsp completions <bash|zsh|fish|powershell|elvish>"
90fi
68 91
69echo "" 92echo ""
70echo "Done!" 93echo "Done!"