Add setup_final.sh using host networking and disabled pings
This commit is contained in:
117
setup_final.sh
Executable file
117
setup_final.sh
Executable file
@@ -0,0 +1,117 @@
|
||||
#!/bin/bash
|
||||
|
||||
# FINAL ATTEMPT Script
|
||||
# Uses Mautrix image but switches to Host Networking to bypass Docker NAT issues.
|
||||
# Disables Pings.
|
||||
# Uses bbctl for tokens.
|
||||
|
||||
BRIDGE_SERVICE="telegram"
|
||||
DATA_DIR="data/$BRIDGE_SERVICE"
|
||||
CONFIG_FILE="$DATA_DIR/config.yaml"
|
||||
REG_FILE="$DATA_DIR/registration.yaml"
|
||||
|
||||
# ... (Token extraction logic as before) ...
|
||||
# We'll skip the boilerplate for brevity in this thought process,
|
||||
# but I will write the full script to the file.
|
||||
|
||||
if command -v bbctl &> /dev/null; then
|
||||
echo "Found 'bbctl'. Fetching registration..."
|
||||
BBCTL_OUT=$(bbctl register "sh-$BRIDGE_SERVICE" 2>&1)
|
||||
if [ $? -eq 0 ]; then
|
||||
YAML_CONTENT=$(echo "$BBCTL_OUT" | sed -n '/^id:/,$p')
|
||||
echo "$YAML_CONTENT" > "$REG_FILE"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Parse tokens
|
||||
get_yaml_val() { grep "^$1:" "$REG_FILE" | sed 's/^[^:]*: *//' | tr -d '\r'; }
|
||||
REG_ID=$(get_yaml_val "id")
|
||||
AS_TOKEN=$(get_yaml_val "as_token")
|
||||
HS_TOKEN=$(get_yaml_val "hs_token")
|
||||
BOT_USERNAME=$(get_yaml_val "sender_localpart")
|
||||
|
||||
# Ask API ID/Hash only if not present or empty
|
||||
if [ -z "$API_ID" ]; then
|
||||
read -p "Telegram API ID: " API_ID
|
||||
read -p "Telegram API Hash: " API_HASH
|
||||
fi
|
||||
|
||||
# Config with Ping Disabled and Null Address
|
||||
cat <<EOF > "$CONFIG_FILE"
|
||||
homeserver:
|
||||
address: https://matrix.beeper.com/_hungryserv/inswe
|
||||
domain: beeper.local
|
||||
verify_ssl: true
|
||||
software: hungry
|
||||
http_retry_count: 4
|
||||
async_media: true
|
||||
websocket: true
|
||||
ping_interval_seconds: -1
|
||||
|
||||
appservice:
|
||||
address: null
|
||||
id: $REG_ID
|
||||
bot_username: $BOT_USERNAME
|
||||
as_token: $AS_TOKEN
|
||||
hs_token: $HS_TOKEN
|
||||
database: sqlite:////data/bridge.db
|
||||
async_transactions: true
|
||||
|
||||
bridge:
|
||||
username_template: "${BRIDGE_SERVICE}_{userid}"
|
||||
displayname_template: "{displayname} ($BRIDGE_SERVICE)"
|
||||
permissions:
|
||||
"*": relay
|
||||
"beeper.local": user
|
||||
"beeper.com": user
|
||||
"@inswe:beeper.com": admin
|
||||
relay:
|
||||
enabled: true
|
||||
admin_only: false
|
||||
|
||||
logging:
|
||||
version: 1
|
||||
formatters:
|
||||
colored:
|
||||
format: "[%(asctime)s] [%(levelname)s@%(name)s] %(message)s"
|
||||
datefmt: "%b %d %H:%M:%S"
|
||||
handlers:
|
||||
console:
|
||||
class: logging.StreamHandler
|
||||
formatter: colored
|
||||
stream: ext://sys.stdout
|
||||
root:
|
||||
level: INFO
|
||||
handlers: [console]
|
||||
|
||||
telegram:
|
||||
api_id: $API_ID
|
||||
api_hash: $API_HASH
|
||||
device_info:
|
||||
device_model: "Beeper Bridge"
|
||||
system_version: "Docker"
|
||||
app_version: "0.1"
|
||||
EOF
|
||||
|
||||
# Docker Compose with Host Network
|
||||
cat <<EOF > docker-compose.yml
|
||||
services:
|
||||
telegram:
|
||||
container_name: beeper-telegram
|
||||
image: dock.mau.dev/mautrix/telegram:latest
|
||||
restart: unless-stopped
|
||||
network_mode: "host"
|
||||
volumes:
|
||||
- ./data/telegram:/data
|
||||
environment:
|
||||
- MAUTRIX_TELEGRAM_HOMESERVER_WEBSOCKET=true
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
EOF
|
||||
|
||||
echo "Starting with Host Network..."
|
||||
docker compose up -d --force-recreate telegram
|
||||
docker compose logs -f telegram
|
||||
Reference in New Issue
Block a user