#!/usr/bin/env bash # Install the AvianVisitors e-ink frame (display side) on a Raspberry Pi. # Enables SPI + I2C, installs deps, makes a venv, installs the systemd timer. # # Default mode mirrors a local bird mic (set the image source in the config). # Pass --bird-weather --zip to instead run the frame standalone from # BirdWeather data for that ZIP: it renders on the Pi and pulls cutouts from the # repo's raw GitHub URLs, so no mic and no local illustration folder are needed. set -euo pipefail cd "$(dirname "$0")" FRAME="$(pwd)" BIRD_WEATHER=0 ZIP="" while [ $# -gt 0 ]; do case "$1" in --bird-weather) BIRD_WEATHER=1 ;; --zip) ZIP="${2:-}"; shift ;; --zip=*) ZIP="${1#*=}" ;; *) echo "unknown argument: $1" >&2; exit 1 ;; esac shift done if [ "$BIRD_WEATHER" = 1 ] && [ -z "$ZIP" ]; then echo "--bird-weather needs --zip , e.g. install.sh --bird-weather --zip 94107" >&2 exit 1 fi CONFIG_TXT=/boot/firmware/config.txt [ -f "$CONFIG_TXT" ] || CONFIG_TXT=/boot/config.txt echo "1/5 Enabling SPI + I2C (Inky needs both; SPI with no chip-select)..." sudo raspi-config nonint do_spi 0 sudo raspi-config nonint do_i2c 0 grep -q "^dtoverlay=spi0-0cs" "$CONFIG_TXT" || echo "dtoverlay=spi0-0cs" | sudo tee -a "$CONFIG_TXT" >/dev/null echo "2/5 Installing system packages (build tools to compile spidev, libatlas3-base for numpy)..." sudo apt-get update -qq sudo apt-get install -y python3-venv python3-dev build-essential libatlas3-base echo "3/5 Creating venv and installing Python deps..." python3 -m venv .venv .venv/bin/pip install -q --upgrade pip .venv/bin/pip install -q -r requirements-frame.txt if [ "$BIRD_WEATHER" = 1 ]; then echo " BirdWeather mode: installing Playwright + Chromium for on-Pi rendering (a few minutes)..." .venv/bin/pip install -q playwright sudo .venv/bin/playwright install-deps chromium .venv/bin/playwright install chromium fi echo "4/5 Setting up config..." mkdir -p "$HOME/.birdframe" [ -f "$HOME/.birdframe/config.toml" ] || cp config.example.toml "$HOME/.birdframe/config.toml" echo "5/5 Installing systemd service + timer..." if [ "$BIRD_WEATHER" = 1 ]; then PY="$FRAME/.venv/bin/python" PNG="$HOME/.birdframe/frame.png" sudo tee /etc/systemd/system/birdframe.service >/dev/null </dev/null else sed "s|/home/monalisa/AvianVisitors/frame|$FRAME|g; s|/home/monalisa|$HOME|g; s|User=monalisa|User=$USER|" \ systemd/birdframe.service | sudo tee /etc/systemd/system/birdframe.service >/dev/null sudo cp systemd/birdframe.timer /etc/systemd/system/birdframe.timer fi sudo systemctl daemon-reload sudo systemctl enable --now birdframe.timer # --now starts it immediately, not only on the next boot if [ "$BIRD_WEATHER" = 1 ]; then cat <