mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-11-16 19:52:17 -05:00
117 lines
3.4 KiB
Bash
117 lines
3.4 KiB
Bash
#!/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
|
|
}
|