Files
matrix/now-playing/install.sh
T

37 lines
1.6 KiB
Bash
Raw Normal View History

#!/bin/bash
# Install or update the now-playing service (cinny #491) on LXC 151.
# Run with this repo's main branch pulled to /opt/matrix-config:
# bash /opt/matrix-config/now-playing/install.sh
# First install: put the Navidrome login in /etc/lotus-now-playing/env first
# (NAVIDROME_USER=lotus-nowplaying / NAVIDROME_PASSWORD=...), mode 640 root:lotus-now-playing.
# Optional /etc/lotus-now-playing/users.json maps Matrix IDs whose SSO link has no
# email to their SSO username, e.g. {"@bigmanjeff:matrix.lotusguild.org": "jeff"}.
# Neither file is kept in this (public) repo. Safe to re-run.
set -euo pipefail
REPO=/opt/matrix-config
CONF=/etc/lotus-now-playing
id lotus-now-playing >/dev/null 2>&1 ||
useradd --system --no-create-home --home-dir /var/lib/lotus-now-playing --shell /usr/sbin/nologin lotus-now-playing
install -d -m750 -o root -g lotus-now-playing "$CONF"
install -D -m644 "$REPO/now-playing/lotus_now_playing.py" /opt/lotus-now-playing/lotus_now_playing.py
if [ ! -f "$CONF/env" ]; then
echo "missing $CONF/env (NAVIDROME_USER / NAVIDROME_PASSWORD); create it and re-run" >&2
exit 1
fi
chown root:lotus-now-playing "$CONF/env"
chmod 640 "$CONF/env"
if [ -f "$CONF/users.json" ]; then
chown root:lotus-now-playing "$CONF/users.json"
chmod 640 "$CONF/users.json"
fi
install -m644 "$REPO/systemd/lotus-now-playing.service" /etc/systemd/system/lotus-now-playing.service
systemctl daemon-reload
systemctl enable lotus-now-playing >/dev/null
systemctl restart lotus-now-playing
sleep 2
systemctl --no-pager --lines=5 status lotus-now-playing
curl -fsS http://127.0.0.1:8072/healthz && echo " (healthy)"