forked from ChelseaKR/olive-bark-logger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-pi.sh
More file actions
40 lines (33 loc) · 1.74 KB
/
Copy pathsetup-pi.sh
File metadata and controls
40 lines (33 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash
# One-shot setup for a Raspberry Pi (Debian/Raspberry Pi OS). Idempotent-ish.
# Installs PortAudio, creates a venv with the live extra, and installs the systemd unit.
set -euo pipefail
PREFIX="${PREFIX:-/opt/olive}"
DATA_DIR="${DATA_DIR:-/var/lib/olive}"
CONF_DIR="${CONF_DIR:-/etc/olive}"
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
echo "==> Installing system audio libraries (PortAudio)"
sudo apt-get update
sudo apt-get install -y python3-venv libportaudio2
echo "==> Creating ${PREFIX} and ${DATA_DIR}"
sudo mkdir -p "$PREFIX" "$DATA_DIR" "$CONF_DIR"
sudo python3 -m venv "$PREFIX/.venv"
sudo "$PREFIX/.venv/bin/pip" install --upgrade pip
sudo "$PREFIX/.venv/bin/pip" install "$REPO_DIR[live]"
echo "==> Installing default config (edit ${CONF_DIR}/config.json for your placement/tz)"
if [ ! -f "$CONF_DIR/config.json" ]; then
sudo cp "$REPO_DIR/config.sample.json" "$CONF_DIR/config.json"
sudo sed -i 's#"db_path": "olive.db"#"db_path": "/var/lib/olive/olive.db"#' "$CONF_DIR/config.json"
sudo sed -i 's#"health_path": "olive-health.json"#"health_path": "/var/lib/olive/olive-health.json"#' "$CONF_DIR/config.json"
fi
echo "==> Installing systemd unit"
sudo cp "$REPO_DIR/deploy/olive-monitor.service" /etc/systemd/system/
sudo systemctl daemon-reload
cat <<'EOF'
Done. Next steps:
1. Edit /etc/olive/config.json (set tz, placement_note, threshold).
2. Create the service user: sudo useradd -r -g audio olive && sudo chown -R olive /var/lib/olive
3. Start it: sudo systemctl enable --now olive-monitor
4. Watch logs: journalctl -u olive-monitor -f
5. Generate a report: /opt/olive/.venv/bin/olive-report --config /etc/olive/config.json --out report.html
EOF