diff --git a/scripts/signal-relay.py b/scripts/signal-relay.py index 4f15f43..d1805fc 100755 --- a/scripts/signal-relay.py +++ b/scripts/signal-relay.py @@ -33,8 +33,12 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer # podman bridge subnet (10.89.0.0/16) only, keeping the unauthenticated # endpoint off the rest of the LAN. LISTEN_ADDR = ("192.168.0.143", 18093) -SIGNAL_CLI = "/usr/local/bin/signal-cli" -SIGNAL_ACCOUNT = "318311" +# The account is addressed by phone number: signal-cli 0.14.7's -a flag +# parses an all-digit value as a phone number and never falls back to the +# accounts.json name (the numeric name 318311 dies with "Invalid account +# (phone number)"). The number is a number, not a credential — the +# credential is the account state under ~/.local/share/signal-cli. +SIGNAL_ACCOUNT = "+12062476336" SIGNAL_TO = "+12062476336" # The relay is a safety net, not the rate limiter: Alertmanager already @@ -86,7 +90,8 @@ def send_signal(text): return False try: proc = subprocess.run( - [SIGNAL_CLI, "-a", SIGNAL_ACCOUNT, "-o", "json", "send", SIGNAL_TO, text], + [SIGNAL_CLI, "-a", SIGNAL_ACCOUNT, "-o", "json", "send", SIGNAL_TO, + "-m", text], capture_output=True, text=True, timeout=30, ) except subprocess.TimeoutExpired: diff --git a/serverAppConfigs-docs/Infrastructure/Alertmanager.md b/serverAppConfigs-docs/Infrastructure/Alertmanager.md index 97bf76c..6d37c25 100644 --- a/serverAppConfigs-docs/Infrastructure/Alertmanager.md +++ b/serverAppConfigs-docs/Infrastructure/Alertmanager.md @@ -28,7 +28,7 @@ The Signal relay is a host-side process, and the address it must bind is the one - POST `/alertmanager` — the Alertmanager webhook handler; formats the group and sends it. - GET `/health` — liveness for the deployer's health wait. - Dedupes per group for 15 minutes, so a stuck alert cannot out-repeat the 4 h `repeat_interval` during a relay hiccup. -- Sends through `/usr/local/bin/signal-cli -a 318311 send +12062476336` — Frank's existing account; the credential is the account state under `~/.local/share/signal-cli`, and the account/phone are numbers, not secrets. +- Sends through `/usr/local/bin/signal-cli -a +12062476336 -o json send +12062476336 -m ` — Frank's existing account (state dir `318311`); the credential is the account state under `~/.local/share/signal-cli`, and the account/phone are numbers, not secrets. ## Deployment @@ -43,6 +43,8 @@ The Signal relay is a host-side process, and the address it must bind is the one - The webhook URL and the relay's listen port are a **cross-file contract**: the relay moves ports and the webhook string does not move with it, and every alert is then dropped with no error anywhere. `tests/observability_quadlet.bats` pins both halves. - The container address is `alertmanager:9093`, never the published port: Prometheus is in a container and the port is loopback-only. - signal-cli account state is on the host, not in the container — a wiped `~/.local/share/signal-cli` silences delivery while every status page stays green. +- signal-cli 0.14.7's `-a` flag parses an all-digit value as a **phone number** and never falls back to the `accounts.json` name: the account's numeric name (`318311`) dies with `Invalid account (phone number)`, while `-a +12062476336` works. The message goes via `-m`, not a positional — a positional message is parsed as a second recipient (`Invalid phone number '…'`). +- A failed send is **not** marked in the dedupe map, so the next Alertmanager repeat retries it — but the relay returns 200 to the webhook regardless (a relay bug must not 500 Alertmanager), so a dead signal-cli shows up only in the relay's journal, not in Alertmanager's. ## See Also diff --git a/tests/observability_quadlet.bats b/tests/observability_quadlet.bats index af4c6d9..940f0a8 100755 --- a/tests/observability_quadlet.bats +++ b/tests/observability_quadlet.bats @@ -473,7 +473,7 @@ assert any('ALERTS' in e for e in exprs), exprs local handler="$REPO_ROOT/scripts/deploy-remote.sh" grep -q 'signal-cli' "$relay" grep -q 'SIGNAL_CLI = "/usr/local/bin/signal-cli"' "$relay" - grep -q 'SIGNAL_ACCOUNT = "318311"' "$relay" + grep -q 'SIGNAL_ACCOUNT = "+12062476336"' "$relay" grep -q 'LISTEN_ADDR = ("192.168.0.143", 18093)' "$relay" grep -q -- '--dport 18093 -s 127.0.0.1 -j ACCEPT' "$handler" grep -q -- '--dport 18093 -s 192.168.0.143 -j ACCEPT' "$handler"