Monday, August 24, 2009

Installing SerMyAdmin 1.2.8 With OpenSIPS 1.5.xx ON Ubuntu 9.x.x

WARNING: Tutorial is in progress, not finalized yet so please contribute if you have efficient way of doing this...

Why SerMyADmin?
We need a GUI tool to help users and administrators, OpenSIPS offer command tool (opensipsctl) but its not easy to use it when dealing with 1000's of users.

SerMyAdmin 1.2.8 is available for download at https://sourceforge.net/projects/sermyadmin/

Objectives:

  • Installing Dependencies
  • Installing SerMyAdmin 1.2.8
  • Configuring User's/Administrator's Access
  • Add and Remove domains
  • Customize the Portal:
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Changes since the last version:
- New installation tool
- It uses now the opensips database instead of their own.
- Does not delete and recreate any opensips tables
- Five new modules
- Updated to Grails 1.0.5 and Jsecurity 0.4.1
- Database table cdrs was renamed to srm_cdrs to avoid conflicts with opensips-cp


Important Consideration:
The database connection parameters are defined in the file /usr/local/tomcat6/conf/context.xml The defaults used are "opensips:opensipsrw". Please adjust the parameters specific to your needs.

If the system do not start, please restart tomcat6 (/etc/init.d/tomcat6 restart) it is often the problem.
SerMyAdmin is best viewed using Firefox.
default user: admin@setup
default password: secret


By Flavio E. Goncalves
http://www.sermyadmin.org/

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

STOP!!! Before you start, you must add the non-free repository to your /etc/apt/sources.list to include the contrib and non-free repositories as stated in the instructions. Java is not in the standard Debian repositories.

>> Add repositories in file...
$ nano /etc/apt/sources.list

deb http://ftp.us.debian.org/debian/ etch main contrib non-free
deb-src http://ftp.us.debian.org/debian/ etch main contrib non-free
deb http://security.debian.org/ etch/updates main contrib non-free
deb-src http://security.debian.org/ etch/updates main contrib non-free

>> Update the package listings:
$ apt-get update
...
...

Manual Installation:
You can always install by using the script provided "install.sh" but if someone have curiousity to go all the way step by step then here it is...

Untar the package using following command:
$ tar xvfz sermyadmin-install-1.2.8.tar.gz

