#!/bin/sh # This file is a part of RSPlayer # Licensed under the GPL-3.0 License # Copyright (C) 2026 Salmonik @ salmonik@tuta.io # https://codeberg.org/salmonik/RSPlayer set -e if ping -W 2 -c 1 codeberg.org >/dev/null 2>&1; then echo "Updating the repo..." git pull 2>/dev/null fi echo "Building rsplayer in release mode..." cargo build --release echo "Stopping existing daemon..." systemctl --user stop rsplayer 2>/dev/null || true rsp stop-daemon 2>/dev/null || true if [ "$(uname -s)" = "FreeBSD" ]; then BIN="/usr/local/bin/rsp" echo "Installing to ${BIN}..." sudo install target/release/rsp "${BIN}" echo "" echo "Installing rc.d service..." sudo install -m 755 rsplayer.rc /usr/local/etc/rc.d/rsplayer echo "Activating the rc.d service for user ${USER}..." sudo sysrc rsplayer_enable=YES sudo sysrc rsplayer_user="$USER" sudo service rsplayer start elif [ "$(uname -s)" = "Linux" ]; then BIN="/usr/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 2>&1; 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 (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" 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!"