From 45c2a5c04ecdcbf3a305ba5f2164a7a4770dff85 Mon Sep 17 00:00:00 2001 From: Gemini Bot Date: Sat, 6 Dec 2025 18:37:33 +0000 Subject: [PATCH] Fix YAML parsing by using grep/sed instead of python --- setup_beeper_bridge.sh | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/setup_beeper_bridge.sh b/setup_beeper_bridge.sh index 92c33de..cfd2c7f 100755 --- a/setup_beeper_bridge.sh +++ b/setup_beeper_bridge.sh @@ -49,27 +49,22 @@ if command -v bbctl &> /dev/null; then echo "Successfully saved registration to $REG_FILE" # Now we need to parse values from this file to populate config variables - # We use python one-liner to extract vars + # We use grep/sed to extract vars to avoid python dependencies echo "Extracting tokens..." - eval $(docker run --rm -v "$(pwd)/$REG_FILE:/reg.yaml" python:3.11-slim python -c " -import yaml # PyYAML is standard in some images, but if not we might need manual parsing or install -try: - import yaml -except ImportError: - # Fallback: simple line parsing if yaml module missing in minimal image (though python:3.11-slim usually needs pip install) - # Let's just do manual parsing to be safe and fast without network - d = {} - with open('/reg.yaml') as f: - for line in f: - if ':' in line: - k,v = line.split(':', 1) - d[k.strip()] = v.strip() - print(f'REG_ID={d.get(\"id\", \"\")}') - print(f'AS_TOKEN={d.get(\"as_token\", \"\")}') - print(f'HS_TOKEN={d.get(\"hs_token\", \"\")}') - print(f'BOT_USERNAME={d.get(\"sender_localpart\", \"\")}') -") + # Helper function to extract value by key + 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") + + if [ -n "$REG_ID" ]; then + echo " -> ID: $REG_ID" + fi else echo "Could not parse YAML from bbctl output. Falling back to manual input." fi