Kannel基础

介绍

技术 特性 适用场景 说明
Kannel 适配不同类型的短信提供商的接口(CMPP、SMPP、GSM Modemm、HTTP Interface) - 官网
- Doc
- User's Guide
- Download

运维

安装

CentOS

$ wget https://redmine.kannel.org/attachments/322/gateway-1.4.5.tar.gz --no-check-certificate

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
$ yum update -y
$ yum groupinstall 'Development tools' -y
$ yum install openssl-devel openjade jadetex docbook-style-dsssl texlive-dvips transfig ImageMagick libxml2-devel bison-devel byacc texlive-collection-xetex -y

$ yum update
$ yum groupinstall "Development tools" -y
$ yum install libxml2-devel -y

$ cd /usr/local/src
$ wget http://www.kannel.org/download/1.4.4/gateway-1.4.4.tar.gz --no-check-certificate
$ tar -zxvf gateway-1.4.4.tar.gz
$ cd gateway-1.4.4
$ ./configure --prefix=/etc/kannel --enable-start-stop-daemon
$ make
$ make install
$ mkdir /etc/kannel/smscs
$ sudo mkdir /etc/kannel/logs
$ sudo mkdir /etc/kannel/run
$ sudo vi /etc/kannel/kannel.conf
# kannel.conf
group = core
dlr-storage = internal
admin-port = 14000
admin-password = <admin-password>
status-password = <status-password>
admin-allow-ip = '*.*.*.*'
smsbox-port = 14004
log-level = 0
log-file = "/etc/kannel/logs/kannel.log"
box-allow-ip = "*.*.*.*"

# SMSC CONNECTIONS
# Here you can add as many SMSC you want and it will he easy to disable any SMSC
include = "/etc/kannel/smscs/smsc01.conf"

group = smsbox
smsbox-id = BOX1
bearerbox-host = X.X.X.X
sendsms-port = 14013
log-file = "/etc/kannel/logs/smsbox.log"
log-level = 0
access-log = "/etc/kannel/logs/access.log"

group = smsbox-route
smsbox-id = BOX1
smsc-id = SMSC01

# For Receiving SMS
group = sms-service
keyword = default
catch-all = yes
max-messages = 0
#get-url = "http://localhost/sms.php?ORIGINATOR=%p&RECEIVER=%P&SMS=%a&SOURCE_PRV=%o"

# For Sending SMS
group = sendsms-user
username = <set-username-for-sending-sms>
password = <set-password-for-sending-sms>
#dlr-url = "http://someurl?"
default-smsc = SMSC01
concatenation= true
max-messages = 2
#forced-smsc = "SMSC01"

$ sudo vi /etc/kannel/smscs/smsc1.conf
group = smsc
smsc = smpp
smsc-id = SMSC01
host = <smsc-host>
port = <smsc-port>
system-id = <username>
smsc-password = <password>
system-type = SMPP
transceiver-mode = true
enquire-link-interval=30
reconnect-delay=10
interface-version=34
log-file = "/etc/kannel/logs/smsc01.log"
allowed-smsc-id = SMSC01

$ touch /etc/init.d/kannel
$ chmod a+x /etc/init.d/kannel
$ vim /etc/init.d/kannel
#!/bin/sh
# Start/stop the Kannel boxes: One bearer box and one WAP box.

# This is the default init.d script for Kannel. Its configuration is
# appropriate for a small site running Kannel on one machine.

# Make sure that the Kannel binaries can be found in $BOXPATH or somewhere
# else along $PATH. run_kannel_box has to be in $BOXPATH.

BOXPATH=/etc/kannel/sbin
PIDFILES=/etc/kannel/run
CONFDIR=/etc/kannel
CONF=$CONFDIR/kannel.conf

USER=kannel
VERSION=""
#VERSION="-0.12.4"

RB=$BOXPATH/run_kannel_box$VERSION
BB=$BOXPATH/bearerbox$VERSION
WB=$BOXPATH/wapbox$VERSION
SB=$BOXPATH/smsbox$VERSION
SSD=$BOXPATH/start-stop-daemon$VERSION

PATH=$BOXPATH:$PATH

# On Debian, the most likely reason for the bearerbox not being available
# is that the package is in the "removed" or "unconfigured" state, and the
# init.d script is still around because it's a conffile. This is normal,
# so don't generate any output.
#test -x $BOXPATH/$BB || exit 0

case "$1" in
start)
echo -n "Starting WAP gateway: bearerbox"
$SSD --start --quiet --pidfile $PIDFILES/kannel_bearerbox.pid --exec $RB -- --pidfile $PIDFILES/kannel_bearerbox.pid $BB -- $CONF
echo -n " smsbox"
$SSD --start --quiet --pidfile $PIDFILES/kannel_smsbox.pid --exec $RB -- --pidfile $PIDFILES/kannel_smsbox.pid $SB -- $CONF
echo "."
;;

stop)
echo -n "Stopping WAP gateway: "
echo -n " smsbox"
$SSD --stop --quiet --pidfile $PIDFILES/kannel_smsbox.pid --exec $RB
echo -n " bearerbox"
$SSD --stop --quiet --pidfile $PIDFILES/kannel_bearerbox.pid --exec $RB
echo "."
;;

status)
CORE_CONF=$(grep -r 'group[[:space:]]*=[[:space:]]*core' $CONFDIR | cut -d: -f1)
ADMIN_PORT=$(grep '^admin-port' $CORE_CONF | sed "s/.*=[[:space:]]*//")
ADMIN_PASS=$(grep '^admin-password' $CORE_CONF | sed "s/.*=[[:space:]]*//")
STATUS_URL="http://127.0.0.1:${ADMIN_PORT}/status.txt?password=${ADMIN_PASS}"
lynx -source $STATUS_URL
;;

reload)
# We don't have support for this yet.
exit 1
;;

restart|force-reload)
$0 stop
sleep 1
$0 start
;;

*)
echo "Usage: $0 {start|stop|status|reload|restart|force-reload}"
exit 1

esac

exit 0

$ service kannel start
$ curl 'http://X.X.X.X:14000/status?password=<admin-password-in-kannel.conf>'

Ubuntu

1
2


参考

坚持原创技术分享,您的支持将鼓励我继续创作!
0%