25 Feb 2015

Membuat SMS-Gateway menggunakan kannel di centOS 7

ada beberapa tipe software untuk membuat sms-gateway diantaranya : gnokii, gammu, kannel, dan sebagainya. kali ini saya akan membahas intalasi kannel di centos 7.
Agak ribet awal instalasi kannel di centos 7, tapi akhirnya berjalan juga mesin sms gatewaynya.

Bahan – bahannya berupa:

software kannelnya sendiri dapat di download disini . Saya menggunakan kannel versi 1.4.3

kemudian saya di menngunakan moden vodafone

library yang harus di install :

  • libxml2
  • libxml2-devel
  • cmake
  • wget
  • gcc
  • bison (saya lupa ini dipake atau nggak, tapi install aja… ini untuk compiler ycc)

Install pake yang dibutuhkan

#yum install wget libxml2 libxml2-devel gcc cmake bison

Oke sekarang kita download kannelnya

Masuk sebagai super user

#sudo su
#cd /tmp/
#wget http://www.kannel.org/download/1.4.3/gateway-1.4.3.tar.gz

kemudian extract

#tar -zxvf gateway-1.4.3.tar.gz
gateway-1.4.3/gw/wml_compiler.c
gateway-1.4.3/gw/wap_push_si_compiler.h
gateway-1.4.3/gw/bearerbox.h
gateway-1.4.3/gw/bb_store_file.c
gateway-1.4.3/gw/smscconn.h
gateway-1.4.3/gw/bb_store.c
gateway-1.4.3/gw/ota_prov.h
gateway-1.4.3/gw/wap-appl.c
gateway-1.4.3/gw/bb_store_spool.c
gateway-1.4.3/gw/wapkannel.conf
gateway-1.4.3/gw/wap-maps.h
gateway-1.4.3/gw/wap_push_pap_compiler.c
gateway-1.4.3/gw/wap_ppg_session_machine.def
gateway-1.4.3/gw/dlr_pgsql.c
gateway-1.4.3/gw/dlr.h
gateway-1.4.3/gw/wbxml_tokens.def
gateway-1.4.3/gw/alt_charsets.h
gateway-1.4.3/gw/mime_decompiler.h
gateway-1.4.3/gw/smscconn.c
gateway-1.4.3/gw/wap_push_ota.c
gateway-1.4.3/gw/wap_push_si_compiler.c
gateway-1.4.3/gw/urltrans.h
gateway-1.4.3/gw/urltrans.c
gateway-1.4.3/gw/load.c
gateway-1.4.3/gw/numhash.h
gateway-1.4.3/gw/wapbox.c
gateway-1.4.3/gw/bb_smscconn_cb.h
gateway-1.4.3/gw/dlr_sdb.c
gateway-1.4.3/gw/.cvsignore
gateway-1.4.3/gw/xml_shared.h
gateway-1.4.3/gw/mime_decompiler.c
gateway-1.4.3/gw/bb_boxc.c
gateway-1.4.3/gw/wap_push_ppg.h
gateway-1.4.3/gw/wap_push_pap_compiler.h
gateway-1.4.3/gw-config.h.in
[[email protected] tmp]#

Kemudian masuk kedalam folder gateway

#cd gateway-1.4.3

Compile kannel

#./configure --prefix=/usr/local/kannel --enable-start-stop-daemon

tapilan akhir compile

License information ...
+--------------------------------------------------------------------+
| License: |
| This software is subject to the Kannel Software License, available |
| in this distribution in the file LICENSE. By continuing this |
| installation process, you are bound by the terms of this license |
| agreement. If you do not agree with the terms of this license, you |
| must abort the installation process at this point. |
| |
| The Kannel Group <http://www.kannel.org/> |
+--------------------------------------------------------------------+
Thank you for using Kannel.
[[email protected] gateway-1.4.3]#

Lanjutkan Compile

#make

Tampilan akhiran Compile

