Cara install gammu sms gateway di ubuntu server

Cara install gammu sms gateway di ubuntu server

Cara install gammu sms gateway di ubuntu server merupakan hasil studi kasus di kantor yang sebelumnya menggunakan aplikasi sms gateway berbasis windows. Gammu sms gateway kali ini di install pada ubuntu server 10 dengan modem iTegno GPRS Modem. Sebagai aplikasi sms gateway, Gammu sms gateway sendiri merupakan project open source yang bertujuan untuk melakukan handling operasi handphone, fiturnya yang bermacam-macam dari daftar panggilan, sms, backup pengiriman, daftar buku telpon (phonebook), juga dapat mengimport ataupun mengeksport data csv.

Persiapan dan perlengkapan yang harus ada:

Cara Install Gammu SMS Gateway

Login ke Ubuntu server, kita rubah dulu source listnya, masukan perintah:

1
luthfi@rahwana:~$ sudo nano /etc/apt/sources.list

Lalu gantilah source list tersebut:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#Ubuntu Repository 10.04 UGM
deb <a href="http://repo.ugm.ac.id/ubuntu/" target="_blank" rel="nofollow">http://repo.ugm.ac.id/ubuntu/</a> lucid main restricted universe multiverse
deb <a href="http://repo.ugm.ac.id/ubuntu/" target="_blank" rel="nofollow">http://repo.ugm.ac.id/ubuntu/</a> lucid-updates main restricted universe multiv$
deb <a href="http://repo.ugm.ac.id/ubuntu/" target="_blank" rel="nofollow">http://repo.ugm.ac.id/ubuntu/</a> lucid-security main restricted universe multi$
#gammu
deb <a href="http://repo.ugm.ac.id/ppa.launchpad.net/gammu" target="_blank" rel="nofollow">http://repo.ugm.ac.id/ppa.launchpad.net/gammu</a> lucid main
#kalkun
deb <a href="http://repo.ugm.ac.id/ppa.launchpad.net/kalkun" target="_blank" rel="nofollow">http://repo.ugm.ac.id/ppa.launchpad.net/kalkun</a> lucid main

Kemudian kita ambil file key gammu, masukan perintah:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
luthfi@rahwana:~$ wget ftp://repo.ugm.ac.id/ekstra/.ugos_tools/key_gammu
Connecting to repo.ugm.ac.id|175.111.88.15|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /ekstra/.ugos_tools ... done.
==> SIZE key_gammu ... 689
==> PASV ... done.    ==> RETR key_gammu ... done.
Length: 689 (unauthoritative)

100%[===================>] 689         --.-K/s   in 0.02s

