#!/bin/bash # One-time install of the Discord presence service (lotus_presence.py). # Run on LXC 151 with this repo's main branch pulled to /opt/matrix-config: # bash /opt/matrix-config/discord-bridge/install-presence.sh # Generates its own appservice credentials on this machine and never prints them. # Does NOT restart Synapse: until you do, Discord works but Matrix answers 401. # Safe to re-run: existing credentials are kept. set -euo pipefail REPO=/opt/matrix-config REG=/etc/matrix-synapse/discord-presence-registration.yaml ENV_FILE=/etc/lotus-presence/env HS=/etc/matrix-synapse/homeserver.yaml install -d -m750 -o root -g mautrix-discord /etc/lotus-presence install -D -m644 "$REPO/discord-bridge/lotus_presence.py" /opt/lotus-presence/lotus_presence.py if [ ! -f "$ENV_FILE" ]; then AS_TOKEN="$(openssl rand -hex 32)" HS_TOKEN="$(openssl rand -hex 32)" (umask 027; printf 'AS_TOKEN=%s\n' "$AS_TOKEN" > "$ENV_FILE") chown root:mautrix-discord "$ENV_FILE" (umask 027; cat > "$REG" <