Monday, September 21, 2015

Configuring sms gateway with gammu and Kalkun on Ubuntu 14.04

Hello everyone, in this lab am going to show you how to install and configure sms gateway using gammu and Kalkun. An SMS gateway allows a computer to send or receive Short Message Service (SMS) transmissions to or from a telecommunications network.

Lab requirements
Hardware:
-A computer installed with Operating system, you can install windows, Mac or Linux operating systems, am using Ubuntu 14.04
--Modem with is supported by gammu, see supported modems here.Am using zte MF 190 in my lab.

Software:
-Gammu
    An open source program for communicating with mobile phones.It is command line sms gateway utility which allows to use all libGammu features.

-Kalkun
  Kalkun is open source web-based SMS (Short Message Service) management, it use gammu-smsd (part of gammu family) as SMS gateway engine to deliver and retrieve messages from your phone/modem.


Procedures
The lab consist two main steps
-Gammu installation
-Kalkun installation


********************
1. Gammu installation
********************

Prepare your machine
 As this is new installed Linux server, you should run the following command to prepare your server for gammu installation

sudo apt-get  update
sudo apt-get  upgrade

Install Gammu
sudo apt-get install gammu gammu-smsd

Now connect you modem and check is it is detected by running the following command

dmesg | grep tty

Output
sudo dmesg | grep tty
[    0.000000] console [tty0] enabled
[    0.827573] 00:04: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
[  203.063947] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0
[  203.064281] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1
[  203.064416] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2

Now configure gammu, create gammrc file and add the the following

sudo vim /root/.gammurc

The file should look like

[gammu]

port = /dev/ttyUSB2
model =
connection=at115200
synchronizetime = yes
logfile = /var/log/smsdlog
logformat = nothing
use_locking =
gammuloc =

Note:
port: /dev/ttyUSB* (depends on your usb modem attached port)

Test the connection between gammu and modem by running one of the following command

a. get modem identify

sudo gammu --identify

Device               : /dev/ttyUSB2
Manufacturer         : ZTE CORPORATION
Model                : unknown (MF190)
Firmware             : BD_MF190V1.0.0B24
IMEI                 : 865720018986973
SIM IMSI             : 640045000066980

b. Send a test sms

$ sudo su
# echo "This is just a test sms" | gammu --sendsms TEXT +25571588XXXX

If you want break, press Ctrl+C...
Sending SMS 1/1....waiting for network answer..OK, message reference=16


If everything is working fine and you are able to send sms via command move to step 2 now


**********************
2. Kalkun installation
**********************

-Since Kalkun is web based sms management service, we will install LAMP (apache as website, mysql database and php) as pre-requisity

To install LAMP,use the following command

sudo apt-get install lamp-server^

or

sudo tasksel

Then select [ * ] LAMP Server, It will install all package that needed for LAMP Stack

Now configure your database

a. Create database for sms, am going to call it sms

mysql -u root -p
create database sms;


b. Import data structure for gammu into sms database

#cd /usr/share/doc/gammu/examples/sql
# ls
mysql.sql.gz  pgsql.sql.gz  sqlite.sql.gz

# gunzip mysql.sql.gz
# ls
mysql.sql  pgsql.sql.gz  sqlite.sql.gz

# mysql -u root -p sms < mysql.sql

Check if the schema is imported

# mysql -u root -p

Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 44
Server version: 5.5.44-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sms                |
+--------------------+
4 rows in set (0.00 sec)

mysql>
mysql> use sms

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> show tables;
 
+------------------+
| Tables_in_sms    |
+------------------+
| daemons          |
| gammu            |
| inbox            |
| outbox           |
| outbox_multipart |
| pbk              |
| pbk_groups       |
| phones           |
| sentitems        |
+------------------+
9 rows in set (0.00 sec)

mysql>


-Configure sms daemon

# vi /etc/gammu-smsdrc

The file should look something like

# Configuration file for Gammu SMS Daemon

# Gammu library configuration, see gammurc(5)
[gammu]
# Please configure this!
port = /dev/ttyUSB2
connection=at115200
# Debugging
#logformat = textall

