From b0d51f034444f3ff68893fcd3c7ce6af94fd3732 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 21 Aug 2026 21:13:16 +0000 Subject: [PATCH] Fix sms-inbound.sh persisting an unusable "" webhook URL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the "Public domain for the webhook" prompt was left blank (DNS not ready yet, or just missed), the installer built the Forward-to-URL as literal https:///sms/... and persisted that placeholder to settings.env as if it were real. "Update" mode never re-prompts for the domain (by design — it's meant to leave already-configured settings alone), so every later re-run silently re-served the same unusable placeholder, with nothing indicating anything was wrong. A DID provider (Anveo) correctly rejects it — it isn't a resolvable hostname. - Only build FORWARD_URL when a real domain was entered; leave it empty otherwise instead of substituting the placeholder. - Fresh-install summary and README now say plainly that setup isn't complete and how to finish it, instead of printing an empty/bogus URL. - Update-mode now detects a missing/placeholder domain and tells you to re-run with "Full reinstall" to be asked again, instead of reporting success with a broken URL. Verified with a direct test of _sms_write_readme() and the FORWARD_URL construction for both the blank- and real-domain cases. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01SpKTLpwAgZNooTacWeQLuc --- services/sms-inbound.sh | 67 ++++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 14 deletions(-) diff --git a/services/sms-inbound.sh b/services/sms-inbound.sh index f8447b4..1681d88 100644 --- a/services/sms-inbound.sh +++ b/services/sms-inbound.sh @@ -629,17 +629,11 @@ CBLOCK _sms_write_readme() { local _url="$1" _relay_domain="$2" - write_readme "$SMS_APP_DIR" << MD -# Inbound SMS → Sipnetic (via AMI) -Gets SMS sent to one of your PSTN DIDs delivered into Asterisk as a SIP -MESSAGE, landing in Sipnetic the same way internal texting already does — -not a push notification, a real message in the softphone. - -## The URL to paste into your DID provider - -In the provider portal, open the DID's SMS settings and paste this into the -"Forward to URL" field (on Anveo: Phone Numbers → the DID → SMS tab, tick + local _url_section + if [ -n "$_url" ]; then + _url_section="In the provider portal, open the DID's SMS settings and paste this into the +\"Forward to URL\" field (on Anveo: Phone Numbers → the DID → SMS tab, tick the checkbox, paste, press SAVE — RETURN discards): \`\`\` @@ -652,7 +646,21 @@ query parameters; with the message last, everything after it can be read back verbatim. Treat this URL like a password — anyone holding it can trigger a message -delivery into your Asterisk. +delivery into your Asterisk." + else + _url_section="**Not set up yet — no public domain was entered.** Re-run \`sudo ./setup.sh sms-inbound\` and choose \"Full reinstall\" once DNS for the webhook's domain points at this box; nothing here works until then." + fi + + write_readme "$SMS_APP_DIR" << MD +# Inbound SMS → Sipnetic (via AMI) + +Gets SMS sent to one of your PSTN DIDs delivered into Asterisk as a SIP +MESSAGE, landing in Sipnetic the same way internal texting already does — +not a push notification, a real message in the softphone. + +## The URL to paste into your DID provider + +${_url_section} ## How delivery is decided @@ -770,8 +778,24 @@ install_sms-inbound() { && log_success "Relay refreshed and restarted." \ || log_warning "Restart failed — check: journalctl -u sms-inbound -n 50" echo "" - log_success "Settings, Caddy and firewall rules were left untouched." - echo " Provider URL: ${SMS_FORWARD_URL}" + # A missing/placeholder domain here means an earlier run was + # left with no real webhook URL (RELAY_DOMAIN entered blank, + # or DNS wasn't ready yet) — "update" mode never re-prompts + # for the domain (by design, same as every other service's + # non-destructive update path), so silently repeating that + # broken URL forever, looking like nothing is wrong, is worse + # than saying so plainly. Confirmed live: this is exactly + # what a DID provider like Anveo rejects — "" + # isn't a resolvable hostname. + if [[ -z "${SMS_RELAY_DOMAIN:-}" || "${SMS_FORWARD_URL:-}" == *""* ]]; then + log_warning "No real webhook domain was ever set for this install — the stored" + log_warning "provider URL is a placeholder, not something a DID provider can use." + log_warning "Re-run 'sudo ./setup.sh sms-inbound' and choose \"2) Full reinstall\"" + log_warning "to be asked for the domain again (needs DNS pointed at this box first)." + else + log_success "Settings, Caddy and firewall rules were left untouched." + echo " Provider URL: ${SMS_FORWARD_URL}" + fi echo "" return 0 ;; @@ -898,7 +922,14 @@ install_sms-inbound() { ensure_ufw_enabled fi - local FORWARD_URL="https://${RELAY_DOMAIN:-}/sms/${RELAY_TOKEN}?from=\$[from]\$&to=\$[to]\$&message=\$[message]\$" + # Empty (not a "" placeholder) when no domain was entered — + # a placeholder here used to get persisted to settings.env and silently + # re-served as-is on every later "update" run (which never re-prompts + # for the domain, by design), looking like a valid webhook URL right up + # until a DID provider like Anveo rejected it as an unresolvable host. + # Confirmed live. + local FORWARD_URL="" + [ -n "$RELAY_DOMAIN" ] && FORWARD_URL="https://${RELAY_DOMAIN}/sms/${RELAY_TOKEN}?from=\$[from]\$&to=\$[to]\$&message=\$[message]\$" # ── Persist settings ────────────────────────────────────────────────────── # Single-quoted values: this file gets `source`d again on the next @@ -929,6 +960,14 @@ ENV # ── Summary ─────────────────────────────────────────────────────────────── echo "" + if [ -z "$FORWARD_URL" ]; then + log_warning "Inbound SMS relay is running, but nothing can reach it yet — no domain was entered." + log_warning "Point an A record at this box, then re-run 'sudo ./setup.sh sms-inbound' and" + log_warning "choose \"2) Full reinstall\" to be asked for the domain again and get a real" + log_warning "\"Forward to URL\" to paste into your DID provider." + echo "" + return 0 + fi log_success "Inbound SMS → Sipnetic configured." echo "" echo " 1. In your DID provider's portal, open the number's SMS settings and"