#!/usr/bin/env bash

# {{ ansible_managed }}

# This is a script that should be run on reboot. It will send a test SMS
# message to specified recipients to confirm that SMS gateway is working
# correctly.

PATH="/bin:/usr/bin:/usr/local/bin"

test_message="{{ smstools_test_message }}"
read -r -a test_recipients <<< "{{ smstools_test_recipients | join(' ') }}"

if [[ "${test_recipients[*]}" ]] ; then
    for recipient in "${test_recipients[@]}" ; do
        /usr/bin/sudo -u smsd /usr/local/bin/sendsms "${recipient}" "${test_message}" > /dev/null
    done
fi
