Files
beeper-bridge-docker/configure_beeper.sh
2025-12-06 02:58:16 +00:00

92 lines
2.9 KiB
Bash

#!/bin/bash
echo "=== Beeper Bridge Configuration Helper ==="
echo "This script sets the Beeper Homeserver details in your bridge configs."
echo "Run this on the REMOTE server."
cat << 'PYTHON_SCRIPT' > apply_beeper_config.py
import sys
import os
try:
from ruamel.yaml import YAML
except ImportError:
import subprocess
subprocess.check_call([sys.executable, "-m", "pip", "install", "ruamel.yaml"])
from ruamel.yaml import YAML
yaml = YAML()
yaml.preserve_quotes = True
services = ["whatsapp", "telegram", "signal", "googlechat"]
base_dir = "data"
# Beeper Standard Config
HS_ADDRESS = "https://matrix.beeper.com"
HS_DOMAIN = "beeper.com"
for service in services:
config_path = os.path.join(base_dir, service, "config.yaml")
if not os.path.exists(config_path):
print(f"[{service}] Config missing. Skipping.")
continue
print(f"[{service}] Updating homeserver config...")
try:
with open(config_path, 'r') as f:
data = yaml.load(f)
changed = False
# Ensure homeserver section exists
if 'homeserver' not in data:
data['homeserver'] = {}
if data['homeserver'].get('address') != HS_ADDRESS:
data['homeserver']['address'] = HS_ADDRESS
changed = True
if data['homeserver'].get('domain') != HS_DOMAIN:
data['homeserver']['domain'] = HS_DOMAIN
changed = True
# Fix Appservice listening port/address if needed (Standard Docker internal)
# The bridge listens on 0.0.0.0:29317 (etc) internally usually, but
# let's just ensure 'address' in 'appservice' is 0.0.0.0 so it accepts docker traffic?
# Actually, let's not touch appservice.address unless requested, default is usually localhost or ::1 which might break in docker.
# Docker images usually default to 0.0.0.0.
if changed:
with open(config_path, 'w') as f:
yaml.dump(data, f)
print(f"[{service}] Updated homeserver to {HS_DOMAIN}.")
else:
print(f"[{service}] Config already correct.")
except Exception as e:
print(f"[{service}] Error: {e}")
PYTHON_SCRIPT
echo "[*] Applying configuration..."
docker run --rm \
-v "$(pwd):/work" \
-w /work \
python:3.11-slim \
sh -c "pip install ruamel.yaml && python apply_beeper_config.py"
rm apply_beeper_config.py
echo ""
echo "=== IMPORTANT NEXT STEPS ==="
echo "1. REGISTRATION FILES:"
echo " You must generate 'registration.yaml' for each bridge using 'bbctl' on your local machine."
echo " Example: 'bbctl register googlechat'"
echo " Then upload the resulting 'registration.yaml' to 'data/googlechat/registration.yaml' on this server."
echo ""
echo " If you see 'as_token was not accepted' in logs, your registration.yaml is wrong or mismatching."
echo ""
echo "2. RESTART:"
echo " After uploading the registration files, run: docker compose restart"