This commit is contained in:
Jean-Michel Tremblay 2026-07-06 21:21:17 -04:00
parent cbda10c62c
commit 8ae4b40263
3 changed files with 16 additions and 9 deletions

View file

@ -12,8 +12,10 @@ MEDIAPI_PASSWORD=changeme
MEDIAPI_MEDIA_ROOTS=/localmedia MEDIAPI_MEDIA_ROOTS=/localmedia
MEDIAPI_PORT=8080 MEDIAPI_PORT=8080
# --- System: systemd services run as this Linux user --- # --- System: the Linux user the systemd services run as ---
MEDIAPI_USER=pi # Auto-detected from whoever runs install.sh (id -un) when left unset, so you
# normally don't need this. Uncomment only to force a specific user.
#MEDIAPI_USER=pi
# --- WiFi access point (re-applied by install.sh) --- # --- WiFi access point (re-applied by install.sh) ---
MEDIAPI_WIFI_COUNTRY=US MEDIAPI_WIFI_COUNTRY=US

View file

@ -134,19 +134,16 @@ screen (`--hwdec=auto-safe` falls back to software if the HW decoder is busy).
sudo apt update sudo apt update
sudo apt install -y mpv sudo apt install -y mpv
# mpv needs access to the GPU/DRM devices to render to HDMI
# (use the MEDIAPI_USER from your .env)
sudo usermod -aG video,render "$USER"
# log out/in (or reboot) for the new group membership to take effect
# install uv (Python package/venv manager) if not already present # install uv (Python package/venv manager) if not already present
curl -LsSf https://astral.sh/uv/install.sh | sh # installs to ~/.local/bin/uv curl -LsSf https://astral.sh/uv/install.sh | sh # installs to ~/.local/bin/uv
# create your .env (see Configuration above) # create your .env (see Configuration above)
cp .env.example .env && $EDITOR .env cp .env.example .env && $EDITOR .env
# deploy the currently-checked-out ref: syncs deps, configures the AP, # deploy the currently-checked-out ref: syncs deps, adds the service user to
# installs+starts the services # the video+render groups (GPU/DRM access for HDMI), configures the AP,
# installs+starts the services. Run as your normal user -- NOT with sudo, or
# the services get rendered to run as root.
./install.sh ./install.sh
# verify # verify

View file

@ -116,6 +116,14 @@ deploy_current() {
chmod 600 instance/secret_key chmod 600 instance/secret_key
fi fi
# The mpv service runs as MEDIAPI_USER and needs the video+render groups to
# reach the GPU/DRM devices for HDMI output. Idempotent; systemd picks up the
# new membership when it (re)starts the service below, so no logout needed.
if ! id -nG "${MEDIAPI_USER}" | tr ' ' '\n' | grep -qx render; then
echo "==> Adding '${MEDIAPI_USER}' to video,render groups ..."
sudo usermod -aG video,render "${MEDIAPI_USER}"
fi
echo "==> Applying WiFi country + AP config ..." echo "==> Applying WiFi country + AP config ..."
sudo raspi-config nonint do_wifi_country "${MEDIAPI_WIFI_COUNTRY}" sudo raspi-config nonint do_wifi_country "${MEDIAPI_WIFI_COUNTRY}"
if nmcli -g NAME con show | grep -qx "${MEDIAPI_AP_CONN_NAME}"; then if nmcli -g NAME con show | grep -qx "${MEDIAPI_AP_CONN_NAME}"; then