diff --git a/asks/live-acceptance.sh b/asks/live-acceptance.sh index e47f567..f153b1b 100644 --- a/asks/live-acceptance.sh +++ b/asks/live-acceptance.sh @@ -13,7 +13,9 @@ # through which channel, with which proofs. set -eu -mc=${MESH_CONTROLLER:-mesh-controller} +# mesh-cli asks the controller; on the control node, from the operator's own account, a line is the +# controller's terminal (ADR 0272). `nox` is its interactive alias; a script says mesh-cli. +mc=${MESH_CLI:-mesh-cli} stop() { echo "NOT ACCEPTED: $*"; exit 1; } echo "1. Nothing open says the router's or Telegram's machine is not root-free (root-not-free, agent-root)." @@ -24,12 +26,20 @@ fi echo "2. The Telegram channel holds a working bot token and its updates arrive." tg=$($mc ask telegram telegram_status) || stop "the telegram module does not answer" -echo "$tg" | grep -q '"can_send": *true' || { echo "$tg"; stop "Telegram cannot send now (why_not above): give the bot token again, at this terminal: $mc secret accept telegram telegram-token, then push "; } +echo "$tg" | grep -q '"can_send": *true' || { echo "$tg"; stop "Telegram cannot send now (why_not above): give the bot token again at the controller's terminal (hq ADR 0259, the operator's steps), then push the control node"; } echo "3. One Telegram account is linked as the operator, and its hour has passed." ids=$($mc ask messenger messenger_identities) || stop "the router does not answer" echo "$ids" echo "$ids" | grep -q '"telegram"' || stop "no Telegram account is linked: send /start to the bot, then the code from the desk" +# The router answers approvals from a new link only an hour after it was made (ADR 0259 §7): said here, with the +# time, rather than seen as a rehearsal nobody's approval reaches. +from=$(echo "$ids" | tr -d '\n ' | grep -o '"kind":"telegram"[^}]*' | grep -o '"approve-from":"[^"]*"' | cut -d'"' -f4 | head -n 1) +[ -n "$from" ] || stop "the router's word on the Telegram account says no time it can approve from" +starts=$(date -d "$from" +%s 2>/dev/null) || stop "the time the Telegram account can approve from is not a time: $from" +if [ "$(date +%s)" -lt "$starts" ]; then + stop "the Telegram account was linked less than an hour ago — approvals start at $(date -d "$from" '+%H:%M') (local time); run this again then" +fi echo "4. The rehearsal: a question on your phone. Approve it there within 15 minutes." said=$($mc rehearse --for 15m) || stop "the rehearsal could not be asked"