Add hiera support for SMS Admin Number
This commit is contained in:
parent
811b865e39
commit
1bb6dc3750
4 changed files with 46 additions and 3 deletions
34
modules/rhizo_base/templates/check_account_balance.sh.erb
Normal file
34
modules/rhizo_base/templates/check_account_balance.sh.erb
Normal file
|
@ -0,0 +1,34 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
|
||||
MSISDN=( <%= @admin_contact %> )
|
||||
|
||||
if [ "${MSISDN[0]}" == "" ] ; then
|
||||
exit
|
||||
fi
|
||||
|
||||
BALANCE=`/var/rhizomatica/bin/get_account_balance.sh`
|
||||
OUT=`echo $BALANCE | awk '{if ($1 < 10) print $0}' | sed -e 's/\n//g'`
|
||||
|
||||
PORT=4242
|
||||
HOST=localhost
|
||||
PROMPT="OpenBSC>"
|
||||
|
||||
send_command() {
|
||||
(echo $* ; sleep 1 ) |
|
||||
telnet $HOST $PORT 2>&1 |
|
||||
sed '1,/'$PROMPT'/d;/'$PROMPT'/,$d'
|
||||
}
|
||||
|
||||
|
||||
if [ "$OUT" != "" ]; then
|
||||
# balance < 20 send SMS
|
||||
TEXT="El balance de la cuenta VOIP esta de bajo de los \$10. Balance Actual es: \$${BALANCE} USD"
|
||||
CLENGTH="${#TEXT}"
|
||||
|
||||
for msisdn in ${MSISDN[@]}; do
|
||||
message_body="subscriber extension $msisdn sms sender extension 10000 send $TEXT"
|
||||
send_command $message_body
|
||||
done
|
||||
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue