Project

General

Profile

Library req » History » Version 26

Refik Hadzialic, 11/16/2011 01:26 PM

1 1 Triatmoko -
h1. Library requirement
2 1 Triatmoko -
3 1 Triatmoko -
h2. Python Library
4 1 Triatmoko -
5 2 Triatmoko -
h3. PJSUA Library
6 1 Triatmoko -
7 1 Triatmoko -
pjsua is an open source command line SIP user agent (softphone) that is used as the reference implementation for PJSIP, PJNATH, and PJMEDIA. Despite its simple command line appearance, it does pack many features!
8 1 Triatmoko -
9 1 Triatmoko -
This library use for SIP handler. More information about this library you will found in this site http://www.pjsip.org/pjsua.htm
10 1 Triatmoko -
11 3 Triatmoko -
How to use it and how to install will explain here: [[SIP| SIP Handler]]
12 3 Triatmoko -
13 3 Triatmoko -
h3. SSH
14 3 Triatmoko -
15 6 Triatmoko -
Secure Shell (SSH) is a network protocol for secure data communication, remote shell services or command execution and other secure network services between two networked computers that it connects via a secure channel over an insecure network: a server (running an SSH server program) and a client (running an SSH client program).[1] The protocol specification distinguishes two major versions that are referred to as SSH-1 and SSH-2.
16 6 Triatmoko -
17 6 Triatmoko -
Instalation
18 6 Triatmoko -
19 6 Triatmoko -
<pre>
20 6 Triatmoko -
sudo apt-get install ssh
21 6 Triatmoko -
</pre>
22 6 Triatmoko -
23 6 Triatmoko -
We need to configure ssh connection to the client without typing password. This will be done with copying public key into the client. For more information how to configure, you can find in this tutorial "3 Steps to Perform SSH Login Without Password Using ssh-keygen & ssh-copy-id" by RAMESH NATARAJAN http://www.thegeekstuff.com/2008/11/3-steps-to-perform-ssh-login-without-password-using-ssh-keygen-ssh-copy-id/
24 6 Triatmoko -
25 13 Konrad Meier
h3. install easy_install
26 13 Konrad Meier
27 13 Konrad Meier
<pre>
28 13 Konrad Meier
sudo apt-get install python-setuptools python-dev build-essential
29 13 Konrad Meier
</pre>
30 13 Konrad Meier
31 13 Konrad Meier
h3. Setproctitle 
32 3 Triatmoko -
33 5 Triatmoko -
The library allows a process to change its title (as displayed by system tools such as ps and top).
34 5 Triatmoko -
35 5 Triatmoko -
Changing the title is mostly useful in multi-process systems, for example when a master process is forked: changing the children's title allows to identify the task each process is busy with. The technique is used by PostgreSQL and the OpenSSH Server for example.
36 5 Triatmoko -
37 5 Triatmoko -
The procedure is hardly portable across different systems. PostgreSQL provides a good multi-platform implementation: this module is a Python wrapper around PostgreSQL code.
38 5 Triatmoko -
Installation
39 5 Triatmoko -
40 5 Triatmoko -
You can use easy_install to install the module: to perform a system-wide installation use:
41 5 Triatmoko -
42 5 Triatmoko -
<pre>
43 5 Triatmoko -
sudo easy_install setproctitle
44 5 Triatmoko -
</pre>
45 5 Triatmoko -
46 5 Triatmoko -
If you are an unprivileged user or you want to limit installation to a local environment, you can use the command:
47 5 Triatmoko -
48 5 Triatmoko -
<pre>
49 5 Triatmoko -
easy_install -d /target/path setproctitle
50 5 Triatmoko -
</pre>
51 5 Triatmoko -
52 5 Triatmoko -
Notice that easy_install requires /target/path to be in your PYTHONPATH.
53 5 Triatmoko -
54 5 Triatmoko -
Module content
55 5 Triatmoko -
56 5 Triatmoko -
The module exports the following functions:
57 5 Triatmoko -
58 5 Triatmoko -
<pre>
59 5 Triatmoko -
setproctitle(title)
60 5 Triatmoko -
</pre>
61 5 Triatmoko -
62 5 Triatmoko -
Set title as the title for the current process.
63 5 Triatmoko -
64 5 Triatmoko -
<pre>
65 5 Triatmoko -
getproctitle()
66 5 Triatmoko -
</pre>
67 5 Triatmoko -
68 5 Triatmoko -
Return the current process title.
69 5 Triatmoko -
70 5 Triatmoko -
More information about this library. http://pypi.python.org/pypi/setproctitle
71 5 Triatmoko -
72 10 Triatmoko -
h3. Serial port library
73 10 Triatmoko -
74 10 Triatmoko -
The serial port library is required for the cell phones to communicate with the server
75 10 Triatmoko -
computer and the BeagleBoards. The required library for Python can be installed by typing the following command:
76 10 Triatmoko -
77 10 Triatmoko -
<pre>
78 10 Triatmoko -
sudo apt-get install python-serial
79 10 Triatmoko -
</pre>
80 10 Triatmoko -
81 3 Triatmoko -
h3. MySQLdb
82 5 Triatmoko -
83 5 Triatmoko -
MySQLdb is an thread-compatible interface to the popular MySQL database server that provides the Python database API.
84 5 Triatmoko -
 _mysql is a low-level API similiar to the MySQL C API. ZMySQLDA is a Database Adapter for Zope2.
