diff options
| author | salmon <salmonik@tuta.io> | 2026-08-09 23:28:12 +0200 |
|---|---|---|
| committer | salmon <salmonik@tuta.io> | 2026-08-09 23:28:12 +0200 |
| commit | da4147a8ca2ed92556eb56061a63e0cccb1984ce (patch) | |
| tree | f6135a996a5dc53bdbf1a0166fb7234f37baa1c5 /install.sh | |
| parent | Document FreeBSD requirements in README (diff) | |
| download | rsplayer-da4147a8ca2ed92556eb56061a63e0cccb1984ce.tar.gz rsplayer-da4147a8ca2ed92556eb56061a63e0cccb1984ce.zip | |
Add FreeBSD rc.d service, install completions only for installed shells
Diffstat (limited to 'install.sh')
| -rwxr-xr-x | install.sh | 103 |
1 files changed, 63 insertions, 40 deletions
| @@ -19,52 +19,75 @@ echo "Stopping existing daemon..." | |||
| 19 | systemctl --user stop rsplayer 2>/dev/null || true | 19 | systemctl --user stop rsplayer 2>/dev/null || true |
| 20 | rsp stop-daemon 2>/dev/null || true | 20 | rsp stop-daemon 2>/dev/null || true |
| 21 | 21 | ||
| 22 | echo "Installing to /usr/bin/rsp..." | 22 | if [ "$(uname -s)" = "FreeBSD" ]; then |
| 23 | sudo 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 | ||
| 25 | echo "" | 27 | echo "" |
| 26 | echo "Installing systemd service..." | 28 | echo "Installing rc.d service..." |
| 27 | mkdir -p ~/.config/systemd/user | 29 | sudo install -m 755 rsplayer.rc /usr/local/etc/rc.d/rsplayer |
| 28 | cp rsplayer.service ~/.config/systemd/user/ | 30 | echo "Service installed. Enable it with:" |
| 29 | 31 | echo " sudo sysrc rsplayer_enable=YES" | |
| 30 | if 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 | ||
| 34 | else | 34 | else |
| 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 | ||
| 37 | fi | 51 | fi |
| 38 | 52 | ||
| 39 | echo "" | 53 | echo "" |
| 40 | echo "Installing shell completions..." | 54 | echo "Installing shell completions (only for shells that are installed)..." |
| 41 | shell_name=$(basename "${SHELL:-}") | 55 | found=0 |
| 42 | case "$shell_name" in | 56 | |
| 43 | bash) | 57 | if 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) | 63 | fi |
| 64 | |||
| 65 | if 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" | 78 | fi |
| 60 | mkdir -p "$(dirname "$dest")" | 79 | |
| 61 | /usr/bin/rsp completions fish > "$dest" | 80 | if 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 |
| 67 | esac | 86 | fi |
| 87 | |||
| 88 | if [ "$found" -eq 0 ]; then | ||
| 89 | echo " → No supported shell (bash/zsh/fish) found; generate manually with: rsp completions <bash|zsh|fish|powershell|elvish>" | ||
| 90 | fi | ||
| 68 | 91 | ||
| 69 | echo "" | 92 | echo "" |
| 70 | echo "Done!" | 93 | echo "Done!" |
