SMS server setup

SMS Server Setup

The SMS server is managed by SMSTools3, and is installed on the Messaging server in the AWS Virtual Private Cloud. A second installation is present on the training (Sidecar) server.

Configuration file

The contents of smsd.conf on the live server are as follows (IP addresss removed)

  1. New Server smsd.conf
 devices = SOV*4009-4024
 
 logfile  = /var/log/smstools/smsd.log
 loglevel = 5
 smart_logging = yes
 
 stats    = /var/spool/sms/stats
 outgoing = /var/spool/sms/outgoing
 checked  = /var/spool/sms/checked
 incoming = /var/spool/sms/incoming
 infofile = /var/run/smstools/smsd.working
 pidfile  = /var/run/smstools/smsd.pid
 failed   = /var/spool/sms/failed
 sent     = /var/spool/sms/sent
 
 errorsleeptime = 3
 # eventhandler for incoming messages
 eventhandler = /home/smsd/sms_in.sh
 # regular run to send new messages with msgid of 0
 regular_run = /home/smsd/sms_rr.sh
 regular_run_interval = 300
 user = smsd
 group = dialout
 
 [queues]
 MAIN = /var/spool/sms/queues/MAIN
 OTHER = /var/spool/sms/queues/OTHER
 HALO = /var/spool/sms/queues/HALO
 SOV4009 = /var/spool/sms/queues/SOV4009
 SOV4010 = /var/spool/sms/queues/SOV4010
 SOV4011 = /var/spool/sms/queues/SOV4011
 SOV4012 = /var/spool/sms/queues/SOV4012
 SOV4013 = /var/spool/sms/queues/SOV4013
 SOV4014 = /var/spool/sms/queues/SOV4014
 SOV4015 = /var/spool/sms/queues/SOV4015
 SOV4016 = /var/spool/sms/queues/SOV4016
 SOV4017 = /var/spool/sms/queues/SOV4017
 SOV4018 = /var/spool/sms/queues/SOV4018
 SOV4019 = /var/spool/sms/queues/SOV4019
 SOV4020 = /var/spool/sms/queues/SOV4020
 SOV4021 = /var/spool/sms/queues/SOV4021
 SOV4022 = /var/spool/sms/queues/SOV4022
 SOV4023 = /var/spool/sms/queues/SOV4023
 SOV4024 = /var/spool/sms/queues/SOV4024
 
 [providers]
 # telkomsel
 MAIN = 62811, 62812, 62813, 62821, 62822, 62823, 62852, 62853
 # non-telkomsel
 OTHER = 628
 # other (primarily interntational - could be expensive so use postpaid)
 HALO = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
 # short numbers - admin.
 SOV4017 = s
 
 [default]
 regular_run_interval = 300
 queues = modemname, MAIN, OTHER
 socket_connection_retries = -1
 socket_connection_errorsleeptime = 20
 socket_connection_alarm_after = 10
 
 [SOV4009]
 device = @ipaddress:4009
 incoming = yes
 regular_run =          /var/spool/sms/regular_run/SOV4009.sh
 regular_run_post_run = /var/spool/sms/regular_run/SOV4009.sh
 regular_run_cmdfile =  /var/spool/sms/regular_run/SOV4009.cmdfile
 regular_run_statfile = /var/spool/sms/regular_run/SOV4009.statfile
 
 [SOV4010]
 device = @ipaddress:4010
 incoming = yes
 regular_run =          /var/spool/sms/regular_run/SOV4010.sh
 regular_run_post_run = /var/spool/sms/regular_run/SOV4010.sh
 regular_run_cmdfile =  /var/spool/sms/regular_run/SOV4010.cmdfile
 regular_run_statfile = /var/spool/sms/regular_run/SOV4010.statfile
 
 [SOV4011]
 device = @ipaddress:4011
 incoming = yes
 regular_run =          /var/spool/sms/regular_run/SOV4011.sh
 regular_run_post_run = /var/spool/sms/regular_run/SOV4011.sh
 regular_run_cmdfile =  /var/spool/sms/regular_run/SOV4011.cmdfile
 regular_run_statfile = /var/spool/sms/regular_run/SOV4011.statfile
 
 [SOV4012]
 device = @ipaddress:4012
 incoming = yes
 regular_run =          /var/spool/sms/regular_run/SOV4012.sh
 regular_run_post_run = /var/spool/sms/regular_run/SOV4012.sh
 regular_run_cmdfile =  /var/spool/sms/regular_run/SOV4012.cmdfile
 regular_run_statfile = /var/spool/sms/regular_run/SOV4012.statfile
 
 [SOV4013]
 device = @ipaddress:4013
 incoming = yes
 regular_run =          /var/spool/sms/regular_run/SOV4013.sh
 regular_run_post_run = /var/spool/sms/regular_run/SOV4013.sh
 regular_run_cmdfile =  /var/spool/sms/regular_run/SOV4013.cmdfile
 regular_run_statfile = /var/spool/sms/regular_run/SOV4013.statfile
 
 [SOV4014]
 device = @ipaddress:4014
 incoming = yes
 regular_run =          /var/spool/sms/regular_run/SOV4014.sh
 regular_run_post_run = /var/spool/sms/regular_run/SOV4014.sh
 regular_run_cmdfile =  /var/spool/sms/regular_run/SOV4014.cmdfile
 regular_run_statfile = /var/spool/sms/regular_run/SOV4014.statfile
 
 [SOV4015]
 device = @ipaddress:4015
 incoming = yes
 regular_run =          /var/spool/sms/regular_run/SOV4015.sh
 regular_run_post_run = /var/spool/sms/regular_run/SOV4015.sh
 regular_run_cmdfile =  /var/spool/sms/regular_run/SOV4015.cmdfile
 regular_run_statfile = /var/spool/sms/regular_run/SOV4015.statfile
 
 [SOV4016]
 device = @ipaddress:4016
 incoming = yes
 regular_run =          /var/spool/sms/regular_run/SOV4016.sh
 regular_run_post_run = /var/spool/sms/regular_run/SOV4016.sh
 regular_run_cmdfile =  /var/spool/sms/regular_run/SOV4016.cmdfile
 regular_run_statfile = /var/spool/sms/regular_run/SOV4016.statfile
 
 # main incoming modem
 [SOV4017]
 device = @ipaddress:4017
 incoming = high
 queues = SOV4017, HALO
 regular_run =          /var/spool/sms/regular_run/SOV4017.sh
 regular_run_post_run = /var/spool/sms/regular_run/SOV4017.sh
 regular_run_cmdfile = /var/spool/sms/regular_run/SOV4017.cmdfile
 regular_run_statfile = /var/spool/sms/regular_run/SOV4017.statfile
 
 [SOV4018]
 device = @ipaddress:4018
 incoming = yes
 regular_run =          /var/spool/sms/regular_run/SOV4018.sh
 regular_run_post_run = /var/spool/sms/regular_run/SOV4018.sh
 regular_run_cmdfile =  /var/spool/sms/regular_run/SOV4018.cmdfile
 regular_run_statfile = /var/spool/sms/regular_run/SOV4018.statfile
 
 [SOV4019]
 device = @ipaddress:4019
 incoming = yes
 regular_run =          /var/spool/sms/regular_run/SOV4019.sh
 regular_run_post_run = /var/spool/sms/regular_run/SOV4019.sh
 regular_run_cmdfile =  /var/spool/sms/regular_run/SOV4019.cmdfile
 regular_run_statfile = /var/spool/sms/regular_run/SOV4019.statfile
 
 [SOV4020]
 device = @ipaddress:4020
 incoming = yes
 regular_run =          /var/spool/sms/regular_run/SOV4020.sh
 regular_run_post_run = /var/spool/sms/regular_run/SOV4020.sh
 regular_run_cmdfile =  /var/spool/sms/regular_run/SOV4020.cmdfile
 regular_run_statfile = /var/spool/sms/regular_run/SOV4020.statfile
 
 [SOV4021]
 device = @ipaddress:4021
 incoming = yes
 regular_run =          /var/spool/sms/regular_run/SOV4021.sh
 regular_run_post_run = /var/spool/sms/regular_run/SOV4021.sh
 regular_run_cmdfile =  /var/spool/sms/regular_run/SOV4021.cmdfile
 regular_run_statfile = /var/spool/sms/regular_run/SOV4021.statfile
 
 [SOV4022]
 device = @ipaddress:4022
 incoming = yes
 regular_run =          /var/spool/sms/regular_run/SOV4022.sh
 regular_run_post_run = /var/spool/sms/regular_run/SOV4022.sh
 regular_run_cmdfile =  /var/spool/sms/regular_run/SOV4022.cmdfile
 regular_run_statfile = /var/spool/sms/regular_run/SOV4022.statfile
 
 [SOV4023]
 device = @ipaddress:4023
 incoming = yes
 regular_run =          /var/spool/sms/regular_run/SOV4023.sh
 regular_run_post_run = /var/spool/sms/regular_run/SOV4023.sh
 regular_run_cmdfile =  /var/spool/sms/regular_run/SOV4023.cmdfile
 regular_run_statfile = /var/spool/sms/regular_run/SOV4023.statfile
 
 [SOV4024]
 device = @ipaddress:4024
 incoming = yes
 regular_run =          /var/spool/sms/regular_run/SOV4024.sh
 regular_run_post_run = /var/spool/sms/regular_run/SOV4024.sh
 regular_run_cmdfile =  /var/spool/sms/regular_run/SOV4024.cmdfile
 regular_run_statfile = /var/spool/sms/regular_run/SOV4024.statfile
 

