mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-11-16 19:52:17 -05:00
move from /pi to /rover because it isnt just pi anymore.
new json config stuff and ui
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CONFIG_DEST="/etc/roverd.json"
|
||||
|
||||
log() {
|
||||
echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] $*"
|
||||
}
|
||||
|
||||
ensure_user() {
|
||||
local user="$1"
|
||||
local groups="${2:-}"
|
||||
local existing_groups=""
|
||||
local group
|
||||
|
||||
if [[ -n "$groups" ]]; then
|
||||
IFS=',' read -ra group_list <<< "$groups"
|
||||
for group in "${group_list[@]}"; do
|
||||
if getent group "$group" >/dev/null 2>&1; then
|
||||
existing_groups="${existing_groups:+$existing_groups,}$group"
|
||||
else
|
||||
# Different Debian-family installs expose slightly different
|
||||
# hardware groups. Skipping missing optional groups lets one
|
||||
# profile script cover ordinary laptops and Raspberry Pi OS.
|
||||
log "Skipping missing system group '$group' for $user"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if ! id -u "$user" >/dev/null 2>&1; then
|
||||
if [[ -n "$existing_groups" ]]; then
|
||||
useradd -r -s /usr/sbin/nologin -G "$existing_groups" "$user"
|
||||
else
|
||||
useradd -r -s /usr/sbin/nologin "$user"
|
||||
fi
|
||||
elif [[ -n "$existing_groups" ]]; then
|
||||
usermod -a -G "$existing_groups" "$user"
|
||||
fi
|
||||
}
|
||||
|
||||
require_root() {
|
||||
if [[ "${EUID}" -ne 0 ]]; then
|
||||
echo "Please run as root (sudo)" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
validate_install_inputs() {
|
||||
if [[ ! -f "$BINARY_SRC" ]]; then
|
||||
echo "Binary not found at $BINARY_SRC" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$CONFIG_SRC" ]]; then
|
||||
echo "Config source not found at $CONFIG_SRC" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_roverd_binary() {
|
||||
ensure_user roverd "$ROVERD_GROUPS"
|
||||
install -o root -g root -m 0755 "$BINARY_SRC" /usr/local/bin/roverd
|
||||
log "Installed roverd binary for profile $PROFILE"
|
||||
}
|
||||
|
||||
install_roverd_config() {
|
||||
CONFIG_EXISTS=0
|
||||
if [[ -f "$CONFIG_DEST" ]]; then
|
||||
CONFIG_EXISTS=1
|
||||
log "Existing $CONFIG_DEST found; leaving it in place"
|
||||
else
|
||||
install -D -o root -g root -m 0600 "$CONFIG_SRC" "$CONFIG_DEST"
|
||||
log "Installed sample config to $CONFIG_DEST (edit before starting service)"
|
||||
fi
|
||||
}
|
||||
|
||||
install_roverd_unit() {
|
||||
install -m 0644 rover/systemd/roverd.service /etc/systemd/system/roverd.service
|
||||
log "Installed roverd systemd unit"
|
||||
}
|
||||
@@ -0,0 +1,425 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
install_debian_laptop_deps() {
|
||||
# The laptop rover is a dedicated appliance, not a normal desktop/laptop audio
|
||||
# install. Keep this package set intentionally close to the Pi profile so the
|
||||
# same roverd TTS/playback/capture code paths are available on both targets.
|
||||
if command -v ffmpeg >/dev/null 2>&1 \
|
||||
&& command -v arecord >/dev/null 2>&1 \
|
||||
&& command -v aplay >/dev/null 2>&1 \
|
||||
&& command -v amixer >/dev/null 2>&1 \
|
||||
&& command -v v4l2-ctl >/dev/null 2>&1 \
|
||||
&& command -v flite >/dev/null 2>&1 \
|
||||
&& command -v espeak >/dev/null 2>&1 \
|
||||
&& command -v python3 >/dev/null 2>&1 \
|
||||
&& command -v curl >/dev/null 2>&1 \
|
||||
&& command -v xz >/dev/null 2>&1 \
|
||||
&& command -v unzip >/dev/null 2>&1 \
|
||||
&& ldconfig -p 2>/dev/null | grep -q 'libgcc_s\.so\.1' \
|
||||
&& ldconfig -p 2>/dev/null | grep -q 'libstdc\+\+\.so\.6' \
|
||||
&& ldconfig -p 2>/dev/null | grep -q 'libc++\.so\.1' \
|
||||
&& ldconfig -p 2>/dev/null | grep -q 'libc++abi\.so\.1'; then
|
||||
log "Debian laptop media/audio/TTS dependencies already installed; skipping apt install"
|
||||
return
|
||||
fi
|
||||
|
||||
log "Installing Debian laptop rover dependencies (ffmpeg, ALSA tools, V4L2 tools, flite/espeak, Chrome TTS runtime deps)..."
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends \
|
||||
ffmpeg alsa-utils v4l-utils ca-certificates flite espeak python3 curl xz-utils unzip libasound2-plugins libgcc-s1 libstdc++6 libc++1 libc++abi1 \
|
||||
|| apt-get install -y --no-install-recommends \
|
||||
ffmpeg alsa-utils v4l-utils ca-certificates flite espeak python3 curl xz-utils unzip libasound2-plugins libgcc-s1 libstdc++6 libc++1-14 libc++abi1-14
|
||||
}
|
||||
|
||||
DEBIAN_LAPTOP_INSTALLER_CONFIG="/etc/roverd-installer.env"
|
||||
|
||||
disable_debian_laptop_desktop_audio_stack() {
|
||||
# This profile is for a dedicated rover laptop. PipeWire/PulseAudio are good
|
||||
# desktop defaults, but they can grab the hardware device and make the rover's
|
||||
# root/systemd ALSA services fail or route through a moving per-user graph.
|
||||
# Mask them globally and kill already-running instances so ALSA owns the box,
|
||||
# which is the closest behavior to the Pi rover appliance setup.
|
||||
log "Disabling desktop audio daemons for dedicated laptop rover audio"
|
||||
|
||||
local -a user_units=(
|
||||
pipewire.service
|
||||
pipewire.socket
|
||||
pipewire-pulse.service
|
||||
pipewire-pulse.socket
|
||||
wireplumber.service
|
||||
pulseaudio.service
|
||||
pulseaudio.socket
|
||||
)
|
||||
|
||||
if command -v systemctl >/dev/null 2>&1; then
|
||||
systemctl --global disable "${user_units[@]}" >/dev/null 2>&1 || true
|
||||
systemctl --global mask "${user_units[@]}" >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
pkill -x pipewire >/dev/null 2>&1 || true
|
||||
pkill -x pipewire-pulse >/dev/null 2>&1 || true
|
||||
pkill -x wireplumber >/dev/null 2>&1 || true
|
||||
pkill -x pulseaudio >/dev/null 2>&1 || true
|
||||
}
|
||||
|
||||
derive_debian_laptop_alsa_card_from_device() {
|
||||
local device="$1"
|
||||
|
||||
# The common ALSA hardware device shape is hw:CARD,DEVICE. Pulling the card
|
||||
# number from that string gives the installer a useful default while still
|
||||
# allowing the prompt to handle named cards or uncommon PCM strings.
|
||||
if [[ "$device" =~ ^hw:([0-9]+),[0-9]+$ ]]; then
|
||||
printf '%s\n' "${BASH_REMATCH[1]}"
|
||||
return
|
||||
fi
|
||||
|
||||
printf '0\n'
|
||||
}
|
||||
|
||||
read_debian_laptop_installer_value() {
|
||||
local prompt="$1"
|
||||
local default_value="$2"
|
||||
local value=""
|
||||
|
||||
# Prompting through /dev/tty keeps this usable even when the installer is
|
||||
# launched through sudo with stdin redirected. The caller already checks for
|
||||
# an interactive terminal before reaching this function, so failure here is
|
||||
# genuinely unexpected and should stop the install instead of guessing.
|
||||
read -r -p "${prompt} [${default_value}]: " value </dev/tty
|
||||
if [[ -z "$value" ]]; then
|
||||
value="$default_value"
|
||||
fi
|
||||
printf '%s\n' "$value"
|
||||
}
|
||||
|
||||
validate_debian_laptop_alsa_config() {
|
||||
# The PCM fields are written inside quoted ALSA strings, so keep them to the
|
||||
# device spellings ALSA normally uses for hardware/plugin PCMs. Rejecting
|
||||
# whitespace and shell/config punctuation prevents a bad installer config
|
||||
# from generating an asound.conf that changes structure instead of values.
|
||||
if [[ ! "$ROVERD_ALSA_PLAYBACK_DEVICE" =~ ^[A-Za-z0-9_.,:+/-]+$ ]]; then
|
||||
echo "Invalid ROVERD_ALSA_PLAYBACK_DEVICE: $ROVERD_ALSA_PLAYBACK_DEVICE" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! "$ROVERD_ALSA_CAPTURE_DEVICE" =~ ^[A-Za-z0-9_.,:+/-]+$ ]]; then
|
||||
echo "Invalid ROVERD_ALSA_CAPTURE_DEVICE: $ROVERD_ALSA_CAPTURE_DEVICE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Softvol controls and ctl.!default need the playback card, because
|
||||
# TTSMaster, HornMaster, and ForwardMaster are all playback mixer controls.
|
||||
# Keep this numeric to match the prompt and avoid needing quoted ALSA card
|
||||
# ids in the generated config.
|
||||
if [[ ! "$ROVERD_ALSA_PLAYBACK_CARD" =~ ^[0-9]+$ ]]; then
|
||||
echo "Invalid ROVERD_ALSA_PLAYBACK_CARD: $ROVERD_ALSA_PLAYBACK_CARD" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
load_debian_laptop_installer_config_file() {
|
||||
local config_path="$1"
|
||||
local line key val
|
||||
|
||||
# Read only the small allowlist this installer owns. Avoid sourcing the file
|
||||
# because it lives in /etc and is meant to be installer data, not shell code.
|
||||
while IFS= read -r line || [[ -n "$line" ]]; do
|
||||
[[ "$line" =~ ^[[:space:]]*$ ]] && continue
|
||||
[[ "$line" =~ ^[[:space:]]*# ]] && continue
|
||||
|
||||
if [[ "$line" =~ ^[[:space:]]*([A-Za-z_][A-Za-z0-9_]*)=(.*)$ ]]; then
|
||||
key="${BASH_REMATCH[1]}"
|
||||
val="${BASH_REMATCH[2]}"
|
||||
else
|
||||
continue
|
||||
fi
|
||||
|
||||
val="${val#${val%%[![:space:]]*}}"
|
||||
val="${val%${val##*[![:space:]]}}"
|
||||
if [[ "$val" =~ ^\".*\"$ ]]; then
|
||||
val="${val:1:${#val}-2}"
|
||||
elif [[ "$val" =~ ^\'.*\'$ ]]; then
|
||||
val="${val:1:${#val}-2}"
|
||||
fi
|
||||
|
||||
case "$key" in
|
||||
ROVERD_ALSA_PLAYBACK_DEVICE|ROVERD_ALSA_PLAYBACK_CARD|ROVERD_ALSA_CAPTURE_DEVICE)
|
||||
printf -v "$key" '%s' "$val"
|
||||
export "$key"
|
||||
;;
|
||||
esac
|
||||
done < "$config_path"
|
||||
}
|
||||
|
||||
write_debian_laptop_installer_config_file() {
|
||||
local config_path="$1"
|
||||
local tmp_path
|
||||
|
||||
tmp_path="$(mktemp)"
|
||||
# This file is intentionally plain KEY=VALUE shell-style data so future
|
||||
# installs can reuse the same laptop-specific card choices without asking
|
||||
# again. It is still parsed by an allowlist reader instead of sourced.
|
||||
cat > "$tmp_path" <<EOF
|
||||
# Created by install_roverd.sh for the Debian laptop rover profile.
|
||||
# These values choose the physical ALSA hardware behind the rover's logical
|
||||
# mixer devices: tts, horn, forward, default playback, and rovermic capture.
|
||||
ROVERD_ALSA_PLAYBACK_DEVICE="${ROVERD_ALSA_PLAYBACK_DEVICE}"
|
||||
ROVERD_ALSA_PLAYBACK_CARD="${ROVERD_ALSA_PLAYBACK_CARD}"
|
||||
ROVERD_ALSA_CAPTURE_DEVICE="${ROVERD_ALSA_CAPTURE_DEVICE}"
|
||||
EOF
|
||||
install -o root -g root -m 0644 "$tmp_path" "$config_path"
|
||||
rm -f "$tmp_path"
|
||||
}
|
||||
|
||||
load_or_create_debian_laptop_alsa_config() {
|
||||
if [[ -f "$DEBIAN_LAPTOP_INSTALLER_CONFIG" ]]; then
|
||||
load_debian_laptop_installer_config_file "$DEBIAN_LAPTOP_INSTALLER_CONFIG"
|
||||
log "Using Debian laptop ALSA installer config from $DEBIAN_LAPTOP_INSTALLER_CONFIG"
|
||||
elif [[ -n "${ROVERD_ALSA_PLAYBACK_DEVICE:-}" && -n "${ROVERD_ALSA_PLAYBACK_CARD:-}" && -n "${ROVERD_ALSA_CAPTURE_DEVICE:-}" ]]; then
|
||||
# This keeps unattended installs possible without adding a pile of CLI
|
||||
# flags. The generated /etc file still becomes the durable source for
|
||||
# future installs on the same laptop.
|
||||
validate_debian_laptop_alsa_config
|
||||
write_debian_laptop_installer_config_file "$DEBIAN_LAPTOP_INSTALLER_CONFIG"
|
||||
log "Wrote Debian laptop ALSA installer config to $DEBIAN_LAPTOP_INSTALLER_CONFIG from environment"
|
||||
else
|
||||
if ! { true </dev/tty >/dev/tty; } 2>/dev/null; then
|
||||
echo "Missing $DEBIAN_LAPTOP_INSTALLER_CONFIG and no interactive terminal is available for ALSA setup." >&2
|
||||
echo "Run sudo ./rover/install_roverd.sh --debian-laptop once from a terminal, then reuse the generated config for future installs." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "No $DEBIAN_LAPTOP_INSTALLER_CONFIG found; creating Debian laptop ALSA installer config"
|
||||
if command -v aplay >/dev/null 2>&1; then
|
||||
echo "Playback devices from aplay -l:" >/dev/tty
|
||||
aplay -l >/dev/tty 2>/dev/tty || true
|
||||
fi
|
||||
if command -v arecord >/dev/null 2>&1; then
|
||||
echo "Capture devices from arecord -l:" >/dev/tty
|
||||
arecord -l >/dev/tty 2>/dev/tty || true
|
||||
fi
|
||||
|
||||
ROVERD_ALSA_PLAYBACK_DEVICE="$(read_debian_laptop_installer_value "ALSA playback device for rover speaker output" "${ROVERD_ALSA_PLAYBACK_DEVICE:-hw:0,0}")"
|
||||
ROVERD_ALSA_PLAYBACK_CARD="$(read_debian_laptop_installer_value "ALSA playback card number for mixer controls" "${ROVERD_ALSA_PLAYBACK_CARD:-$(derive_debian_laptop_alsa_card_from_device "$ROVERD_ALSA_PLAYBACK_DEVICE")}")"
|
||||
ROVERD_ALSA_CAPTURE_DEVICE="$(read_debian_laptop_installer_value "ALSA capture device for rover microphone input" "${ROVERD_ALSA_CAPTURE_DEVICE:-$ROVERD_ALSA_PLAYBACK_DEVICE}")"
|
||||
|
||||
validate_debian_laptop_alsa_config
|
||||
write_debian_laptop_installer_config_file "$DEBIAN_LAPTOP_INSTALLER_CONFIG"
|
||||
log "Wrote Debian laptop ALSA installer config to $DEBIAN_LAPTOP_INSTALLER_CONFIG"
|
||||
fi
|
||||
|
||||
ROVERD_ALSA_PLAYBACK_DEVICE="${ROVERD_ALSA_PLAYBACK_DEVICE:-hw:0,0}"
|
||||
ROVERD_ALSA_PLAYBACK_CARD="${ROVERD_ALSA_PLAYBACK_CARD:-$(derive_debian_laptop_alsa_card_from_device "$ROVERD_ALSA_PLAYBACK_DEVICE")}"
|
||||
ROVERD_ALSA_CAPTURE_DEVICE="${ROVERD_ALSA_CAPTURE_DEVICE:-$ROVERD_ALSA_PLAYBACK_DEVICE}"
|
||||
validate_debian_laptop_alsa_config
|
||||
}
|
||||
|
||||
render_debian_laptop_asound_config() {
|
||||
local tmp_path
|
||||
|
||||
tmp_path="$(mktemp)"
|
||||
# The rover-facing ALSA names stay stable even when the laptop's physical
|
||||
# sound card changes. dmixer owns the one real playback PCM, while tts,
|
||||
# horn, and forward each wrap that mixer with a separate softvol control.
|
||||
cat > "$tmp_path" <<EOF
|
||||
# Dedicated ALSA routing for the Debian laptop rover profile.
|
||||
#
|
||||
# Generated by install_roverd.sh from $DEBIAN_LAPTOP_INSTALLER_CONFIG.
|
||||
# Change the physical devices there, then rerun the Debian laptop installer.
|
||||
#
|
||||
# Logical playback devices:
|
||||
# tts - default text-to-speech output with TTSMaster softvol
|
||||
# horn - horn synth output with HornMaster softvol
|
||||
# forward - browser-forwarded audio with ForwardMaster softvol
|
||||
# default - TTS playback plus rovermic capture
|
||||
#
|
||||
# Physical routing selected for this laptop:
|
||||
# playback PCM: ${ROVERD_ALSA_PLAYBACK_DEVICE}
|
||||
# playback card: ${ROVERD_ALSA_PLAYBACK_CARD}
|
||||
# capture PCM: ${ROVERD_ALSA_CAPTURE_DEVICE}
|
||||
|
||||
# Mix multiple playback clients in software with a fixed low-cost format.
|
||||
pcm.dmixer {
|
||||
type dmix
|
||||
ipc_key 1024
|
||||
ipc_perm 0666
|
||||
slave {
|
||||
pcm "${ROVERD_ALSA_PLAYBACK_DEVICE}"
|
||||
format S16_LE
|
||||
rate 16000
|
||||
channels 1
|
||||
period_time 0
|
||||
period_size 1024
|
||||
buffer_size 4096
|
||||
}
|
||||
}
|
||||
|
||||
# TTS volume control. TTS uses the default playback route, so this control lets
|
||||
# generated speech move independently from horns and forwarded browser audio.
|
||||
pcm.tts_softvol {
|
||||
type softvol
|
||||
slave.pcm "dmixer"
|
||||
control {
|
||||
name "TTSMaster"
|
||||
card ${ROVERD_ALSA_PLAYBACK_CARD}
|
||||
}
|
||||
min_dB -60.0
|
||||
max_dB 12.0
|
||||
}
|
||||
|
||||
# Horn volume control. The horn synth opens the logical "horn" device, which
|
||||
# keeps horn loudness adjustable without changing the shared hardware PCM.
|
||||
pcm.horn_softvol {
|
||||
type softvol
|
||||
slave.pcm "dmixer"
|
||||
control {
|
||||
name "HornMaster"
|
||||
card ${ROVERD_ALSA_PLAYBACK_CARD}
|
||||
}
|
||||
min_dB -60.0
|
||||
max_dB 12.0
|
||||
}
|
||||
|
||||
# Forwarded audio volume control. The browser-audio listener opens "forward",
|
||||
# so remote audio can be mixed with local rover sounds without bypassing dmix.
|
||||
pcm.forward_softvol {
|
||||
type softvol
|
||||
slave.pcm "dmixer"
|
||||
control {
|
||||
name "ForwardMaster"
|
||||
card ${ROVERD_ALSA_PLAYBACK_CARD}
|
||||
}
|
||||
min_dB -60.0
|
||||
max_dB 12.0
|
||||
}
|
||||
|
||||
# Per-source playback PCMs.
|
||||
pcm.tts {
|
||||
type plug
|
||||
slave.pcm "tts_softvol"
|
||||
}
|
||||
|
||||
pcm.horn {
|
||||
type plug
|
||||
slave.pcm "horn_softvol"
|
||||
}
|
||||
|
||||
pcm.forward {
|
||||
type plug
|
||||
slave.pcm "forward_softvol"
|
||||
}
|
||||
|
||||
# Capture alias used by laptop rover config defaults. Capture is deliberately
|
||||
# separate from playback because laptop speakers and microphones often appear
|
||||
# on different ALSA cards.
|
||||
pcm.rovermic {
|
||||
type plug
|
||||
slave.pcm "${ROVERD_ALSA_CAPTURE_DEVICE}"
|
||||
}
|
||||
|
||||
# Defaults: TTS direct playback + raw capture on the selected laptop devices.
|
||||
pcm.!default {
|
||||
type asym
|
||||
playback.pcm "tts"
|
||||
capture.pcm "rovermic"
|
||||
}
|
||||
|
||||
ctl.!default {
|
||||
type hw
|
||||
card ${ROVERD_ALSA_PLAYBACK_CARD}
|
||||
}
|
||||
EOF
|
||||
install -o root -g root -m 0644 "$tmp_path" /etc/asound.conf
|
||||
rm -f "$tmp_path"
|
||||
log "Installed dedicated Debian laptop ALSA config to /etc/asound.conf using playback ${ROVERD_ALSA_PLAYBACK_DEVICE}"
|
||||
}
|
||||
|
||||
install_debian_laptop_audio_support() {
|
||||
load_or_create_debian_laptop_alsa_config
|
||||
render_debian_laptop_asound_config
|
||||
|
||||
install -D -o root -g root -m 0755 rover/bin/chromegtts-daemon-laptop.py /usr/local/bin/chromegtts-daemon
|
||||
log "Installed laptop chromegtts daemon"
|
||||
|
||||
install_google_tts_assets_laptop
|
||||
|
||||
log "ALSA config updated; reboot recommended before testing laptop rover audio"
|
||||
}
|
||||
|
||||
install_google_tts_assets_laptop() {
|
||||
local asset_dir="/opt/roverd/googletts"
|
||||
local voice_dir="${asset_dir}/en-us-x-multi-r30"
|
||||
local dist_url="https://storage.googleapis.com/chromeos-localmirror/distfiles/googletts-26.5.tar.xz"
|
||||
local tmp_dir
|
||||
local lib_member=""
|
||||
local member
|
||||
|
||||
if [[ -f "${asset_dir}/libchrometts.so" && -f "${voice_dir}/pipeline.pb" ]]; then
|
||||
log "Google Chrome TTS assets already installed; skipping download"
|
||||
return
|
||||
fi
|
||||
|
||||
tmp_dir="$(mktemp -d)"
|
||||
log "Downloading Google Chrome TTS assets for Debian laptop profile..."
|
||||
if ! curl -L -o "${tmp_dir}/googletts-26.5.tar.xz" "$dist_url"; then
|
||||
rm -rf "$tmp_dir"
|
||||
log "WARNING: failed to download Google Chrome TTS assets; chromegtts will be unavailable"
|
||||
return
|
||||
fi
|
||||
|
||||
local -a candidate_libs=()
|
||||
case "$(uname -m)" in
|
||||
aarch64|arm64)
|
||||
candidate_libs=(libchrometts_arm64.so)
|
||||
;;
|
||||
armv7l|armhf)
|
||||
candidate_libs=(libchrometts_armv7.so)
|
||||
;;
|
||||
x86_64|amd64)
|
||||
candidate_libs=(libchrometts_x86_64.so libchrometts_amd64.so libchrometts_x64.so libchrometts.so)
|
||||
;;
|
||||
i386|i686)
|
||||
candidate_libs=(libchrometts_x86.so libchrometts_i386.so libchrometts.so)
|
||||
;;
|
||||
*)
|
||||
log "WARNING: unsupported Chrome TTS architecture $(uname -m); skipping Google TTS assets"
|
||||
rm -rf "$tmp_dir"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
for member in "${candidate_libs[@]}"; do
|
||||
if tar -tf "${tmp_dir}/googletts-26.5.tar.xz" "$member" >/dev/null 2>&1; then
|
||||
lib_member="$member"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z "$lib_member" ]]; then
|
||||
log "WARNING: no libchrometts library matching $(uname -m) found in Google TTS archive; chromegtts will be unavailable"
|
||||
rm -rf "$tmp_dir"
|
||||
return
|
||||
fi
|
||||
|
||||
if ! tar -xf "${tmp_dir}/googletts-26.5.tar.xz" -C "$tmp_dir" en-us-x-multi.zvoice "$lib_member"; then
|
||||
rm -rf "$tmp_dir"
|
||||
log "WARNING: failed to unpack Google Chrome TTS assets; chromegtts will be unavailable"
|
||||
return
|
||||
fi
|
||||
|
||||
install -d -o root -g root -m 0755 "$asset_dir"
|
||||
install -o root -g root -m 0644 "${tmp_dir}/${lib_member}" "${asset_dir}/libchrometts.so"
|
||||
rm -rf "$voice_dir"
|
||||
install -d -o root -g root -m 0755 "$voice_dir"
|
||||
unzip -q "${tmp_dir}/en-us-x-multi.zvoice" -d "$voice_dir"
|
||||
chown -R root:root "$asset_dir"
|
||||
find "$asset_dir" -type d -exec chmod 0755 {} +
|
||||
find "$asset_dir" -type f -exec chmod 0644 {} +
|
||||
rm -rf "$tmp_dir"
|
||||
log "Installed Google Chrome TTS assets to $asset_dir using $lib_member"
|
||||
}
|
||||
|
||||
install_debian_laptop_profile() {
|
||||
install_debian_laptop_deps
|
||||
disable_debian_laptop_desktop_audio_stack
|
||||
install_debian_laptop_audio_support
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
write_media_env_placeholder() {
|
||||
install -d -o roverd -g roverd /var/lib/roverd
|
||||
|
||||
case "$PROFILE" in
|
||||
pi)
|
||||
# roverd rewrites media.env after loading /etc/roverd.json. These
|
||||
# values only make the services syntactically usable before the first
|
||||
# successful roverd run, so they mirror the Pi defaults instead of
|
||||
# trying to become a second source of truth.
|
||||
cat > /var/lib/roverd/media.env <<'ENV'
|
||||
# Managed by roverd; placeholder values will be overwritten at runtime.
|
||||
ROVERD_VIDEO_ENABLE=1
|
||||
ROVERD_VIDEO_PUBLISHER=pi-libcamera
|
||||
ROVERD_VIDEO_PUBLISH_URL=rtsp://control-server.local:8554/CHANGE_ME
|
||||
ROVERD_VIDEO_DEVICE=
|
||||
ROVERD_VIDEO_INPUT_FORMAT=
|
||||
ROVERD_VIDEO_WIDTH=640
|
||||
ROVERD_VIDEO_HEIGHT=480
|
||||
ROVERD_VIDEO_FPS=30
|
||||
ROVERD_VIDEO_BITRATE=2000000
|
||||
ROVERD_VIDEO_INVERT=1
|
||||
ROVERD_VIDEO_SENSOR_MODE=1296:972
|
||||
ROVERD_AUDIO_CAPTURE_ENABLE=0
|
||||
ROVERD_AUDIO_CAPTURE_PUBLISH_URL=rtsp://control-server.local:8554/CHANGE_ME-audio
|
||||
ROVERD_AUDIO_CAPTURE_DEVICE=hw:0,0
|
||||
ROVERD_AUDIO_CAPTURE_SAMPLE_RATE=48000
|
||||
ROVERD_AUDIO_CAPTURE_CHANNELS=2
|
||||
ROVERD_AUDIO_CAPTURE_BITRATE=510000
|
||||
ROVERD_AUDIO_PLAYBACK_ENABLE=1
|
||||
ROVERD_AUDIO_PLAYBACK_FORWARD_URL=rtsp://control-server.local:8554/CHANGE_ME-fwd
|
||||
ROVERD_AUDIO_PLAYBACK_DEVICE=forward
|
||||
ROVERD_AUDIO_PLAYBACK_NORMALIZE=1
|
||||
ROVERD_AUDIO_PLAYBACK_NORMALIZE_FILTER=dynaudnorm=f=75:g=15:m=10:p=0.9,alimiter=limit=0.85:level=disabled
|
||||
ENV
|
||||
;;
|
||||
debian-laptop)
|
||||
# The laptop placeholder uses the same logical ALSA names as the
|
||||
# installed laptop asound.conf. That keeps forwarded audio under the
|
||||
# ForwardMaster mixer control while TTS and horn keep their own paths.
|
||||
cat > /var/lib/roverd/media.env <<'ENV'
|
||||
# Managed by roverd; placeholder values will be overwritten at runtime.
|
||||
ROVERD_VIDEO_ENABLE=1
|
||||
ROVERD_VIDEO_PUBLISHER=debian-laptop-v4l2
|
||||
ROVERD_VIDEO_PUBLISH_URL=rtsp://control-server.local:8554/CHANGE_ME
|
||||
ROVERD_VIDEO_DEVICE=/dev/video0
|
||||
ROVERD_VIDEO_INPUT_FORMAT=mjpeg
|
||||
ROVERD_VIDEO_WIDTH=640
|
||||
ROVERD_VIDEO_HEIGHT=480
|
||||
ROVERD_VIDEO_FPS=30
|
||||
ROVERD_VIDEO_BITRATE=2000000
|
||||
ROVERD_VIDEO_INVERT=0
|
||||
ROVERD_VIDEO_SENSOR_MODE=
|
||||
ROVERD_AUDIO_CAPTURE_ENABLE=1
|
||||
ROVERD_AUDIO_CAPTURE_PUBLISH_URL=rtsp://control-server.local:8554/CHANGE_ME-audio
|
||||
ROVERD_AUDIO_CAPTURE_DEVICE=default
|
||||
ROVERD_AUDIO_CAPTURE_SAMPLE_RATE=48000
|
||||
ROVERD_AUDIO_CAPTURE_CHANNELS=2
|
||||
ROVERD_AUDIO_CAPTURE_BITRATE=510000
|
||||
ROVERD_AUDIO_PLAYBACK_ENABLE=1
|
||||
ROVERD_AUDIO_PLAYBACK_FORWARD_URL=rtsp://control-server.local:8554/CHANGE_ME-fwd
|
||||
ROVERD_AUDIO_PLAYBACK_DEVICE=forward
|
||||
ROVERD_AUDIO_PLAYBACK_NORMALIZE=1
|
||||
ROVERD_AUDIO_PLAYBACK_NORMALIZE_FILTER=dynaudnorm=f=75:g=15:m=10:p=0.9,alimiter=limit=0.85:level=disabled
|
||||
ENV
|
||||
;;
|
||||
esac
|
||||
|
||||
chown roverd:roverd /var/lib/roverd/media.env
|
||||
chmod 0640 /var/lib/roverd/media.env
|
||||
}
|
||||
|
||||
install_audio_fifo() {
|
||||
local fifo_path="/var/lib/roverd/audio.pcm"
|
||||
|
||||
# The capture service and publisher service meet at this FIFO. Recreating
|
||||
# it only when it is missing or the path is not a FIFO preserves a working
|
||||
# service pipe while still fixing accidental regular-file leftovers.
|
||||
if [[ -p "$fifo_path" ]]; then
|
||||
chown roverd:audio "$fifo_path"
|
||||
chmod 0660 "$fifo_path"
|
||||
else
|
||||
rm -f "$fifo_path"
|
||||
mkfifo "$fifo_path"
|
||||
chown roverd:audio "$fifo_path"
|
||||
chmod 0660 "$fifo_path"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
install_pi_video_deps() {
|
||||
if command -v ffmpeg >/dev/null 2>&1 && (command -v rpicam-vid >/dev/null 2>&1 || command -v libcamera-vid >/dev/null 2>&1); then
|
||||
log "Video dependencies already installed; skipping apt install"
|
||||
return
|
||||
fi
|
||||
log "Installing video dependencies (libcamera-apps, ffmpeg)..."
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends libcamera-apps ffmpeg
|
||||
}
|
||||
|
||||
find_boot_config() {
|
||||
if [[ -f /boot/firmware/config.txt ]]; then
|
||||
printf "/boot/firmware/config.txt"
|
||||
return 0
|
||||
fi
|
||||
if [[ -f /boot/config.txt ]]; then
|
||||
printf "/boot/config.txt"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
ensure_pwm_overlay() {
|
||||
local boot_config
|
||||
if ! boot_config="$(find_boot_config)"; then
|
||||
log "WARNING: unable to locate /boot config.txt; please ensure dtoverlay=pwm-2chan is added manually for servo support"
|
||||
return
|
||||
fi
|
||||
if grep -Eq '^\s*dtoverlay=pwm(-2chan)?' "$boot_config"; then
|
||||
log "PWM overlay already present in $boot_config"
|
||||
return
|
||||
fi
|
||||
local backup="${boot_config}.roverd.$(date +%Y%m%d%H%M%S).bak"
|
||||
cp "$boot_config" "$backup"
|
||||
{
|
||||
echo ""
|
||||
echo "# Added by roverd installer to expose PWM hardware for camera servo control on GPIO12/13 (leaves GPIO18/19 free for I2S)"
|
||||
echo "dtoverlay=pwm-2chan,pin=12,func=4,pin2=13,func2=4"
|
||||
} >> "$boot_config"
|
||||
log "Enabled dtoverlay=pwm-2chan on GPIO12/13 in $boot_config (backup at $backup). Reboot required for changes to apply."
|
||||
}
|
||||
|
||||
install_pi_audio_support() {
|
||||
local boot_config
|
||||
if ! boot_config="$(find_boot_config)"; then
|
||||
log "WARNING: unable to locate /boot config.txt; please enable googlevoicehat-soundcard overlay manually"
|
||||
else
|
||||
# Ensure onboard audio is disabled (prevents card index flapping)
|
||||
if grep -Eq '^\s*dtparam=audio=on\b' "$boot_config"; then
|
||||
log "Disabling onboard audio (dtparam=audio=on -> off) in $boot_config"
|
||||
sed -i 's/^\s*dtparam=audio=on\b/# roverd disabled onboard audio\ndtparam=audio=off/' "$boot_config"
|
||||
fi
|
||||
if ! grep -Eq '^\s*dtparam=audio=off\b' "$boot_config"; then
|
||||
log "Adding dtparam=audio=off to $boot_config"
|
||||
echo "dtparam=audio=off" >> "$boot_config"
|
||||
fi
|
||||
if ! grep -Eq '^\s*dtparam=i2s=on\b' "$boot_config"; then
|
||||
log "Adding dtparam=i2s=on to $boot_config"
|
||||
echo "dtparam=i2s=on" >> "$boot_config"
|
||||
fi
|
||||
if ! grep -Eq '^\s*dtoverlay=googlevoicehat-soundcard\b' "$boot_config"; then
|
||||
local backup="${boot_config}.roverd.$(date +%Y%m%d%H%M%S).bak"
|
||||
cp "$boot_config" "$backup"
|
||||
{
|
||||
echo ""
|
||||
echo "# Added by roverd installer to enable Google AIY v1 sound card"
|
||||
echo "dtoverlay=googlevoicehat-soundcard"
|
||||
} >> "$boot_config"
|
||||
log "Enabled googlevoicehat-soundcard overlay in $boot_config (backup at $backup). Reboot required."
|
||||
else
|
||||
log "googlevoicehat-soundcard overlay already present in $boot_config"
|
||||
fi
|
||||
fi
|
||||
if [[ -f rover/asound.conf ]]; then
|
||||
install -m 0644 rover/asound.conf /etc/asound.conf
|
||||
log "Installed ALSA config to /etc/asound.conf"
|
||||
alsa_reload_notice=1
|
||||
else
|
||||
log "WARNING: rover/asound.conf missing; skipping ALSA config install"
|
||||
fi
|
||||
|
||||
if [[ "${alsa_reload_notice:-0}" -eq 1 ]]; then
|
||||
log "ALSA config updated; reboot recommended for overlay + audio changes"
|
||||
fi
|
||||
|
||||
log "Installing TTS/audio packages (flite, espeak, Chrome TTS runtime deps)..."
|
||||
if command -v flite >/dev/null 2>&1 \
|
||||
&& command -v espeak >/dev/null 2>&1 \
|
||||
&& command -v python3 >/dev/null 2>&1 \
|
||||
&& command -v curl >/dev/null 2>&1 \
|
||||
&& command -v xz >/dev/null 2>&1 \
|
||||
&& command -v unzip >/dev/null 2>&1 \
|
||||
&& command -v aplay >/dev/null 2>&1 \
|
||||
&& ldconfig -p 2>/dev/null | grep -q 'libc++\.so\.1' \
|
||||
&& ldconfig -p 2>/dev/null | grep -q 'libc++abi\.so\.1'; then
|
||||
log "Core TTS packages already installed; skipping apt install"
|
||||
else
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends flite espeak python3 curl xz-utils unzip alsa-utils libc++1 libc++abi1 \
|
||||
|| apt-get install -y --no-install-recommends flite espeak python3 curl xz-utils unzip alsa-utils libc++1-14 libc++abi1-14
|
||||
fi
|
||||
|
||||
install -D -o root -g root -m 0755 rover/bin/chromegtts-daemon.py /usr/local/bin/chromegtts-daemon
|
||||
log "Installed chromegtts daemon"
|
||||
|
||||
install_google_tts_assets
|
||||
}
|
||||
|
||||
install_google_tts_assets() {
|
||||
local asset_dir="/opt/roverd/googletts"
|
||||
local voice_dir="${asset_dir}/en-us-x-multi-r30"
|
||||
local dist_url="https://storage.googleapis.com/chromeos-localmirror/distfiles/googletts-26.5.tar.xz"
|
||||
local tmp_dir
|
||||
local lib_member
|
||||
|
||||
case "$(uname -m)" in
|
||||
aarch64|arm64)
|
||||
lib_member="libchrometts_arm64.so"
|
||||
;;
|
||||
armv7l|armhf)
|
||||
lib_member="libchrometts_armv7.so"
|
||||
;;
|
||||
*)
|
||||
log "WARNING: unsupported Chrome TTS architecture $(uname -m); skipping Google TTS assets"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ -f "${asset_dir}/libchrometts.so" && -f "${voice_dir}/pipeline.pb" ]]; then
|
||||
log "Google Chrome TTS assets already installed; skipping download"
|
||||
return
|
||||
fi
|
||||
|
||||
tmp_dir="$(mktemp -d)"
|
||||
log "Downloading Google Chrome TTS assets..."
|
||||
curl -L -o "${tmp_dir}/googletts-26.5.tar.xz" "$dist_url"
|
||||
tar -xf "${tmp_dir}/googletts-26.5.tar.xz" -C "$tmp_dir" en-us-x-multi.zvoice "$lib_member"
|
||||
|
||||
install -d -o root -g root -m 0755 "$asset_dir"
|
||||
install -o root -g root -m 0644 "${tmp_dir}/${lib_member}" "${asset_dir}/libchrometts.so"
|
||||
rm -rf "$voice_dir"
|
||||
install -d -o root -g root -m 0755 "$voice_dir"
|
||||
unzip -q "${tmp_dir}/en-us-x-multi.zvoice" -d "$voice_dir"
|
||||
chown -R root:root "$asset_dir"
|
||||
find "$asset_dir" -type d -exec chmod 0755 {} +
|
||||
find "$asset_dir" -type f -exec chmod 0644 {} +
|
||||
rm -rf "$tmp_dir"
|
||||
log "Installed Google Chrome TTS assets to $asset_dir"
|
||||
}
|
||||
|
||||
install_pi_profile() {
|
||||
if ! command -v rpicam-vid >/dev/null 2>&1 && ! command -v libcamera-vid >/dev/null 2>&1; then
|
||||
log "WARNING: neither rpicam-vid nor libcamera-vid found in PATH; install libcamera-apps."
|
||||
fi
|
||||
install_pi_video_deps
|
||||
ensure_pwm_overlay
|
||||
install_pi_audio_support
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
PROFILE="pi"
|
||||
BINARY_SRC=""
|
||||
CONFIG_SRC=""
|
||||
|
||||
usage() {
|
||||
cat <<'USAGE'
|
||||
Usage: sudo ./rover/install_roverd.sh [options]
|
||||
|
||||
Options:
|
||||
--profile <name> Install profile: pi or debian-laptop (default: pi)
|
||||
--debian-laptop Shortcut for --profile debian-laptop
|
||||
-b, --binary <path> Path to the roverd binary (default: detected OS architecture)
|
||||
-c, --config <path> Source config to install if /etc/roverd.json is missing
|
||||
(default depends on profile)
|
||||
-h, --help Show this help text
|
||||
|
||||
The script must run from the repository root and as root (sudo). It will:
|
||||
* create system users/groups if needed
|
||||
* install /usr/local/bin/roverd and /etc/roverd.json
|
||||
* install profile-specific video helpers and shared audio helpers
|
||||
* install profile-specific ALSA/system audio setup
|
||||
* install the fixed-command self-update helper used by admin-triggered updates
|
||||
* enable roverd.service and media publisher/listener services
|
||||
USAGE
|
||||
}
|
||||
|
||||
parse_args() {
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--profile)
|
||||
PROFILE="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--debian-laptop)
|
||||
PROFILE="debian-laptop"
|
||||
shift
|
||||
;;
|
||||
-b|--binary)
|
||||
BINARY_SRC="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
-c|--config)
|
||||
CONFIG_SRC="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1" >&2
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
select_profile() {
|
||||
# Binary selection follows the installed userland, independent of the
|
||||
# temporary media installer profiles removed later in the rework.
|
||||
case "$(dpkg --print-architecture)" in
|
||||
amd64) binary_arch=amd64 ;;
|
||||
arm64) binary_arch=arm64 ;;
|
||||
armhf)
|
||||
# ARMv6 also runs on ARMv7; use the conservative artifact for
|
||||
# 32-bit Debian derivatives whose armhf baseline differs.
|
||||
binary_arch=armv6 ;;
|
||||
*) echo "Unsupported OS architecture" >&2; exit 1 ;;
|
||||
esac
|
||||
BINARY_SRC="${BINARY_SRC:-dist/roverd-linux-$binary_arch}"
|
||||
|
||||
case "$PROFILE" in
|
||||
pi)
|
||||
CONFIG_SRC="${CONFIG_SRC:-rover/roverd/roverd.sample.json}"
|
||||
VIDEO_HELPER_SRC="rover/bin/video-publisher.sh"
|
||||
VIDEO_HELPER_DEST="/usr/local/bin/video-publisher"
|
||||
VIDEO_SERVICE_SRC="rover/systemd/video-publisher.service"
|
||||
VIDEO_SERVICE_NAME="video-publisher.service"
|
||||
ROVERD_GROUPS="dialout,gpio,video,render,audio"
|
||||
;;
|
||||
debian-laptop)
|
||||
CONFIG_SRC="${CONFIG_SRC:-rover/roverd/roverd.debian-laptop.sample.json}"
|
||||
VIDEO_HELPER_SRC="rover/bin/debian-laptop-video-publisher.sh"
|
||||
VIDEO_HELPER_DEST="/usr/local/bin/debian-laptop-video-publisher"
|
||||
VIDEO_SERVICE_SRC="rover/systemd/debian-laptop-video-publisher.service"
|
||||
VIDEO_SERVICE_NAME="debian-laptop-video-publisher.service"
|
||||
ROVERD_GROUPS="dialout,video,render,audio"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown profile: $PROFILE" >&2
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
install_selected_profile() {
|
||||
case "$PROFILE" in
|
||||
pi)
|
||||
# The Pi profile owns the board-specific camera, PWM, and AIY audio
|
||||
# setup. Keeping that hardware work behind this dispatcher prevents
|
||||
# the laptop profile from accidentally inheriting Pi overlays or
|
||||
# card-index assumptions.
|
||||
install_pi_profile
|
||||
;;
|
||||
debian-laptop)
|
||||
# The Debian laptop profile only installs ordinary Debian packages
|
||||
# and a laptop ALSA routing file. Anything that depends on Pi GPIO,
|
||||
# overlays, or the Google Voice HAT stays out of this path.
|
||||
install_debian_laptop_profile
|
||||
;;
|
||||
esac
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
install_self_update_support() {
|
||||
local sudoers_file="/etc/sudoers.d/roverd-self-update"
|
||||
local update_env="/etc/roverd-update.env"
|
||||
local quoted_repo_root
|
||||
|
||||
# The self-update helper must know which checkout should receive the git
|
||||
# pull. Recording the repository root during the normal installer run keeps
|
||||
# the runtime websocket command simple and prevents the rover from accepting
|
||||
# a caller-controlled path.
|
||||
printf -v quoted_repo_root '%q' "$REPO_ROOT"
|
||||
install -D -o root -g root -m 0644 /dev/null "$update_env"
|
||||
cat > "$update_env" <<ENV
|
||||
# Managed by rover/install_roverd.sh.
|
||||
# This path is intentionally captured from the installer working directory so
|
||||
# admin-triggered rover updates always operate on the same full repository that
|
||||
# was used for the manual install.
|
||||
ROVERD_REPO_DIR=$quoted_repo_root
|
||||
ENV
|
||||
log "Registered roverd update repository at $REPO_ROOT"
|
||||
|
||||
# The helper is root-owned and argument-free. sudoers grants the roverd
|
||||
# service user exactly this command and nothing broader, which is important
|
||||
# because update requests arrive over the rover websocket.
|
||||
install -D -o root -g root -m 0755 rover/bin/roverd-self-update.sh /usr/local/sbin/roverd-self-update
|
||||
cat > "$sudoers_file" <<'SUDOERS'
|
||||
# Managed by rover/install_roverd.sh.
|
||||
# Allow only the roverd service account to run the fixed self-update helper.
|
||||
roverd ALL=(root) NOPASSWD: /usr/local/sbin/roverd-self-update
|
||||
SUDOERS
|
||||
chown root:root "$sudoers_file"
|
||||
chmod 0440 "$sudoers_file"
|
||||
if command -v visudo >/dev/null 2>&1; then
|
||||
visudo -cf "$sudoers_file" >/dev/null
|
||||
fi
|
||||
log "Installed roverd self-update helper and sudoers rule"
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
install_media_units() {
|
||||
# Video publishing is the only profile-specific media service right now:
|
||||
# Pi uses libcamera/rpicam, while Debian laptops publish from a V4L2 webcam.
|
||||
install -D -o root -g root -m 0755 "$VIDEO_HELPER_SRC" "$VIDEO_HELPER_DEST"
|
||||
log "Installed $PROFILE video publisher helper"
|
||||
install -m 0644 "$VIDEO_SERVICE_SRC" "/etc/systemd/system/$VIDEO_SERVICE_NAME"
|
||||
log "Installed $PROFILE video publisher systemd unit"
|
||||
|
||||
# Audio capture publishing and forwarded-audio playback use the same ffmpeg
|
||||
# and ALSA contract on both profiles, so they stay as shared installer work.
|
||||
install -D -o root -g root -m 0755 rover/bin/audio-only-publisher.sh /usr/local/bin/audio-only-publisher
|
||||
install -m 0644 rover/systemd/audio-only-publisher.service /etc/systemd/system/audio-only-publisher.service
|
||||
log "Installed audio-only publisher helper + systemd unit"
|
||||
|
||||
install -D -o root -g root -m 0755 rover/bin/audio-forward-listener.sh /usr/local/bin/audio-forward-listener
|
||||
install -m 0644 rover/systemd/audio-forward-listener.service /etc/systemd/system/audio-forward-listener.service
|
||||
log "Installed audio-forward listener helper + systemd unit"
|
||||
}
|
||||
|
||||
enable_and_restart_units() {
|
||||
systemctl daemon-reload
|
||||
systemctl enable roverd.service
|
||||
systemctl enable "$VIDEO_SERVICE_NAME"
|
||||
systemctl enable audio-only-publisher.service
|
||||
systemctl enable audio-forward-listener.service
|
||||
|
||||
if [[ $CONFIG_EXISTS -eq 1 ]]; then
|
||||
# An existing config means this host was already configured, so restart
|
||||
# immediately to pick up the new binary, helpers, units, and media env.
|
||||
systemctl restart roverd.service
|
||||
systemctl restart "$VIDEO_SERVICE_NAME"
|
||||
systemctl restart audio-only-publisher.service
|
||||
systemctl restart audio-forward-listener.service
|
||||
log "Restarted roverd + media publishers/listener"
|
||||
else
|
||||
# A freshly installed sample config usually still has placeholder names
|
||||
# and URLs. Enabling without starting avoids connecting a half-configured
|
||||
# rover to the control server by accident.
|
||||
log "Skipped auto-start because config is the sample; edit $CONFIG_DEST then run: sudo systemctl restart roverd ${VIDEO_SERVICE_NAME%.service} audio-only-publisher audio-forward-listener"
|
||||
fi
|
||||
}
|
||||
Reference in New Issue
Block a user