33 lines
1.5 KiB
Bash
Executable File
33 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# One-time install of the yaris-obd systemd service on the Pi.
|
|
# Run this ON THE PI as the `yaris` user (needs sudo for the systemctl bits):
|
|
# cd /home/yaris/app/yaris-obd && bash deploy/install_service.sh
|
|
set -euo pipefail
|
|
|
|
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
SERVICE_FILE="$REPO_DIR/deploy/yaris-obd.service"
|
|
SERVICE_NAME="yaris-obd.service"
|
|
STATUS_SUDOERS_FILE="$REPO_DIR/deploy/yaris-status-actions.sudoers"
|
|
DASHCAM_SUDOERS_FILE="$REPO_DIR/deploy/yaris-dashcam.sudoers"
|
|
|
|
if [ ! -d "$REPO_DIR/venv" ]; then
|
|
echo "No venv found at $REPO_DIR/venv - creating one and installing requirements..."
|
|
python3 -m venv "$REPO_DIR/venv"
|
|
"$REPO_DIR/venv/bin/pip" install --upgrade pip
|
|
"$REPO_DIR/venv/bin/pip" install -r "$REPO_DIR/requirements.txt"
|
|
fi
|
|
|
|
sudo cp "$SERVICE_FILE" "/etc/systemd/system/$SERVICE_NAME"
|
|
sudo install -m 440 "$STATUS_SUDOERS_FILE" /etc/sudoers.d/yaris-status-actions
|
|
sudo visudo -cf /etc/sudoers.d/yaris-status-actions
|
|
# Passwordless sudo for the dashcam mount/umount/delete operations the app runs
|
|
# at runtime (modules/app_dash.py) as the unprivileged `yaris` user.
|
|
sudo install -m 440 "$DASHCAM_SUDOERS_FILE" /etc/sudoers.d/yaris-dashcam
|
|
sudo visudo -cf /etc/sudoers.d/yaris-dashcam
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable "$SERVICE_NAME"
|
|
sudo systemctl restart "$SERVICE_NAME"
|
|
|
|
echo "Done. Check status with: sudo systemctl status $SERVICE_NAME"
|
|
echo "Logs: tail -f $REPO_DIR/yaris-obd.log (or: sudo journalctl -u $SERVICE_NAME -f)"
|