# SMSD configuration, see gammu-smsdrc(5)
[smsd]
service = sql
logfile = /var/log/smsdlog
# Increase for debugging information
debuglevel = 0

# 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/

#mysql connnection
Driver=native_mysql
User=root
Password= [Your mysql dababase password here]
PC=Localhost
Database=sms


Close and save the file.
-Run the service
# /etc/init.d/gammu-smsd start


-Check the service
#tail -f /var/log/smsdlog

b. Now download and install Kalkun
Download and extract the latest source code to your web root folder.

# cd /var/www/html
# mkdir sms
#cd sms

# wget http://downloads.sourceforge.net/project/kalkun/kalkun/0.7.1/kalkun_0.7.1.zip

#unzip kalkun_0.7.1.zip

open vim application/config/database.php and insert your mysql info, as below

$db['default']['hostname'] = "localhost";

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


Change the ownership of sms folder to be accessible by apache user

#chown -R www-data:root /var/www/html/sms

Now restart apache

# /etc/init.d/apache2 restart

Now go to your browser http://<server IP>/sms/ and continue with installation, see below



When install is success rename or remove the install folder

Rename by the following command

# mv install/ install.bk

Finalize your installation by doing the following

a. -Open vim /etc/gammu-smsdrc and add the following line

runonreceive = /var/www/html/sms/scripts/daemon.sh

b.Edit the daemon file and its daemon.php in /scripts folder

#vim /var/www/html/sms/scripts/daemon.sh
and change to 

DAEMON=/var/www/html/sms/scripts/daemon.php

c. Add your url in your daemon.php file

#vim /var/www/html/sms/scripts/daemon.php

change the following line as below

$url = "http://localhost/sms";

Now your are good, stop and start smsd service

#/etc/init.d/gammu-smsd stop
#/etc/init.d/gammu-smsd start

Good to your browser on
http://<server ip>/sms

username is kalkun and password is kalkun.



Enjoy!!
Drop comments if you face any problems.


Monday, September 14, 2015

[Solved]-"Choose your keyboard layout" problem when upgrading to window 10 in Lenovo

I got lenovo g40 machine, i installed window 7 for the aim of upgrading it to window 10, when all initial check is done, and computer reboot to upgrade to window 10 it stuck on Choose your keyboard layout when all the keys are disable.
After several hours of troubleshooting including Googling i notices the problem affects most of Lenovo and HP computers when upgrading to window 10, below are solution for Lenovo.

-Switch off your computer
-Press fn + f2 which will take you to BIOS settings
-Navigate to Exit section, on Os Optimized Defaults choose Win8 64bit
-Then Load Defaults Settings
-Press Fn + F10 to save the configuration and restart.
-When restarting press Fn + F7 which will take you to next window when you will be required to choose between window 7 and window 7 setup, choose window 7 setup to start upgrade.

Your good to go! Problem solved.

Saturday, September 12, 2015

How to Install GNS 1.3.10 in Ubuntu 14.04/Deepin 2014.3

Graphical Network Simulator-3 (GNS3) is a software emulator for networks, launched in 2008. It allows the combination of virtual devices and real devices, and so can be used to simulate complex networks. It uses Dynamips emulation software to simulate Cisco IOS.Below are steps of how to install it on Ubuntu/Deepin from official documentation found here , which i modified a bit to match with new version GNS 1.3.10

#Run apt-get update
➜  ~  sudo apt-get update

# - Install GNS3 Python dependencies
➜  ~  sudo apt-get install python3-setuptools python3-pyqt4 python3-ws4py python3-netifaces python3-crypto


#- Install Dynmips dependencies
➜  ~  sudo apt-get install cmake libelf-dev uuid-dev libpcap-dev

# - Download and unzip GNS3 Linux source files here
Migrade to your download directory and unzip the file

➜ unzip GNS3-1.3.10.source.zip
Results:
Archive:  GNS3-1.3.10.source.zip
 extracting: dynamips-0.2.14.zip  
 extracting: iouyap-0.95.zip      
 extracting: ubridge-0.9.0.zip    
 extracting: vpcs-0.6.1.zip        
 extracting: gns3-server-1.3.10.zip
 extracting: gns3-gui-1.3.10.zip

