Monday, October 18, 2010

bash script for Qmail&Vpopmail Uers Quota Refresh - Version 2


#!/bin/sh
#Author: Tanveer Hussain Khan(tanveerhk@hotmail.com)
#Function:Referesh User Quota for all user and domain for qmmail and vpopmail #output=$(/usr/local/bin/mysql --password=rootpassword --exec="select pw_name,pw_domain,pw_shell from vpopmaildb.vpopmail")

/bin/date
echo "Going Referesh Quota For All Users & Domains"
output=$(/usr/bin/mysql --exec="select pw_name,pw_domain,pw_shell from vpopmaildb.vpopmail")

array=$(echo $output | tr " " "\n")
record=""
x=0
for a in $array
do
      record[x]=$a
      let "x+=1"
done

let "count=$x-1"
for ((i=3;i<=$count;i+=3))
do
      let "name=$i"
      let "domain=$i+1"
      let "quota=$i+2"
#     echo "Setting Quota To ${record[$quota]} For User ${record[$name]}@${record[$domain]}"
#     echo ${record[$name]}@${record[$domain]} ${record[$quota]}
#     echo "/var/qmail/vpopmail/bin/vsetuserquota ${record[$name]}@${record[$domain]} ${record[$quota]}"
      /var/qmail/vpopmail/bin/vsetuserquota ${record[$name]}@${record[$domain]} ${record[$quota]} done

/bin/date
echo "Quota Refereshed For All Users & Domains"
echo "***********************************************************"

Saturday, October 2, 2010

bash script for Qmail&Vpopmail Uers Quota Refresh

#!/bin/sh
#Author: Tanveer Hussain Khan
#Function:Referesh User Quota for all user and domain for qmmail and vpopmail
#output=$(/usr/local/bin/mysql --password=rootpassword --exec="select pw_name,pw_domain,pw_shell from vpopmaildb.vpopmail")
output=$(/usr/bin/mysql --exec="select pw_name,pw_domain,pw_shell from vpopmaildb.vpopmail")

array=$(echo $output | tr " " "\n")
record=""
x=0
for a in $array
do
        record[x]=$a
        let "x+=1"
done

let "count=$x-1"
echo $count
for ((i=3;i<=$count;i+=3))
do
        let "name=$i"
        let "domain=$i+1"
        let "quota=$i+2"
        echo "Setting Quota To ${record[$quota]} For User ${record[$name]}@${record[$domain]}"
#       echo ${record[$name]}@${record[$domain]} ${record[$quota]}
#       echo "/var/qmail/vpopmail/bin/vsetuserquota ${record[$name]}@${record[$domain]} ${record[$quota]}
        /var/qmail/vpopmail/bin/vsetuserquota ${record[$name]}@${record[$domain]} ${record[$quota]}
done

Tuesday, June 8, 2010

Install Xwindow, KDE, GNOME, VNC using Yum

you can use yum groupinstall command to install these package at once. but for that you need a good internet connection. here is the complete command.

yum -y groupinstall "X Window System" "GNOME Desktop Environment" "KDE Desktop Environment"


if you have internet connection then it a magic :-) command and will install all dependencies at one and you dont need much struggle to run the Graphical Desktop Environment(KDE/GNOME).

Monday, May 31, 2010

TrixBox Web Authentication

/etc/trixbox/httpdconf/trixbox.conf is the trixbox webauthentication file. its sample is given below you can modify it according to your requirement. it use htaccess method to restrict the contents.


cat  /etc/trixbox/httpdconf/trixbox.conf
#Password protect /var/www/html/admin


AuthType Basic
AuthName "Restricted Area"
AuthUserFile /usr/local/apache/passwd/wwwpasswd
Require user wwwadmin maint

 #Password protect /var/www/html/maint

AuthType Basic
AuthName "Restricted Area"
AuthUserFile /usr/local/apache/passwd/wwwpasswd
Require user maint



AllowOverride All

Wednesday, May 26, 2010

RAM Disk Creation & Mount

What Is RAM Disk? RAM disk is the portion for ram which acts as the hard disk. For that we allocate some portion for ram and then mount it. below are the configurations tested on CentOS 5.2

You can configure and mount RAM Disk using the following procedure.

1. In /etc/grub.conf add the option that is highlited in the below kernel line.

title CentOS (2.6.18-164.el5PAE)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-164.el5PAE ro root=LABEL=/ rhgb quiet ramdisk_size=524288
        initrd /initrd-2.6.18-164.el5PAE.img

