| 12345678910111213141516171819202122232425 |
- #!/bin/bash
- : ${SMS_API:=https://room-api.sea.zi3.fi}
- : ${SMS_TOKEN:=foobar}
- if [[ -z "$SMS_API" ]]; then
- echo "booking_sms: SMS_API not set" 1>&2
- exit 0
- fi
- # Read the full email from stdin and extract the first 6-digit Extranet code.
- code=$(grep -oP 'Extranet code: \K[0-9]{6}' | head -1)
- if [[ -z "$code" ]]; then
- echo "booking_sms: no Extranet code found in message" >&2
- exit 0 # exit 0 so Sieve doesn't treat it as a filter failure
- fi
- # Upload
- echo curl -fsS \
- -X POST \
- -H "Content-Type: application/json" \
- -H "X-SMS-Secret: ${SMS_TOKEN}" \
- -d "{\"code\": \"${code}\"}" \
- "${SMS_API%/}/sms/code"
- # Always clean for Sieve
- exit 0
|