gcc -std=gnu99 -D_REENTRANT=1 -I. -Igw -g -O2 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_LARGE_FILES= -I/usr/include/libxml2 -o checks/check_list.o -c checks/check_list.c
gcc -std=gnu99 -D_REENTRANT=1 -I. -Igw -g -O2 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_LARGE_FILES= -I/usr/include/libxml2 -o checks/check_counter.o -c checks/check_counter.c
gcc -std=gnu99 -D_REENTRANT=1 -I. -Igw -g -O2 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_LARGE_FILES= -I/usr/include/libxml2 -o checks/check_octstr.o -c checks/check_octstr.c
gcc -std=gnu99 -D_REENTRANT=1 -I. -Igw -g -O2 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_LARGE_FILES= -I/usr/include/libxml2 -o checks/check_date.o -c checks/check_date.c
gcc -std=gnu99 -D_REENTRANT=1 -I. -Igw -g -O2 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_LARGE_FILES= -I/usr/include/libxml2 -o checks/check_ipcheck.o -c checks/check_ipcheck.c
gcc -std=gnu99 -D_REENTRANT=1 -I. -Igw -g -O2 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_LARGE_FILES= -I/usr/include/libxml2 -rdynamic -o checks/check_list checks/check_list.o libgw.a libwmlscript.a libwap.a libgwlib.a -lrt -lresolv -lnsl -lm  -lpthread -lxml2 -lz -lm -ldl
gcc -std=gnu99 -D_REENTRANT=1 -I. -Igw -g -O2 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_LARGE_FILES= -I/usr/include/libxml2 -rdynamic -o checks/check_counter checks/check_counter.o libgw.a libwmlscript.a libwap.a libgwlib.a -lrt -lresolv -lnsl -lm  -lpthread -lxml2 -lz -lm -ldl
gcc -std=gnu99 -D_REENTRANT=1 -I. -Igw -g -O2 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_LARGE_FILES= -I/usr/include/libxml2 -rdynamic -o checks/check_octstr checks/check_octstr.o libgw.a libwmlscript.a libwap.a libgwlib.a -lrt -lresolv -lnsl -lm  -lpthread -lxml2 -lz -lm -ldl
gcc -std=gnu99 -D_REENTRANT=1 -I. -Igw -g -O2 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_LARGE_FILES= -I/usr/include/libxml2 -rdynamic -o checks/check_date checks/check_date.o libgw.a libwmlscript.a libwap.a libgwlib.a -lrt -lresolv -lnsl -lm  -lpthread -lxml2 -lz -lm -ldl
gcc -std=gnu99 -D_REENTRANT=1 -I. -Igw -g -O2 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_LARGE_FILES= -I/usr/include/libxml2 -rdynamic -o checks/check_ipcheck checks/check_ipcheck.o libgw.a libwmlscript.a libwap.a libgwlib.a -lrt -lresolv -lnsl -lm  -lpthread -lxml2 -lz -lm -ldl
./utils/foobar-config.sh "-I/usr/local/kannel/include/kannel -g -O2 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_LARGE_FILES= -I/usr/include/libxml2" 
        "-L/usr/local/kannel/lib/kannel -lgw -lwap -lgwlib -lrt -lresolv -lnsl -lm  -lpthread -lxml2 -lz -lm -ldl" 
        "1.4.3" > gw-config
chmod 0755 gw-config
[[email protected] gateway-1.4.3]#

Kemudian make install

#make install

Tampilan Compile

/bin/install -c -d /usr/local/kannel/bin
for prog in wmlscript/wmlsc wmlscript/wmlsdasm utils/seewbmp utils/mtbatch gw-config; do 
 /bin/install -c $prog 
 /usr/local/kannel/bin/`basename $prog`; 
done
test -r /usr/local/kannel/bin/gw-config || 
 ln -sf gw-config /usr/local/kannel/bin/gw-config
/bin/install -c -d /usr/local/kannel/sbin
for prog in gw/bearerbox gw/smsbox gw/wapbox utils/run_kannel_box utils/start-stop-daemon; do 
 /bin/install -c $prog 
 /usr/local/kannel/sbin/`basename $prog`; 