2. now edit the /etc/rc.d/rc.local and put the below line
####### RAM DISK #######################
mkfs -t ext3 /dev/ram0 # it will formate the ramdisk
mount -t ext3 /dev/ram0 /var/spool/asterisk/monitor # it will mount ramdisk to mount point /var/spool/asterisk/monitor

Wednesday, May 19, 2010

Asterisk Perl AGI

Below is the sample AGI scrip written in per perl.
In This Script You will learn the following
1. How to write AGI concept.
2. Some Perl Programming.(Variables, Arithmetic Operator, IF/ELSE/ELSIF , comparision operators, Labels etc.
3. How to use mysql queries in AGI using perl.
4. Asterisk Application Used( NoOp, SayDigits, SayNumber, Channel Variables, SayUnixTimeStamp etc)

#!/usr/bin/perl
# MODULE
use Time::Local;
use Asterisk::AGI;
use Mysql;

# CONFIG VARIABLES
$host = "localhost";
$database = "testdb";
$user = "root";
$pw = "JustForFun";

# MYSQL CONNECT
$connect = Mysql->connect($host, $database, $user, $pw);

# SELECT A DATABASE
$connect->selectdb($database);

# create agi instance
$AGI = new Asterisk::AGI;

$AGI->exec("NoOP","\----OnlineInquirySystem----\"");
$AGI->exec("Playback","custom/inquiry-thankyou");
Repeapt1:
$AGI->exec("Read","\option,custom/inquiry-tocheck,1,,,\"");
$option = $AGI->get_variable(option);

if ($option == 1 or $option == 2)
{
    EnterCheque:
    $AGI->exec("Read","cheque,custom/inquiry-pleaseenter,15,,,");
    $cheque = $AGI->get_variable(cheque);
    AfterCheque:
    $AGI->exec("NoOP","**$cheque**");
    if (length($cheque) == 10)
    {
    $AGI->exec("Playback","custom/inquiry-waitforinformation");
    $query="Select evttype_fk, issue_dtt,amount,inst_pk from lpsinst where check_no='$cheque'";
    $execute= $connect->query($query);
    @results=$execute->fetchrow();
    $AGI->exec("NoOP","=====================================");
    $AGI->exec("NoOP","**$results[0]**");
    $AGI->exec("NoOP","=====================================");
    if ($results[0] > 0)
    {
    $AGI->exec("NoOP","**CheckFound**");
    $evttype=$results[0];
    $issuedtt=$results[1];
    $amount=$results[2];
    $inst_pk=$results[3];
    $issueyear=substr $issuedtt,0,4;
    $issuemonth=substr $issuedtt,5,2;
    $issueday=substr $issuedtt,8,2;
    $issuehour=substr $issuedtt,11,2;
    $issueminute=substr $issuedtt,14,2;
    $issuesecond=substr $issuedtt,17,2;
    $AGI->exec("NoOP","$issuedtt");
    $AGI->exec("NoOP","$issueyear-$issuemonth-$issueday-$issuehour:$issueminute:$issuesecond");
    $issueutc=timelocal($issuesecond,$issueminute,$issuehour,$issueday,$issuemonth,$issueyear);
    $AGI->exec("NoOP","$issueutc");
    $bfd=length($amount) - 3;
        $afd= $bfd + 1;
        $dollars=substr $amount,0,$bfd;
        $cents=substr $amount,$afd,2;
    $AGI->exec("NoOP","D-$dollars");
    $AGI->exec("NoOP","C-$cents");
  
        if ($evttype == 3)
        {
        $AGI->exec("Playback","custom/inquiry-chequenumber");
        $AGI->exec("SayDigits","$cheque");
        $AGI->exec("Playback","custom/inquiry-wasissuedon");
        $AGI->exec("SayUnixTime","$issueutc,CET,BdY");
        $AGI->exec("Playback","custom/inquiry-amountof");
        $AGI->exec("SayNumber","$dollars");
        $AGI->exec("Playback","dollars");
        $AGI->exec("SayNumber","$cents");
        $AGI->exec("Playback","cents");
        $AGI->exec("PlayBack","custom/inquiry-nofurtherinfo");
        SecondOption:
                $AGI->exec("Read","\option,custom/inquiry-tocheck-2,1,,,\"");
                $option = $AGI->get_variable(option);
            if ($option == 1 or $option == 2)
                {
                goto Repeapt1;
                } elsif ($option == 3)
                    {
                    goto TalkToSupport;
                    } elsif($option == 4)
                        {
                        goto SecondOption;  
                        } elsif($option == 5)
                                                    {
                            EndCall:
                            $AGI->exec("Playback","custom/inquiry-thankforcalling");
                                                    goto END;
                                                    } else
                                {
                                $AGI->exec("Playback","custom/inquiry-invalidoption");
                                goto SecondOption;
                                }
      
      
        } elsif ($evttype == 4)
        {
        $query="select evt_dtt from lpshistory where inst_fk='$inst_pk' and evttype_fk=4";
            $execute= $connect->query($query);
            @results=$execute->fetchrow();
            $evtdtt=$results[0];
        $evtyear=substr $evtdtt,0,4;
            $evtmonth=substr $evtdtt,5,2;
            $evtday=substr $evtdtt,8,2;
            $evthour=substr $evtdtt,11,2;
            $evtminute=substr $evtdtt,14,2;
            $evtsecond=substr $evtdtt,17,2;
            $AGI->exec("NoOP","$issuedtt");
            $AGI->exec("NoOP","$evtsecond-$evtminute-$evthour-$evtday-$evtmonth-$evtyear");
            $evtutc=timelocal($evtsecond,$evtminute,$evthour,$evtday,$evtmonth,$evtyear);
        $AGI->exec("Playback","custom/inquiry-chequenumber");
                $AGI->exec("SayDigits","$cheque");
                $AGI->exec("Playback","custom/inquiry-wasissuedon");
                $AGI->exec("SayUnixTime","$issueutc,CET,BdY");
                $AGI->exec("Playback","custom/inquiry-amountof");
                $AGI->exec("SayNumber","$dollars");
                $AGI->exec("Playback","dollars");
                $AGI->exec("SayNumber","$cents");
                $AGI->exec("Playback","cents");
        $AGI->exec("Playback","custom/inquiry-wasvoidedon");
        $AGI->exec("SayUnixTime","$evtutc,CET,BdY");
        goto SecondOption;
        } elsif ($evttype == 5)
                {
                $query="select evt_dtt from lpshistory where inst_fk='$inst_pk' and evttype_fk=5";
                $execute= $connect->query($query);
                @results=$execute->fetchrow();
                $evtdtt=$results[0];
                $evtyear=substr $evtdtt,0,4;
                $evtmonth=substr $evtdtt,5,2;
                $evtday=substr $evtdtt,8,2;
                $evthour=substr $evtdtt,11,2;
                $evtminute=substr $evtdtt,14,2;
                $evtsecond=substr $evtdtt,17,2;
                $AGI->exec("NoOP","$issuedtt");
                $AGI->exec("NoOP","$evtsecond-$evtminute-$evthour-$evtday-$evtmonth-$evtyear");
                $evtutc=timelocal($evtsecond,$evtminute,$evthour,$evtday,$evtmonth,$evtyear);
                $AGI->exec("Playback","custom/inquiry-chequenumber");
                $AGI->exec("SayDigits","$cheque");
                $AGI->exec("Playback","custom/inquiry-wasissuedon");
                $AGI->exec("SayUnixTime","$issueutc,CET,BdY");
                $AGI->exec("Playback","custom/inquiry-amountof");
                $AGI->exec("SayNumber","$dollars");
                $AGI->exec("Playback","dollars");
                $AGI->exec("SayNumber","$cents");
                $AGI->exec("Playback","cents");
                $AGI->exec("Playback","custom/inquiry-wasredeemedon");
                $AGI->exec("SayUnixTime","$evtutc,CET,BdY");
        goto SecondOption;
                } elsif ($evttype == 6)
        {
        $query="select evt_dtt from lpshistory where inst_fk='$inst_pk' and evttype_fk=6";
                $execute= $connect->query($query);
                @results=$execute->fetchrow();
                $evtdtt=$results[0];
                $evtyear=substr $evtdtt,0,4;
                $evtmonth=substr $evtdtt,5,2;
                $evtday=substr $evtdtt,8,2;
                $evthour=substr $evtdtt,11,2;
                $evtminute=substr $evtdtt,14,2;
                $evtsecond=substr $evtdtt,17,2;
                $AGI->exec("NoOP","$issuedtt");
                $AGI->exec("NoOP","$evtsecond-$evtminute-$evthour-$evtday-$evtmonth-$evtyear");
                $evtutc=timelocal($evtsecond,$evtminute,$evthour,$evtday,$evtmonth,$evtyear);
                $AGI->exec("Playback","custom/inquiry-chequenumber");
                $AGI->exec("SayDigits","$cheque");
                $AGI->exec("Playback","custom/inquiry-wasissuedon");
                $AGI->exec("SayUnixTime","$issueutc,CET,BdY");
                $AGI->exec("Playback","custom/inquiry-amountof");
                $AGI->exec("SayNumber","$dollars");
                $AGI->exec("Playback","dollars");
                $AGI->exec("SayNumber","$cents");
                $AGI->exec("Playback","cents");
                $AGI->exec("Playback","custom/inquiry-wasstopedon");
                $AGI->exec("SayUnixTime","$evtutc,CET,BdY");
        goto SecondOption;
                } elsif ($evttype == 7)
                {
        $query="select evt_dtt from lpshistory where inst_fk='$inst_pk' and evttype_fk=7";
                $execute= $connect->query($query);
                @results=$execute->fetchrow();
                $evtdtt=$results[0];
                $evtyear=substr $evtdtt,0,4;
                $evtmonth=substr $evtdtt,5,2;
                $evtday=substr $evtdtt,8,2;
                $evthour=substr $evtdtt,11,2;
                $evtminute=substr $evtdtt,14,2;
                $evtsecond=substr $evtdtt,17,2;
                $AGI->exec("NoOP","$issuedtt");
                $AGI->exec("NoOP","$evtsecond-$evtminute-$evthour-$evtday-$evtmonth-$evtyear");
                $evtutc=timelocal($evtsecond,$evtminute,$evthour,$evtday,$evtmonth,$evtyear);
                $AGI->exec("Playback","custom/inquiry-chequenumber");
                $AGI->exec("SayDigits","$cheque");
                $AGI->exec("Playback","custom/inquiry-wasissuedon");
                $AGI->exec("SayUnixTime","$issueutc,CET,BdY");
                $AGI->exec("Playback","custom/inquiry-amountof");
                $AGI->exec("SayNumber","$dollars");
                $AGI->exec("Playback","dollars");
                $AGI->exec("SayNumber","$cents");
                $AGI->exec("Playback","cents");
                $AGI->exec("Playback","custom/inquiry-wasstopedandvoidedon");
                $AGI->exec("SayUnixTime","$evtutc,CET,BdY");
        goto SecondOption;
                } elsif ($evttype == 11 or $evttype == 12)
                {
        $query="select evt_dtt from lpshistory where inst_fk='$inst_pk' and evttype_fk=11 or evttype_fk=12";
                $execute= $connect->query($query);
                @results=$execute->fetchrow();
                $evtdtt=$results[0];
                $evtyear=substr $evtdtt,0,4;
                $evtmonth=substr $evtdtt,5,2;
                $evtday=substr $evtdtt,8,2;
                $evthour=substr $evtdtt,11,2;
                $evtminute=substr $evtdtt,14,2;
                $evtsecond=substr $evtdtt,17,2;
                $AGI->exec("NoOP","$issuedtt");
                $AGI->exec("NoOP","$evtsecond-$evtminute-$evthour-$evtday-$evtmonth-$evtyear");
                $evtutc=timelocal($evtsecond,$evtminute,$evthour,$evtday,$evtmonth,$evtyear);
                $AGI->exec("Playback","custom/inquiry-chequenumber");
                $AGI->exec("SayDigits","$cheque");
                $AGI->exec("Playback","custom/inquiry-wasissuedon");
                $AGI->exec("SayUnixTime","$issueutc,CET,BdY");
                $AGI->exec("Playback","custom/inquiry-amountof");
                $AGI->exec("SayNumber","$dollars");
                $AGI->exec("Playback","dollars");
                $AGI->exec("SayNumber","$cents");
                $AGI->exec("Playback","cents");
                $AGI->exec("Playback","custom/inquiry-wasescheatedon");
                $AGI->exec("SayUnixTime","$evtutc,CET,BdY");
        goto SecondOption;
                } else
        {
        $AGI->exec("Playback","custom/inquiry-chequenumber");
        $AGI->exec("SayDigits","$cheque");
        $AGI->exec("NoOP","**$cheque**");
        NoValidStatus:
        $AGI->exec("Read","\option,custom/inquiry-wasnotfoundtry,1,,,\"");
        $option = $AGI->get_variable(option);
        if ($option == 1)
            {
            goto EnterCheque;
            } elsif ($option == 2)
            {
            goto TalkToSupport;
            }  elsif ($option == 3)
                        {
                        goto EndCall;
                        } else
            {
            $AGI->exec("Playback","custom/inquiry-invalidoption");
            goto  NoValidStatus;
            }
      
        }

    } else
            {
        $AGI->exec("NoOP","**====CheckNotFound====**");
        $AGI->exec("Playback","custom/inquiry-chequenumber");
            $AGI->exec("SayDigits","$cheque");
            $AGI->exec("NoOP","**$cheque**");
            RepeatNotFound:
            $AGI->exec("Read","option,custom/inquiry-wasnotfoundtry,1,,,");
            $option = $AGI->get_variable(option);
            if ($option == 1)
            {
                goto EnterCheque;
                } elsif ($option == 2)
                    {
                        goto TalkToSupport;
                        }  elsif ($option == 3)
                            {
                            goto EndCall;
                            } else
                                {
                            $AGI->exec("Playback","custom/inquiry-invalidoption");
                            goto  RepeatNotFound;
                                }

  
        }

    } else
    {
    $AGI->exec("Read","cheque,custom/inquiry-rentercheque,15,,,");
    $cheque = $AGI->get_variable(cheque);
    goto AfterCheque;
    }

} elsif ($option == 3)
    {
    TalkToSupport:
    $AGI->exec("Playback","custom/inquiry-pleasehold");
    goto END;
    } elsif ($option == 4)
        {
        goto Repeapt1;
        } else
            {
            $AGI->exec("Playback","custom/inquiry-invalidoption");
            goto Repeapt1;
            }
      
END:

Thursday, February 25, 2010

Alcatel 1000MM E10 Operations & Maintenance

We will discuss Alcatel Daily Operation & Maintenence Here.
Comming Soon.........................................................................

Emails and Their Replies

shaukat ali has sent you a message.
Date: 2/24/2010
Subject: RE: Solutions/Help/HowTos On Asterisk/Billing/Telecom/IT/System Related Issues
Daer Tanveer:
This is the issue.The provider in Pakistan do not allow this.Thank you any way.
shaukat
-------------------------------------------------------------------
On 02/24/10 12:45 PM, Tanveer Hussain Khan wrote:
--------------------
Dear Shaukat Ali,

thanks for writing me.you can change cli in asterisk by changing the CALLERID variable but for this you should have the privileges from you pri provider. most provide does not allow that. if you change/off cli, they will send your PRI master number to the called party.
---------------------------------------------------------------------
On 02/24/10 12:03 AM, shaukat ali wrote:
--------------------
how to control/change/off cli on ISDN PRI card from Asterisk while it is on in central office

Saturday, February 20, 2010

Alcatel 1000 MM E10

Alcatel 1000 MM E10 is a Next Generation Telecom Switch. The Alcatel 1000 MM E10 with MGC has been specifically designed to address the migration strategy of established service providers (ESPs) currently running Alcatel 1000 E10-based networks. With the MGC operators can handle simultaneously TDM and next generation network (NGN) traffic.

Technical specifications:Multi-service
- One equipment able to perform all functions
- Fixed or mobile, local or transit
Modular and scalable
- Applicable to both capacity and functions
Compatibility
- Hardware and software evolving independently
Quality of service
- Same level of service for voice over circuit (PSTN) or voice over packet
Service guarantee
- Preserving the revenue generated by carrier grade services like IN
Service enhancement
- Packet capacity enabling future services
Billing
- Facilitated billing through the generation of CDRs for any type of communications - circuit or packet
Interoperability
- Guaranteeing interoperability between national and international data networks
High capacity
- Integrated high capacity terminations such as SDH STM1.

SS7 BOX Software Installation

1. Install CentOS-5.4 Operating System on the system.
2. download source of asterisk,dahdi,libpri,asterisk-adons from www.asterisk.org
3. untar the sources one by one.
4. compile and install the sources one by one.


for compilation and installation go to each source directory and run the following command
1-  ./configure
2-  make
3-  make install
4-  follow on screen instructions.


in next chapter will will configure it as a IP PBX with single PRI card and then in next chapter will configure this is SS7 Box/ Signalling Gateway

Thursday, February 18, 2010

SS7 BOX Hardware and Price

1. Intel ATOM Dual Core .................6500
2. RAM 512 MB.................................1300
3. USB Stick(Kinston 8-GB).................850
4. Casing (Mini ATX).........................1880
-----------------------------------------------------------------------------
Total.................................................10530 PKR
------------------------------------------------------------------------------
Digiup TE100P Card........................45000
------------------------------------------------------------------------------
Grand Total......................................55530 PRK
------------------------------------------------------------------------------



Operating System.............................CentOS 5.4

What is SS7 BOX

SS7 Box is a computer running Linux OS(CentOS-5.4) and Asterisk from 4GB usb, on intel ATOM process with TE100p Digium Single PRI Card. this is realy low cost ss7 box / Signalling Gateway. It will cost you about 60K PKR. i will discuss its complete hardware and software configuration and installation process in my later posts. This can also be use as IP PBX with a single pri card. guys it would be a great box with low cost and enriched featured. Comming Soon...............