SMS server setup: Perbedaan revisi
Baris 5: | Baris 5: | ||
The contents of smsd.conf on the live server are as follows (IP addresss removed) | The contents of smsd.conf on the live server are as follows (IP addresss removed) | ||
− | + | # New Server smsd.conf | |
devices = SOV*4009-4024 | devices = SOV*4009-4024 | ||
Baris 70: | Baris 70: | ||
[SOV4009] | [SOV4009] | ||
− | device = @ | + | device = @ipaddress:4009 |
incoming = yes | incoming = yes | ||
regular_run = /var/spool/sms/regular_run/SOV4009.sh | regular_run = /var/spool/sms/regular_run/SOV4009.sh | ||
Baris 78: | Baris 78: | ||
[SOV4010] | [SOV4010] | ||
− | device = @ | + | device = @ipaddress:4010 |
incoming = yes | incoming = yes | ||
regular_run = /var/spool/sms/regular_run/SOV4010.sh | regular_run = /var/spool/sms/regular_run/SOV4010.sh | ||
Baris 86: | Baris 86: | ||
[SOV4011] | [SOV4011] | ||
− | device = @ | + | device = @ipaddress:4011 |
incoming = yes | incoming = yes | ||
regular_run = /var/spool/sms/regular_run/SOV4011.sh | regular_run = /var/spool/sms/regular_run/SOV4011.sh | ||
Baris 94: | Baris 94: | ||
[SOV4012] | [SOV4012] | ||
− | device = @ | + | device = @ipaddress:4012 |
incoming = yes | incoming = yes | ||
regular_run = /var/spool/sms/regular_run/SOV4012.sh | regular_run = /var/spool/sms/regular_run/SOV4012.sh | ||
Baris 102: | Baris 102: | ||
[SOV4013] | [SOV4013] | ||
− | device = @ | + | device = @ipaddress:4013 |
incoming = yes | incoming = yes | ||
regular_run = /var/spool/sms/regular_run/SOV4013.sh | regular_run = /var/spool/sms/regular_run/SOV4013.sh | ||
Baris 110: | Baris 110: | ||
[SOV4014] | [SOV4014] | ||
− | device = @ | + | device = @ipaddress:4014 |
incoming = yes | incoming = yes | ||
regular_run = /var/spool/sms/regular_run/SOV4014.sh | regular_run = /var/spool/sms/regular_run/SOV4014.sh | ||
Baris 118: | Baris 118: | ||
[SOV4015] | [SOV4015] | ||
− | device = @ | + | device = @ipaddress:4015 |
incoming = yes | incoming = yes | ||
regular_run = /var/spool/sms/regular_run/SOV4015.sh | regular_run = /var/spool/sms/regular_run/SOV4015.sh | ||
Baris 126: | Baris 126: | ||
[SOV4016] | [SOV4016] | ||
− | device = @ | + | device = @ipaddress:4016 |
incoming = yes | incoming = yes | ||
regular_run = /var/spool/sms/regular_run/SOV4016.sh | regular_run = /var/spool/sms/regular_run/SOV4016.sh | ||
Baris 135: | Baris 135: | ||
# main incoming modem | # main incoming modem | ||
[SOV4017] | [SOV4017] | ||
− | device = @ | + | device = @ipaddress:4017 |
incoming = high | incoming = high | ||
queues = SOV4017, HALO | queues = SOV4017, HALO | ||
Baris 144: | Baris 144: | ||
[SOV4018] | [SOV4018] | ||
− | device = @ | + | device = @ipaddress:4018 |
incoming = yes | incoming = yes | ||
regular_run = /var/spool/sms/regular_run/SOV4018.sh | regular_run = /var/spool/sms/regular_run/SOV4018.sh | ||
Baris 152: | Baris 152: | ||
[SOV4019] | [SOV4019] | ||
− | device = @ | + | device = @ipaddress:4019 |
incoming = yes | incoming = yes | ||
regular_run = /var/spool/sms/regular_run/SOV4019.sh | regular_run = /var/spool/sms/regular_run/SOV4019.sh | ||
Baris 160: | Baris 160: | ||
[SOV4020] | [SOV4020] | ||
− | device = @ | + | device = @ipaddress:4020 |
incoming = yes | incoming = yes | ||
regular_run = /var/spool/sms/regular_run/SOV4020.sh | regular_run = /var/spool/sms/regular_run/SOV4020.sh | ||
Baris 168: | Baris 168: | ||
[SOV4021] | [SOV4021] | ||
− | device = @ | + | device = @ipaddress:4021 |
incoming = yes | incoming = yes | ||
regular_run = /var/spool/sms/regular_run/SOV4021.sh | regular_run = /var/spool/sms/regular_run/SOV4021.sh | ||
Baris 176: | Baris 176: | ||
[SOV4022] | [SOV4022] | ||
− | device = @ | + | device = @ipaddress:4022 |
incoming = yes | incoming = yes | ||
regular_run = /var/spool/sms/regular_run/SOV4022.sh | regular_run = /var/spool/sms/regular_run/SOV4022.sh | ||
Baris 184: | Baris 184: | ||
[SOV4023] | [SOV4023] | ||
− | device = @ | + | device = @ipaddress:4023 |
incoming = yes | incoming = yes | ||
regular_run = /var/spool/sms/regular_run/SOV4023.sh | regular_run = /var/spool/sms/regular_run/SOV4023.sh | ||
Baris 192: | Baris 192: | ||
[SOV4024] | [SOV4024] | ||
− | device = @ | + | device = @ipaddress:4024 |
incoming = yes | incoming = yes | ||
regular_run = /var/spool/sms/regular_run/SOV4024.sh | regular_run = /var/spool/sms/regular_run/SOV4024.sh | ||
Baris 198: | Baris 198: | ||
regular_run_cmdfile = /var/spool/sms/regular_run/SOV4024.cmdfile | regular_run_cmdfile = /var/spool/sms/regular_run/SOV4024.cmdfile | ||
regular_run_statfile = /var/spool/sms/regular_run/SOV4024.statfile | 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 |
Revisi terkini pada 2 September 2014 22.11
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)
- 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