done
/bin/install -c -d /usr/local/kannel/share/man/man1
/bin/install -c utils/seewbmp.1 utils/mtbatch.1 wmlscript/wmlsc.1 wmlscript/wmlsdasm.1 /usr/local/kannel/share/man/man1
/bin/install -c -d /usr/local/kannel/share/man/man8
/bin/install -c gw/kannel.8 utils/run_kannel_box.8 /usr/local/kannel/share/man/man8
/bin/install -c -d /usr/local/kannel/include/kannel/gwlib
/bin/install -c -m 644 ./gwlib/*.h /usr/local/kannel/include/kannel/gwlib
/bin/install -c -m 644 ./gwlib/*.def /usr/local/kannel/include/kannel/gwlib
/bin/install -c -d /usr/local/kannel/include/kannel/gw
/bin/install -c -m 644 ./gw/*.h /usr/local/kannel/include/kannel/gw
/bin/install -c -m 644 ./gw/*.def /usr/local/kannel/include/kannel/gw
/bin/install -c -d /usr/local/kannel/include/kannel/gw/smsc
/bin/install -c -m 644 ./gw/smsc/*.h /usr/local/kannel/include/kannel/gw/smsc
/bin/install -c -m 644 ./gw/smsc/*.def /usr/local/kannel/include/kannel/gw/smsc
/bin/install -c -d /usr/local/kannel/include/kannel/wap
/bin/install -c -m 644 ./wap/*.h /usr/local/kannel/include/kannel/wap
/bin/install -c -m 644 ./wap/*.def /usr/local/kannel/include/kannel/wap
/bin/install -c -m 644 gw-config.h /usr/local/kannel/include/kannel
/bin/install -c -d /usr/local/kannel/lib/kannel
/bin/install -c -m 644 libgwlib.a /usr/local/kannel/lib/kannel
/bin/install -c -m 644 libgw.a /usr/local/kannel/lib/kannel
/bin/install -c -m 644 libwap.a /usr/local/kannel/lib/kannel
[[email protected] gateway-1.4.3]#

Oke instalasi kannel sudah berhasil. Kemudian kita configurasi kannel

#cp gw/smskannel.conf /usr/local/kannel

buka file smskannel pada folder /usr/local/kannel

#vi /usr/local/kannel/smskannel.conf

kemudian rubah config seperti di bawah ini

#
# THIS IS A SAMPLE CONFIGURATION FOR SMS KANNEL
#
# This basic version is used for system testing. It expects 'fakesmsc' to
# send messages which are replied with simple fixed text message.
# It is run like this:
#
#  1% gw/bearerbox gw/smskannel.conf
#  2% gw/smsbox gw/smskannel.conf
#  3% test/fakesmsc -i 0.1 -m 100 "123 345 text nop"
#
# ..all 3 commands in separate shells (or screen sessions)
# Note that you can run them in different machines but have to
# add certain command line argument and configuration variables then
#
#
# For any modifications to this file, see Kannel User Guide 
# If that does not help, see Kannel web page (http://www.kannel.org) and
# various online help and mailing list archives
#
# Notes on those who base their configuration on this:
#  1) check security issues! (allowed IPs, passwords and ports)
#  2) groups cannot have empty rows inside them!
#  3) read the user guide
#
# Kalle Marjola for Kannel project 2001, 2004

#---------------------------------------------
# CORE
#
# There is only one core group and it sets all basic settings
# of the bearerbox (and system). You should take extra notes on
# configuration variables like 'store-file' (or 'store-dir'),
# 'admin-allow-ip' and 'access.log'


group = core
admin-port = 13000
smsbox-port = 13001
admin-password = bar
#status-password = foo
log-file = "/usr/local/kannel/var/logs/kannel.log" 
log-level = 0
box-deny-ip = "*.*.*.*"
box-allow-ip = "127.0.0.1"
#box-allow-ip = "10.13.10.110"
#unified-prefix = "+358,00358,0;+,00"
#access-log = "/tmp/access.log"
#store-file = "kannel.store"
#ssl-server-cert-file = "cert.pem"
#ssl-server-key-file = "key.pem"
#ssl-certkey-file = "mycertandprivkeyfile.pem"

#---------------------------------------------
# SMSC CONNECTIONS
#
# SMSC connections are created in bearerbox and they handle SMSC specific
# protocol and message relying. You need these to actually receive and send
# messages to handset, but can use GSM modems as virtual SMSCs


# This is a fake smsc connection, _only_ used to test the system and services.
# It really cannot relay messages to actual handsets!

group = smsc
smsc = at
smsc-id = MF627  #Ini tipe modem saya
host = 10.14.203.88 #Ini tipe komputer saya.. Default isi 127.0.0.1 pun bisa
modemtype = auto
device = /dev/ttyUSB1 #port modem saya
speed = 9600 #Speed modem saya
port = 10000
my-number = +6282306***** #ini nomer hp modem
connect-allow-ip = 127.0.0.1
sms-center = "+6281100000"#sms center, kartu saya menggunakan telkomsel

group = modems
id = MF627
name = MF627
detect-string = "MF627"
#---------------------------------------------
# SMSBOX SETUP
#
# Smsbox(es) do higher-level SMS handling after they have been received from
# SMS centers by bearerbox, or before they are given to bearerbox for delivery

group = smsbox
#bearerbox-host = 127.0.0.1
bearerbox-host = 10.14.203.88
sendsms-port = 13013
global-sender = +62823******* #nomer modem
#global-sender = 13013
sendsms-chars = "0123456789 +-"
log-file = "/usr/local/kannel/var/logs/smsbox.log"
log-level = 0
access-log = "/usr/local/kannel/var/logs/access.log"

#---------------------------------------------
# SEND-SMS USERS
#
# These users are used when Kannel smsbox sendsms interface is used to
# send PUSH sms messages, i.e. calling URL like
# http://kannel.machine:13013/cgi-bin/sendsms?username=tester&password=foobar...

group = sendsms-user
username = tester
password = foobar
#user-deny-ip = ""
#user-allow-ip = ""

#-----------------------
# SERVICES
#
# These are 'responses' to sms PULL messages, i.e. messages arriving from
# handsets. The response is based on message content. Only one sms-service is
# applied, using the first one to match.

#group = sms-service
#keyword = nop
#text = "You asked nothing and I did it!"

# There should be always a 'default' service. This service is used when no
# other 'sms-service' is applied.

group = sms-service
keyword = default
#text = "No service specified"
get-url = "http://localhost/kannel/receivesms.php?sender=%p&amp;text=%b"
accept-x-kannel-headers = true
max-messages = 3
concatenation = true
catch-all = true

Simpan dan keluar

Buat folder dan file log

mkdir /usr/local/kannel/var
mkdir /usr/local/kannel/var/logs
touch /usr/local/kannel/var/logs/access.log
touch /usr/local/kannel/var/logs/kannel.log
touch /usr/local/kannel/var/logs/smsbox.log

Jalankan kannel

#/usr/local/kannel/sbin/bearerbox -v 1 /usr/local/kannel/smskannel.conf &
#/usr/local/kannel/sbin/smsbox /usr/local/kannel/smskannel.conf &

tes sms

 #/usr/bin/GET "http://127.0.0.1:13013/cgi-bin/sendsms?user=tester&pass=foobar&text=Tess SMS dari Kannel&to=0856********&from=SMS"

Kemudian setting agar kannel berjalan saat starup

#vi /etc/init.d/kannel

Copy script berikut

#!/bin/sh
#
# gateway This shell script takes care of starting and stopping
# the Kannel WAP gateway (bearer/wapbox)
#
# chkconfig: 2345 97 03
# description: Start and stop the Kannel WAP gateway used to fetch 
# some WML content from a Web server & compile it 
# into WMLC mobile phone bytecode.
# probe: true
 
# Use start-stop-daemon
ver=1.4.3
BBOX=/usr/local/kannel/sbin/bearerbox
SBOX=/usr/local/kannel/sbin/smsbox
START="/usr/local/kannel/sbin/start-stop-daemon --start --background --quiet --exec"
STOP="/usr/local/kannel/sbin/start-stop-daemon --stop --quiet --oknodo --exec"
CONF=/usr/local/kannel/sbin/smskannel.conf
LEVEL=-v 1
[ $# -eq 2 ] && ver=$2
 
# Source function library.
. /etc/rc.d/init.d/functions
 
# Source networking configuration.
. /etc/sysconfig/network
 
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x $BBOX ] || exit 0
[ -x $SBOX ] || exit 0
[ -f $CONF ] || exit 0
 
RETVAL=0
# See how we were called.
case "$1" in
 start)
 # Start daemons.
 echo -n "Starting bearer service (gateway kannel $ver): "
 $START $BBOX -- $LEVEL $CONF
 RETVAL1=$?
 sleep 1 # Sleep for a while before we try to start smsbox
 echo
 echo -n "Starting smsbox service (gateway kannel $ver): "
 $START $SBOX -- $CONF
 RETVAL2=$?
 echo
 echo
 [ $RETVAL1 -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/gateway ||
 RETVAL=1
 ;;
 stop)
 # Stop daemons.
 echo -n "Shutting down smsbox (kannel $ver): "
 $STOP $SBOX
 RETVAL2=$?
 echo
 echo -n "Shutting down bearerbox (kannel $ver): "
 $STOP $BBOX
 RETVAL1=$?
 echo
 [ $RETVAL1 -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /var/lock/subsys/gateway
 echo ""
 ;;
 status)
 status bearerbox
 status smsbox
 exit $?
 ;;
 restart)
 $0 stop
 sleep 1
 $0 start
 ;;
 *)
 echo "Usage: named {start|stop|status|restart}"
 exit 1
esac
exit $RETVAL

simpan dan keluar

# chmod +x /etc/init.d/kannel
# chkconfig - -list kannel
# chkconfig kannel on
# service kannel restart
# service kannel status

Semoga Berhasil.

Leave a Reply