# - Build and Install Dynamips
➜  ~ unzip dynamips-0.2.14.zip
➜  ~ cd dynamips-0.2.14
➜  ~ mkdir build
➜  ~ cd build
➜  ~ cmake ..
➜  ~ make
➜  ~ sudo make install
➜  ~ sudo setcap cap_net_admin,cap_net_raw=ep /usr/local/bin/dynamips
➜  ~ cd ../..

# - Install GNS3 Server
➜ ~ unzip gns3-server-1.3.10.zip
➜ ~ cd gns3-server-1.3.10
➜ ~ sudo python3 setup.py install
➜ ~ cd ..

# - Install GNS3 GUI
➜ ~ unzip gns3-gui-1.3.10.zip
➜ ~ cd gns3-gui-1.3.10
➜ ~ sudo python3 setup.py install
➜ ~ cd ..

# - Install IOU dependencies
➜ ~ sudo apt-get install libssl1.0.0:i386
➜ ~ sudo ln -s /lib/i386-linux-gnu/libcrypto.so.1.0.0 /lib/libcrypto.so.4
➜ ~ sudo apt-get install bison
➜ ~ sudo apt-get install flex
➜ ~ git clone http://github.com/ndevilla/iniparser.git
➜ ~ cd iniparser
➜ ~ make
➜ ~ cd ..
➜ ~ sudo cp libiniparser.* /usr/lib/
➜ ~ cd iniparser
➜ ~ sudo cp libiniparser.* /usr/lib/
➜ ~ sudo cp src/iniparser.h /usr/local/include
➜ ~ sudo cp src/dictionary.h /usr/local/include
➜ ~ cd ..

# - Install GNS3 IOUYAP app (provides network support for IOU)
➜ ~ unzip iouyap-0.95.zip
➜ ~ cd iouyap-0.95
➜ ~ sudo make install
➜ ~ sudo cp iouyap /usr/local/bin
➜ ~ cd ..

# - Install VPCS
➜ ~ unzip vpcs-0.6.1.zip
➜ ~ cd vpcs-0.6.1/src
➜ ~./mk.sh
➜ ~ sudo cp vpcs /usr/local/bin
➜ ~ cd ../..

# - Install VirtualBox
➜ ~ sudo apt-get install virtualbox

# - Install Wireshark
➜ ~ sudo apt-get install wireshark

# - Install QEMU - method 1
$ sudo apt-get install qemu
# - Install QEMU - method 2 (x86 arch. only)
$ sudo apt-get install qemu-system-x86
$ sudo apt-get install qemu-utils

# - Install cpulimit
$ sudo apt-get install cpulimit

# - Start GNS3
➜ ~ gns3

Note:
Don't include ➜ ~ when copying the command as that is Deepin terminal prompt.


Enjoy!

Sunday, September 6, 2015

How to free space in SSD on window 7


After installation of window 7 in computer with SSD and high RAM you may notice high usage of disk space than normal.This happens to me when i was installing window 7 on 100GB SSD drive with 16GB of RAM, i noticed installation took almost 40GB which is not normal at all for window 7, below is how i did to restore my space.


This is how my C look after installation but before space recovery:

Decrease the size of page file/Virtual Memory
Window as in Linux it allocates part of your hard drive as page file or virtual memory for the aim of increasing the performance of your computer, but if you have more than 4 GB of RAM this is useless, for me it allocates 16 GB of my hard drive as virtual memory, so the best way is to minimize it to 1024 Mb to 512 Mb by following the steps below:

-Click the Start button, right click Computer and then click Properties
-In the left pane click Advanced system settings
-In the window that opens click the Settings button in the Performance group box and select the Advanced tab page.
-Click the Change button and select the drive where you page file currently is (by default C:)
Select Custom size and fill the initial and maximum size of your page file to be the same amount of space
512 MB /1024 MB is more than enough if you have more than 4 GB of RAM When ready click Set and then OK.


By doing that it free most of my hard drive space, see below after performing the step above and restart computer.



Check this link for other means of freezing some space in SSD.


Hope it helps someone, enjoy.