Installing Dependencies:
`````````````````````````
SerMyAdmin uses Grails framework thus it needs an application server. We will use Apache Tomcat in this tutorial because it's easy to install and it's free.

>> Install SunJava by executing following command:
$ aptitude install sun-java6-jdk
...
...
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state informationInitializing package states... Done
The following NEW packages will be installed: gsfonts-x11{a} java-common{a} sun-java6-bin{a} sun-java6-jdk sun-java6-jre{a}
0 packages upgraded, 5 newly installed, 0 to remove and 1 not upgraded.
Need to get 52.6MB of archives. After unpacking 156MB will be used.

Do you want to continue? [Y/n/?] Y
Writing extended state information... Done

Preconfiguring packages ...
Selecting previously deselected package java-common.(Reading database ... 145032 files and directories currently installed.)
Unpacking java-common (from .../java-common_0.30ubuntu4_all.deb) ...
Selecting previously deselected package sun-java6-jre.
Unpacking sun-java6-jre (from .../sun-java6-jre_6-14-0ubuntu1.9.04_all.deb) ...
Selecting previously deselected package sun-java6-bin.
Unpacking sun-java6-bin (from .../sun-java6-bin_6-14-0ubuntu1.9.04_amd64.deb) ...

Accept license, terms, and conditions:

sun-dlj-v1-1 license has already been accepted
Selecting previously deselected package sun-java6-jdk.
Unpacking sun-java6-jdk (from .../sun-java6-jdk_6-14-0ubuntu1.9.04_amd64.deb) ...
...
...
DoneBuilding dependency tree
Reading state information... Done
Reading extended state informationInitializing package states... Done
Writing extended state information... Done

>> Lookup the directory where java files and links are stored:
$ ls -l /usr/lib/jvm/

lrwxrwxrwx 1 root root 19 2009-08-25 12:24 java-6-sun -> java-6-sun-1.6.0.14
drwxr-xr-x 8 root root 4096 2009-08-25 12:24 java-6-sun-1.6.0.14

>> Make Java implementation default for Debian to use by executing following command:
$ update-java-alternatives -s java-6-sun
...
...
Using '/usr/lib/jvm/java-6-sun/bin/appletviewer' to provide 'appletviewer'.
Using '/usr/lib/jvm/java-6-sun/bin/apt' to provide 'apt'.

>> If all goes well then following command should give you similar output
$ java -version

java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode)


Installing Apache Tomcat 6:
````````````````````````````
- Unpack ApacheTomcat package from sermyadmin-install directory...
$ tar xvfz apache-tomcat-6.0.16.tar.gz

- Create a link to directory
$ ln -s apache-tomcat-6.0.16 tomcat6

>> To see the contents of package execute following commands:
$ cd apache-tomcat-6.0.16
$ ls -l
drwxrwxrwx 2 root root 4096 2009-08-11 20:40 bin
drwxrwxrwx 2 root root 4096 2009-08-11 20:41 conf
-rwxrwxrwx 1 root root 148 2009-03-26 11:18 generate-cdrs.sh
drwxrwxrwx 2 root root 4096 2009-08-11 20:40 lib
-rwxrwxrwx 1 root root 37951 2009-03-26 11:18 LICENSE
drwxrwxrwx 2 root root 4096 2009-08-20 17:57 logs
-rwxrwxrwx 1 root root 556 2009-03-26 11:18 NOTICE
-rwxrwxrwx 1 root root 7508 2009-03-26 11:18 RELEASE-NOTES
-rwxrwxrwx 1 root root 6681 2009-03-26 11:18 RUNNING.txt
drwxrwxrwx 3 root root 4096 2009-08-11 20:40 temp
drwxrwxrwx 7 root root 4096 2009-08-20 17:57 webapps
drwxrwxrwx 3 root root 4096 2009-08-11 20:40 work


- Write a short script to start Tomcat6 at your server initialization
- Copy the script in /etc/init.d ... as "tomcat6"
- Make script executable at initialization as follows:

$ cd /etc/init.d
$ chmod 755 tomcat6
$ update-rc.d tomcat6 defaults 99

update-rc.d: warning: /etc/init.d/tomcat6 missing LSB information
update-rc.d: see <http://wiki.debian.org/LSBInitScripts>
Adding system startup for /etc/init.d/tomcat6 ...
/etc/rc0.d/K99tomcat6 -> ../init.d/tomcat6
/etc/rc1.d/K99tomcat6 -> ../init.d/tomcat6
/etc/rc6.d/K99tomcat6 -> ../init.d/tomcat6
/etc/rc2.d/S99tomcat6 -> ../init.d/tomcat6
/etc/rc3.d/S99tomcat6 -> ../init.d/tomcat6
/etc/rc4.d/S99tomcat6 -> ../init.d/tomcat6
/etc/rc5.d/S99tomcat6 -> ../init.d/tomcat6

- Now reboot the server, open your browser and type the URL http://mydomain:8080/ in the address bar; if all gone well then you'll see Tomcat's startup page...
- Install MySQL driver for Tomcat, to enable access of your database by SerMyAdmin.
- Download the driver and then execute the commands as follows:

$ wget http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.8.tar.gz/from/http://mirror.services.wisc.edu/mysql/
$ tar zxvf mysql-connector-java-5.1.8.tar.gz
$ cp mysql-connector-java-5.1.8/mysql-connector-java-5.1.8-bin.jar /usr/src/tomcat6/lib

Note: Driver can be found at http://dev.mysql.com/downloads/connector/j/5.1.html

- Update the file "context.xml" found in /usr/src/tomcat6/conf as follows:


Make changes in highlighted tags, based on how you are handling your server. You also need to create a user referenced in context.xml file (in my case "sermyadmin") This user should have required access to database

/usr/local/tomcat6/conf# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1489Server version: 5.0.75-0ubuntu10.2 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> grant all privileges on opensips.* to mailto:sermyadmin@ identified by 'secret';Query OK, 0 rows affected (0.00 sec)
mysql> \q

>> Copy necessary files as follows:
$ cp serMyAdmin.war /usr/local/tomcat6/webapps/serMyAdmin.war
$ cp context.xml /usr/local/tomcat6/conf/context.xml


Configure Debian's Message Transfer Agent if you wish SerMyAdmin to send confirmation email to new users. You can configure to your existing MTA also for this purpose.

Restart tomcat6 again using command "tomcat6 start" and you are done with setup.....
To access SerMyAdmin point your browser to http://:8080/serMyAdmin and you will see the login page ...


Installing SerMyAdmin 1.2.8 using standard script:
`````````````````````````````` `````````````````````
$ tar xvfz sermyadmin-install-1.2.8.tar.gz
sermyadmin-install/
sermyadmin-install/context.xml
sermyadmin-install/install.sh
sermyadmin-install/stacktrace.log
sermyadmin-install/script/
sermyadmin-install/script/tomcat6
sermyadmin-install/apache-tomcat-6.0.16.tar.gz
sermyadmin-install/INSTALL
sermyadmin-install/sermyadmin.sql
sermyadmin-install/README
sermyadmin-install/serMyAdmin.war

Switch directory to read INSTALL file for details about package...

/usr/src$ cd sermyadmin-install
/usr/src/sermyadmin-install$ more INSTALL

********************************************************************
* Please, you MUST have the contrib and non-free repositories
* in your /etc/apt/sources.list or you won't be able to install
* Java 6
*
* To install Java 6 you need at least Debian version 5
*
* IMPORTANT: Before running this program, you MUST have
* ran opensipsdbctl to create the OpenSIPS database. serMyAdmin
do not create a new database it only update the opensips
* database.
*
Its strongly advised that you to BACKUP YOUR DATA BEFORE INSTALLING !
***********************************************************************

To install issue following commands and answer questions:

$ ./install.sh

NOTE: If you need to install again, you have to recreate opensips database or change sermyadmin.sql. The sql file cannot be applied twice.

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Specifics to my case:

I already have ISPConfig3 running on port 8080 thus tomcat6 would cause conflict on that port. In order to avoid this conflict I am assigning another port (e.g. 8100)

Following file needs to be updated for this purpose and replace all port 8080 with 8100...

$ /usr/local/tomcat6/conf# nano server.xml

Now my Tomcat6 and ISPConfig running on separate ports :)

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

Configuring User's/Administrator's Access:
``````````````````````````````````````


Add and Remove domains:
````````````````````````


Customize the Portal:
```````````````````




Credits:
Flavio E. Goncalves http://www.sermyadmin.org/
Michel Spice who is my friend/teacher/supporter.
My family who is very supportive, my wife who lets me work late night :)