Event handler

This receives and processes incoming SMS messages. Replaced elements include username, ip address and database:

 #!/bin/bash
 if [ "$1" != 'RECEIVED' ]; then
         exit 0;  
 fi
 MSGID=$$`date +%s`
 MSG=`cat $2 | sed "s/'//g"`
 DBSERVER="ipaddress"
 psql -q -t -h $DBSERVER -U username -v VERBOSITY=terse database << EOF
 select sms.sms_parse('$MSG','$1','$MSGID');
 EOF
 
 psql \
     -h $DBSERVER -U username \
     -qtAc "select phone, message, case when priority then 'T' else 'F' end, coalesce(modem,'MAIN') from sms.outbox where msgid = $MSGID"\
     --field-separator '|' \
     database| while IFS='|' read -ra Record ; do
 
     NUM=${Record[0]}
     MSG1=${Record[1]}
     if [ "${Record[2]}" == 'T' ]; then
       PRIORITY="\nPriority: High";
     else
       PRIORITY="";
     fi
     QUEUE=${Record[3]}
     TMPFILE=`mktemp /var/spool/sms/outgoing/sms.XXXXX` || exit 1
     echo -e "To: ${NUM}${PRIORITY}\nQueue: ${QUEUE}\n\n$MSG1" > $TMPFILE
 done