85 5 Triatmoko -
86 5 Triatmoko -
If you want to write applications which are portable across databases, use MySQLdb, and avoid using this module directly. _mysql provides an interface which mostly implements the MySQL C API. For more information, see the MySQL documentation. The documentation for this module is intentionally weak because you probably should use the higher-level MySQLdb module. If you really need it, use the standard MySQL docs and transliterate as necessary.
87 3 Triatmoko -
88 12 Triatmoko -
h3. pChart library
89 12 Triatmoko -
90 12 Triatmoko -
The pChart library is within our installation les and does not require to be installed individually. The library is only required if one uses the web interface and requires the generated resulting image. The library is open source and does not require any licensing. However, if one needs to learn how the library works, information can be found on the pChart web page http://www.pchart.net/
91 12 Triatmoko -
92 3 Triatmoko -
h2. PhpMyadmin
93 4 Triatmoko -
94 7 Triatmoko -
phpMyAdmin is a very famous MySQL mangement software package. To use it you should install and configure PHP, Apache and php mysql.
95 7 Triatmoko -
The easy way to install PhpMyadmin is installing from package using Apt-get command.
96 7 Triatmoko -
<pre>
97 7 Triatmoko -
sudo apt-get install phpmyadmin
98 7 Triatmoko -
</pre>
99 7 Triatmoko -
100 9 Triatmoko -
For detailed instructions on using repositories and package managers, please go to the site: https://help.ubuntu.com/community/phpMyAdmin
101 7 Triatmoko -
102 4 Triatmoko -
h2. MySQL Server
103 8 Triatmoko -
104 8 Triatmoko -
MySQL is a fast, multi-threaded, multi-user, and robust SQL database server. It is intended for mission-critical, heavy-load production systems as well as for embedding into mass-deployed software.
105 8 Triatmoko -
106 8 Triatmoko -
h3. Installation
107 11 Triatmoko -
108 8 Triatmoko -
To install MySQL, run the following command from a terminal prompt:
109 8 Triatmoko -
<pre>
110 8 Triatmoko -
sudo apt-get install mysql-server
111 8 Triatmoko -
</pre>
112 8 Triatmoko -
113 8 Triatmoko -
During the installation process you will be prompted to enter a password for the MySQL root user.
114 8 Triatmoko -
115 9 Triatmoko -
Once the installation is complete, the MySQL server should be started automatically. More information, please see: https://help.ubuntu.com/11.04/serverguide/C/mysql.html
116 14 Konrad Meier
117 14 Konrad Meier
118 14 Konrad Meier
h1. Installation guide from Konrad
119 14 Konrad Meier
120 14 Konrad Meier
SSH
121 14 Konrad Meier
<pre>
122 14 Konrad Meier
apt-get install apache
123 14 Konrad Meier
</pre>
124 14 Konrad Meier
125 14 Konrad Meier
Python:
126 14 Konrad Meier
<pre>
127 14 Konrad Meier
apt-get install python python-serial python-setuptools python-dev build-essential
128 14 Konrad Meier
easy_install setproctitle
129 14 Konrad Meier
</pre>
130 14 Konrad Meier
131 16 Konrad Meier
Apache + php:
132 1 Triatmoko -
<pre>
133 16 Konrad Meier
apt-get install apache2 
134 16 Konrad Meier
apt-get install libapache2-mod-php5
135 17 Konrad Meier
a2enmod php5
136 17 Konrad Meier
/etc/init.d/apache2 restart
137 14 Konrad Meier
</pre>
138 14 Konrad Meier
139 14 Konrad Meier
MySQL:
140 14 Konrad Meier
<pre>
141 21 Konrad Meier
apt-get install mysql-server python-mysqldb php5-mysql php5-gd
142 14 Konrad Meier
</pre>
143 15 Konrad Meier
144 15 Konrad Meier
PJSUA
145 15 Konrad Meier
<pre>
146 15 Konrad Meier
wget http://www.pjsip.org/release/1.12/pjproject-1.12.tar.bz2
147 15 Konrad Meier
tar --bzip2 -xvf pjproject-1.12.tar.bz2
148 15 Konrad Meier
./configure && make dep && make
149 15 Konrad Meier
cd pjsip-apps/src/python/
150 15 Konrad Meier
make 
151 1 Triatmoko -
sudo make install
152 18 Konrad Meier
</pre>
153 18 Konrad Meier
154 18 Konrad Meier
155 18 Konrad Meier
Webserver-Config: 
156 18 Konrad Meier
(TODO)
157 18 Konrad Meier
see Report page 30 ff.
158 18 Konrad Meier
159 18 Konrad Meier
Database preparation:
160 18 Konrad Meier
<pre>
161 18 Konrad Meier
mysql -u root -p -h localhost
162 18 Konrad Meier
create databas gsmselftesting;
163 18 Konrad Meier
use mysql;
164 18 Konrad Meier
GRANT ALL PRIVILEGES ON gsmselftesting.* TO 'selftest'@'localhost' IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
165 18 Konrad Meier
166 18 Konrad Meier
mysql -u selftest -p -h localhost -D gsmselftesting < gsmselftesting.sql
167 18 Konrad Meier
mysql -u selftest -p -h localhost -D gsmselftesting < InsertData.sql
168 18 Konrad Meier
</pre>
169 18 Konrad Meier
170 19 Konrad Meier
Change mysql login credentials in the code:
171 18 Konrad Meier
<pre>
172 1 Triatmoko -
vim Code/Server-Code/DbClass.py
173 19 Konrad Meier
</pre>
174 19 Konrad Meier
175 19 Konrad Meier
Chnage mysql login credentials in the website:
176 19 Konrad Meier
<pre>
177 19 Konrad Meier
vim /var/www-ssl/gsm-selftest/dbconnection.php
178 15 Konrad Meier
</pre>
179 20 Konrad Meier
180 20 Konrad Meier
181 20 Konrad Meier
182 20 Konrad Meier
Running the System:
183 20 Konrad Meier
<pre>
184 20 Konrad Meier
export DISPLAY=:0.0
185 20 Konrad Meier
./startSoftware.py
186 20 Konrad Meier
</pre>
187 20 Konrad Meier
188 20 Konrad Meier
<pre>
189 20 Konrad Meier
https://132.230.8.115
190 20 Konrad Meier
</pre>
191 22 Refik Hadzialic
192 22 Refik Hadzialic
193 22 Refik Hadzialic
h1. Configuring the web server to handle https and .htaccess files
194 22 Refik Hadzialic
195 22 Refik Hadzialic
h2. HTTPS
196 23 Refik Hadzialic
197 22 Refik Hadzialic
First we want to generate a server key by typing the following command:
198 22 Refik Hadzialic
<pre>
199 22 Refik Hadzialic
openssl genrsa −des3 −out server.key 4096
200 23 Refik Hadzialic
</pre>
201 23 Refik Hadzialic
202 23 Refik Hadzialic
203 23 Refik Hadzialic
This will generate a 4096 bit long private server key, one is asked to enter two times a password for the _server.key_. Using the generated private server key, we will create a certificate signing request, _server.csr_. We were prompted with a series of questions like country, state, organization name and etc which we had to enter to resume.
204 23 Refik Hadzialic
205 23 Refik Hadzialic
<pre>
206 23 Refik Hadzialic
openssl req -new -key server.key -out server.csr 
207 22 Refik Hadzialic
</pre>
208 24 Refik Hadzialic
209 24 Refik Hadzialic
In the next step we had to sign the certificate signing request and enter the amount of days for how long it should be valid. In our case we entered the duration of one year, one can make it for longer periods as well (i.e. the amount of 365 has to be changed).
210 24 Refik Hadzialic
211 24 Refik Hadzialic
<pre>
212 24 Refik Hadzialic
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
213 24 Refik Hadzialic
</pre>
214 24 Refik Hadzialic
215 24 Refik Hadzialic
We were asked to enter the password again for _server.key_. After we have completed this step we had to make a version of the _server.key_ which did not require a password, _server.key.insecure_ and we will rename the files appropriately. 
216 24 Refik Hadzialic
217 24 Refik Hadzialic
<pre>
218 24 Refik Hadzialic
openssl rsa -in server.key -out server.key.insecure
219 24 Refik Hadzialic
mv server.key server.key.secure
220 24 Refik Hadzialic
mv server.key.insecure server.key
221 24 Refik Hadzialic
</pre>
222 24 Refik Hadzialic
223 24 Refik Hadzialic
The generated files are very sensitive, since they are our keys. After these steps were completed, we had generated 4 files: _server.crt_, _server.csr_, _server.key_ and _server.key.secure_. Now we need to enable the SSL engine on the Apache web server. We copied _server.key_ and _server.crt_ into _/etc/appache2/ssl_. 
224 25 Refik Hadzialic
225 25 Refik Hadzialic
<pre>
226 25 Refik Hadzialic
refik@ubuntu:/etc/apache2$ sudo mkdir ssl
227 25 Refik Hadzialic
cp server.key /etc/apache2/ssl
228 25 Refik Hadzialic
cp server.crt /etc/apache2/ssl
229 25 Refik Hadzialic
</pre>
230 25 Refik Hadzialic
231 25 Refik Hadzialic
Then we enabled SSL by typing in _a2enmod ssl_, "it is simply a general purpose utility to establish a symlink between a module in _/etc/apache2/mods-available_ to _/etc/apache2/mods-enabled_ (or give a message to the effect that a given module does not exist or that it is already symlink-ed for loading)".
232 25 Refik Hadzialic
233 25 Refik Hadzialic
<pre>
234 25 Refik Hadzialic
refik@ubuntu:/etc/apache2/ssl$ sudo a2enmod ssl
235 25 Refik Hadzialic
Enabling module ssl.
236 25 Refik Hadzialic
See /usr/share/doc/apache2.2-common/README.Debian.gz on how to configure SSL and create self-signed certificates.
237 25 Refik Hadzialic
Run '/etc/init.d/apache2 restart' to activate new configuration!
238 25 Refik Hadzialic
</pre>
239 26 Refik Hadzialic
240 26 Refik Hadzialic
In the next procedure we had to establish a symlink from the 'available' default-ssl file to the 'enabled' file. Then we created a folder where our secured PHP files will be located (e.g. https://some-domain-name.com/test-software).
241 26 Refik Hadzialic
242 26 Refik Hadzialic
<pre>
243 26 Refik Hadzialic
refik@ubuntu:/etc/apache2/ssl$ sudo ln -s /etc/apache2/sites-available/default-ssl /etc/apache2/sites-enabled/000-default-ssl 
244 26 Refik Hadzialic
refik@ubuntu:/etc/apache2/ssl$ cd /var/
245 26 Refik Hadzialic
refik@ubuntu:/var$ sudo mkdir www-ssl
246 26 Refik Hadzialic
</pre>
247 26 Refik Hadzialic
248 26 Refik Hadzialic
We had backed up our old configuration files for the virtual hosts, for the case if we damage the Apache configuration files. Then we edited the _default-ssl_ file.
249 26 Refik Hadzialic
250 26 Refik Hadzialic
<pre>
251 26 Refik Hadzialic
refik@ubuntu:/var$ cd /etc/apache2/sites-available
252 26 Refik Hadzialic
refik@ubuntu:/etc/apache2/sites-available$ sudo cp default default_original
253 26 Refik Hadzialic
refik@ubuntu:/etc/apache2/sites-available$ sudo cp default-ssl default-ssl_original
254 26 Refik Hadzialic
refik@ubuntu:/etc/apache2/sites-available$ sudo vim default-ssl
255 26 Refik Hadzialic
</pre>
256 26 Refik Hadzialic
257 26 Refik Hadzialic
Only the beginning of the file is listed here and we have modified the line starting with _DocumentRoot_ and _<Directory /var/www/>_ from _DocumentRoot /var/www_ to _DocumentRoot /var/www-ssl_ and from _<Directory /var/www/>_ to _<Directory /var/www-ssl/>_ (i.e. we had to redefine the location of our SSL directory).
258 26 Refik Hadzialic
259 26 Refik Hadzialic
<pre>
260 26 Refik Hadzialic
<IfModule mod_ssl.c>
261 26 Refik Hadzialic
<VirtualHost _default_:443>
262 26 Refik Hadzialic
        ServerAdmin webmaster@localhost
263 26 Refik Hadzialic
264 26 Refik Hadzialic
        DocumentRoot /var/www-ssl
265 26 Refik Hadzialic
        <Directory />
266 26 Refik Hadzialic
                Options FollowSymLinks
267 26 Refik Hadzialic
                AllowOverride None
268 26 Refik Hadzialic
        </Directory>
269 26 Refik Hadzialic
        <Directory /var/www-ssl/>
270 26 Refik Hadzialic
                Options Indexes FollowSymLinks MultiViews
271 26 Refik Hadzialic
                AllowOverride None
272 26 Refik Hadzialic
                Order allow,deny
273 26 Refik Hadzialic
                allow from all
274 26 Refik Hadzialic
        </Directory>
275 26 Refik Hadzialic
</pre>