#!/usr/bin/env bash # # Install (or upgrade) the MethdAI Receptionist systemd unit on the robot. # Run on the robot itself (e.g. via ssh pollen@reachy-mini.local). # # Idempotent: re-running picks up edits to reachy-receptionist.service and # restarts the live service. # # After install, useful commands: # systemctl status reachy-receptionist # journalctl -u reachy-receptionist -f # sudo systemctl restart reachy-receptionist # sudo systemctl disable --now reachy-receptionist # set -euo pipefail UNIT_NAME="reachy-receptionist.service" HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SRC="$HERE/$UNIT_NAME" DST="/etc/systemd/system/$UNIT_NAME" if [[ ! -f "$SRC" ]]; then echo "✗ Unit file not found at $SRC" >&2 exit 1 fi # Re-elevate via `sudo bash ` so we don't depend on the script # having the executable bit set (git-from-Windows often drops it, and we # want `bash deploy/install_systemd.sh` to Just Work). if [[ "$(id -u)" -ne 0 ]]; then echo "↻ Re-running with sudo..." exec sudo --preserve-env=HOME bash "$HERE/$(basename "${BASH_SOURCE[0]}")" "$@" fi # Sanity check the runtime paths referenced by the unit file. Catching this # now beats debugging a cryptic "ExecStart failed" later. PYTHON_BIN="/venvs/apps_venv/bin/python" PROJECT_DIR="/home/pollen/reachy_mini_receptionist" if [[ ! -x "$PYTHON_BIN" ]]; then echo "✗ Python interpreter not found at $PYTHON_BIN" >&2 echo " Fix: install / locate the apps_venv before re-running." >&2 exit 2 fi if [[ ! -d "$PROJECT_DIR" ]]; then echo "✗ Project not found at $PROJECT_DIR" >&2 exit 3 fi echo "→ Installing $UNIT_NAME → $DST" cp "$SRC" "$DST" chmod 644 "$DST" echo "→ Reloading systemd" systemctl daemon-reload echo "→ Enabling on boot" systemctl enable "$UNIT_NAME" echo "→ Restarting service" systemctl restart "$UNIT_NAME" # Brief wait so the status snapshot below shows a meaningful state sleep 2 echo echo "✓ Installed. Current status:" echo "─────────────────────────────────────────" systemctl --no-pager --lines=10 status "$UNIT_NAME" || true echo "─────────────────────────────────────────" echo echo "Follow logs: journalctl -u $UNIT_NAME -f" echo "Manual restart: sudo systemctl restart $UNIT_NAME" echo "Stop: sudo systemctl stop $UNIT_NAME" echo "Disable: sudo systemctl disable --now $UNIT_NAME"