Add hiera support for SMS Admin Number

This commit is contained in:
Keith 2016-05-26 16:12:00 +01:00
parent 811b865e39
commit 1bb6dc3750
4 changed files with 46 additions and 3 deletions

@ -1 +1 @@
Subproject commit eb52429dbf78778a4871169571a744bff44a6287
Subproject commit 9b1d26bba9b063193259033772a7b34eef349e3b

View file

@ -39,7 +39,7 @@ class rhizo_base {
#BTSs configuration
$bts1_ip_address = hiera('rhizo::bts1_ip_address')
$arfcn_A = hiera('rhizo::arfcn_A')
$arfcn_B = hiera('rhizo::arfcn_B')
$arfcn_B = hiera('rhizo::arfcn_B', false)
$bts2_ip_address = hiera('rhizo::bts2_ip_address', false)
$arfcn_C = hiera('rhizo::arfcn_C', false)
@ -101,6 +101,9 @@ class rhizo_base {
#Emergency number
$emergency_contact = hiera('rhizo::emergency_contact')
#Number to send low VOIP Balance alert
$admin_contact = hiera('rhizo::admin_contact','')
#Device Geo Info
$bsc_geo_lat = hiera('rhizo::bsc_geo_lat')
$bsc_geo_lon = hiera('rhizo::bsc_geo_lon')
@ -204,6 +207,12 @@ class rhizo_base {
mode => '0755',
}
file { '/var/rhizomatica/bin/check_account_balance.sh':
ensure => present,
content => template('rhizo_base/check_account_balance.sh.erb'),
require => Vcsrepo['/var/rhizomatica'],
mode => '0755',
}
file { '/var/rhizomatica/rccn/config_values.py':
ensure => present,

View file

@ -22,7 +22,7 @@ class rhizo_base::kiwi {
package {
['nodejs']:
ensure => '0.10.44-1nodesource1~precise1',
ensure => '0.10.45-1nodesource1~precise1',
require => Class['rhizo_base::apt'],
}

View 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