2012-12-13 15:37:49 (34.8 KB/s) - `key_gammu.1' saved [689]

Kemudian masukan key tersebut, dengan perintah:

1
luthfi@rahwana:~$ sudo apt-key add key_gammu

Setelah berhasil, kemudian kita update repositry, biarkan sampai proses update selesai:

1
luthfi@rahwana:~$ apt-get update

Install dependencies gammu dan install gammu:

1
2
3
luthfi@rahwana:~$ sudo apt-get install checkinstall cmake python-dev pkg-config libmysqlclient-dev libpq-dev libcurl4-gnutls-dev libusb-1.0-0-dev libdbi0-dev libbluetooth-dev libgudev-1.0-dev libglib2.0-dev unixodbc-dev
luthfi@rahwana:~$ sudo apt-get install gammu gammu-smsd

Installasi gammu sementara selesai, kita lanjutkan langkah berikutnya dengan membuat database MySQL, setelah database kita buat kembali lagi di layar kegelapan console SMS Server.
Contoh database yang kita buat:
database: websms
user: root
password: root
pc: localhost

Setelah gammu terinstall, kita cek dulu modem kita dengan menuliskan perintah, dan hasilnya sbb:

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
luthfi@rahwana:~$ dmesg | grep tty
[    0.000000] console [tty0] enabled
[    0.268232] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[    0.268356] serial8250: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
[    0.268835] 00:07: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[    0.269039] 00:08: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
[    8.324159] usb 3-2: pl2303 converter now attached to ttyUSB0

luthfi@rahwana:~$ dmesg | grep USB
[    0.273586] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.273699] ehci_hcd 0000:00:1d.7: new USB bus registered, assigned bus number 1
[    0.291669] ehci_hcd 0000:00:1d.7: USB 2.0 started, EHCI 1.00
[    0.291893] hub 1-0:1.0: USB hub found
[    0.292012] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.292040] uhci_hcd: USB Universal Host Controller Interface driver
[    0.292175] uhci_hcd 0000:00:1d.0: new USB bus registered, assigned bus number 2
[    0.292386] hub 2-0:1.0: USB hub found
[    0.292547] uhci_hcd 0000:00:1d.1: new USB bus registered, assigned bus number 3
[    0.292763] hub 3-0:1.0: USB hub found
[    0.292915] uhci_hcd 0000:00:1d.2: new USB bus registered, assigned bus number 4
[    0.293129] hub 4-0:1.0: USB hub found
[    0.293282] uhci_hcd 0000:00:1d.3: new USB bus registered, assigned bus number 5
[    0.293508] hub 5-0:1.0: USB hub found
[    0.891802] usb 3-2: new full speed USB device using uhci_hcd and address 2
[    8.249983] USB Serial support registered for generic
[    8.250126] usbserial: USB Serial Driver core
[    8.312615] USB Serial support registered for pl2303
[    8.324159] usb 3-2: pl2303 converter now attached to ttyUSB0
[    8.324203] pl2303: Prolific PL2303 USB to serial adaptor driver

Konfigurasi gammu config:

1
luthfi@rahwana:~$ gammu-config

Setelah selesai, hasilnya adalah sbb:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
luthfi@rahwana:~$ cat /home/luthfi/.gammurc
# This is a generated gammurc file.
# It was generated by Gammu configurator 0.4
[gammu]
port = /dev/ttyUSB0
model =
connection = at115200
synchronizetime = yes
logfile =
logformat = textall
use_locking = no
gammuloc =

Kemudian kita setting gammurc:

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
luthfi@rahwana:~$ nano /etc/gammu-smsdrc

hasilnya adalah sbb:

luthfi@rahwana:~$ cat /etc/gammu-smsdrc
# Gammu library configuration, see gammurc(5)
[gammu]
port = /dev/ttyUSB0
connection = at115200
logformat = textalldate
use_locking = yes
gammuloc =

# SMSD configuration, see gammu-smsdrc(5)
[smsd]
service = mysql
driver = native_mysql
PIN = 1234

logfile = /etc/smsdlog
runonreceive = /var/www/websmsku/scripts/daemon.sh
# Increase for debugging information
# debuglevel = 0
debuglevel = 255

#Commication frequency settings
commtimeout = 30
sendtimeout = 30
#Phone communication settings
checksecurity = 0

# Database backends congfiguration
user = root
password = root
pc = localhost
database = websms

# Paths where messages are stored
inboxpath = /var/spool/gammu/inbox/
outboxpath = /var/spool/gammu/outbox/
sentsmspath = /var/spool/gammu/sent/
errorsmspath = /var/spool/gammu/error/

Perhatikan baris:
runonreceive = /var/www/websmsku/scripts/daemon.sh

merupakan source dimana nanti Kalkun sms kita install di webserver.

Beres install konfigurasi gammu, sekarang kita cek:

1
2
3
4
5
6
7
8
9
10
11
12
13
luthfi@rahwana:~$ sudo gammu --identify
[sudo] password for luthfi:
Manufacturer         : iWOW
Model                : unknown (TR-800)
Firmware             : AB_02_00_30N_DEF003
IMEI                 : 35578000blabla..bla
SIM IMSI             : 5100155blablabla...bla

done!

Kita cek kirim sms:

1
2
3
4
5
6
7
luthfi@rahwana:~$ sudo gammu --sendsms text 081235025700
Enter message text and press ^D:
haloo test sms gammu nihIf you want break, press Ctrl+C...
Sending SMS 1/1....waiting for network answer..OK, message reference=-1

Selesai..sekarang kita dump example sql gammu di database yang tadi sudah kita buat.
/usr/share/doc/gammu/examples/sql/mysql.sql.qz

note:
kalau kita kesulitan mengambil mysql.sql.qz tersebut, kita pindah saja filenya ke /var/www/ untuk kita download dan kita ekstrak di komputer kita untuk kita ambil sql nya dan kita dump di phpmyadmin.
misal: http://namadomainsaya.com/mysql.sql.qz

1
luthfi@rahwana:~$ cp /usr/share/doc/gammu/examples/sql/mysql.sql.qz /var/www/

Cara install Kalkun SMS Gateway

Langkah install gammu sudah selesai, tinggal cara install Kalkun sms gateway, yang kita letakan di /var/www/
download kalkun: http://sourceforge.net/projects/kalkun/

misalkan ekstrak file di direktori kalkun:
/var/www/websmsku berarti nantinya: http://namadomainsaya.com/websmsku

Note:
Sebelum kita install kalkun, kita rubah dahulu beberapa file konfigurasi database di kalkun tersebut.

Edit konfigurasi kalkun:
/var/www/websmsku/application/config/database.php

1
2
3
4
5
6
7
8
9
10
11
12
$db['default']['hostname'] = "localhost";

// MySQL
$db['default']['username'] = "root";
$db['default']['password'] = "root";
$db['default']['database'] = "websms";
$db['default']['dbdriver'] = "mysql";

Hasil dari daemon.sh:
/var/www/websmsku/scripts/daemon.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
luthfi@rahwana:~$ cat /var/www/websmsku/scripts/daemon.sh |more
#!/bin/sh

# Configure this (use absolute path)
PHP=/usr/bin/php # php cli path
DAEMON=/var/www/websmsku/scripts/daemon.php
# Execute
$PHP $DAEMON

Hasil Edit daemon.php
/var/www/websmsku/scripts/daemon.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
luthfi@rahwana:~$ cat /var/www/websmsku/scripts/daemon.php |more
<?php
// Make sure it's run from CLI
if(php_sapi_name() != 'cli' && !empty($_SERVER['REMOTE_ADDR'])) exit("Access Denied.");

// Please configure this
#$url = "http://localhost/kalkun";
$url = "http://namadomainsaya.com/websmsku";
fclose(fopen($url."/index.php/daemon/message_routine/", "r"));

Setelah selesai edit file tersebut tinggal kita masuk ke url sms web kita untuk proses installasi.
Note:
SQL dari mysql.sql.qz sudah kita dump di phpMyadmin

install pertama kali: http://namadomainsaya.com/websmsku

setelah selesai, kita hapus direktori install yang berada di Kalkun tersebut.

Install Cron Job dan Auto Start SMS Gateway

kita cek dulu:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
luthfi@rahwana:/etc$ sudo /etc/init.d/gammu-smsd start

luthfi@rahwana:/etc$ sudo update-rc.d gammu-smsd defaults

install crontab:

luthfi@rahwana:/etc$ sudo crontab -e

isikan:

10 6 * * * /etc/init.d/gammu-smsd restart

Backup file log:

1
luthfi@rahwana:/etc$ sudo nano /etc/logrotate.d/smsdlog

isikan:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/var/log/smsdlog {
daily
missingok
rotate 7
compress
delaycompress
create 640 root root
endscript
}

Tambahan:

tail -f /var/log/syslog

dmesg | grep -e “modem” -e “tty”

selesai sudah cara install gammu sms gateway di ubuntu server. semoga bermanfaat :)

There are 2 comments for this article

Tinggalkan Balasan

Alamat surel Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *


*

Anda dapat menggunakan tag dan atribut HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>