Archive for July, 2011

Call Forwarding from outside the office

See the previous call forward setup.  Use the same setup and append the below lines to /etc/asterisk/extensions_custom.conf , change the numbers to where you want to enable call forwarding(ie. the your mobile number from where you pick up the forwarded call)  and reload asterisk. Dial your office number from your mobile when you reach IVR dial 9 which will enable call forwarding . Now all calls to your office are forwarded to your mobile.

[ivr-5-custom]
exten => 9,1,NoOP(${CALLERID(num)})
exten => 9,n,GotoIf($["${CALLERID(num)}" = "0X5X8X0X2X" || "${CALLERID(num)}" = "05X9X4X8XX"]?cact)
exten => 9,n,Goto(ivr-5,s,1)
exten => 9,n(cact),Goto(from-internal,*${CALLERID(num)},1)

, , , , , , , , , , ,

1 Comment

Asterisk 1.4:Call forwarding(Follow Me) – With Music On Hold-MeetMe-Without delay

When we use follow-me in FreePBX with our mobile number as the follow-me extension, the caller will hear the ring back sound when the PBX dials our mobile number.  If we are using analog lines to forward the calls even the Dial command with m option(Music On Hold) will not work in this situation.

Here I’m using  meet-me application asterisk call file  and some dial plan manipulation to do the task. All the calls from PSTN(analog lines) to IVR will be forwarded to mobile number. Create conference extension from FreePBX GUI ,create IVR and route the calls to conference number from IVR. Add a 3rd IVR and route the calls from that to same conference number., In third IVR you can add some voice menu like “You have received a call please dial 0 to accept the call” so that when we receive the forwarded call we can dial 0 and connect caller. The forward number will be dialed as soon as the  incoming call reaches PBX. So the call connection delay will be minimum.

First I’ve made a dial plan to Activate/Deactivate call forwarding. To enable/disable (toggle) call forwarding you have to dial * followed by your mobile number from your extension. Find below the dialplan. Put this into /etc/asterisk/extension.conf under [from-internal] context. Here it is 10 digit number starting with a preceding 0.

[from-internal]
exten => _*0XXXXXXXXX,1,NoOP(${DB(AMPUSER/followme)})
exten => _*0XXXXXXXXX,n(start),Answer
exten => _*0XXXXXXXXX,n,Wait(1)
exten => _*0XXXXXXXXX,n,Macro(user-callerid,)
exten => _*0XXXXXXXXX,n,GotoIf($["${DB(AMPUSER/followme)}" = "0"]?activate)
exten => _*0XXXXXXXXX,n(deactivate),Set(DB(AMPUSER/followme)=0)
exten => _*0XXXXXXXXX,n,Playback(followme&de-activated)
exten => _*0XXXXXXXXX,n(end),Macro(hangupcall,)
exten => _*0XXXXXXXXX,n(activate),Set(DB(AMPUSER/followme)=${EXTEN:1})
exten => _*0XXXXXXXXX,n,Playback(followme&activated)
exten => _*0XXXXXXXXX,n(end),Macro(hangupcall,)

Create a sh script make it executable,make asterisk as its owner and save it as “/va/lib/asterisk/bin/clfwd.sh” . This file make a call to your mobile when a new call arrives.

#!/bin/bash
echo -e "Channel: DAHDI/16/$1\nMaxRetries: 2\nRetryTime: 60\nWaitTime: 45\nContext: ivr-7\nExtension: s" > /tmp/$1.call
chmod 777 /tmp/$1.call
mv /tmp/$1.call /var/spool/asterisk/outgoing/

Edit the file /etc/asterisk/extension_additional.conf and add the below line under the context [from-pstn-custom]. Create the context [ from-pstn-custom] if it doesn’t exists.

[from-pstn-custom]
exten => s,1,Noop(Entering FAX Detection)
exten => s,n,Ringing()
exten => s,n,Set(DID=${IF($["${DID**"= ""]?s:${DID**)**)
exten => s,n,Noop(DID is now ${DID**)
exten => s,n,Set(CHAN=${CHANNEL:6})
exten => s,n,Set(CHAN=${CUT(CHAN,-,1)})
exten => s,n,GotoIf($["${CHAN}" = "18"]?fax:ivr)
exten => s,n(fax),Goto(ext-fax-custom,s,1)
exten => s,n(ivr),NoOP(${DB(AMPUSER/followme)})
;exten => s,n,Set(CFNO = "${DB(AMPUSER/followme)}")
exten => s,n,GotoIf($["${DB(AMPUSER/followme)}" != "0"]?active)
exten => s,n,Goto(ivr-5,s,1)
exten => s,n,Hangup()
exten => s,n(active),Wait(2)
exten => s,n,ChanIsAvail(DAHDI/16)  ;checks if the line to forward the call is already busy.
exten => s,n,Set(CHANAV=${AVAILORIGCHAN})
exten => s,n,GotoIf($["${CHANAV}" = ""]?active)
exten => s,n,system(/var/lib/asterisk/bin/clfwd.sh ${DB(AMPUSER/followme)})
exten => s,n,Goto(ivr-7,s,1)
exten => s,n,Hangup()
exten => fax,1,Goto(ext-fax-custom,s,1)

Enable call forwarding by dialing your number with preceding *.

Make a call to your PBX . The PBX makes a call to your mobile. Accept the call and dial 0 to connect the caller.

Find below the other configurations by FreePBX GUI.

;extension_additional.conf

[ext-meetme]
include => ext-meetme-custom
exten => STARTMEETME,1,MeetMe(${MEETME_ROOMNUM},${MEETME_OPTS},${PIN})
exten => STARTMEETME,n,Hangup
exten => h,1,Hangup
exten => 696,1,Macro(user-callerid,)
exten => 696,n,Set(MEETME_ROOMNUM=696)
exten => 696,n,Set(MEETME_RECORDINGFILE=${ASTSPOOLDIR}/monitor/meetme-conf-rec-${MEETME_ROOMNUM}-${UNIQUEID})
exten => 696,n,GotoIf($["${DIALSTATUS}" = "ANSWER"]?USER)
exten => 696,n,Answer
exten => 696,n,Wait(1)
exten => 696,n(USER),Set(MEETME_OPTS=qMsr)
exten => 696,n,Goto(STARTMEETME,1)
exten => 696,hint,MeetMe:696
[ivr-5]
include => ivr-5-custom
include => from-did-direct-ivr
include => app-directory
exten => #,1,dbDel(${BLKVM_OVERRIDE})
exten => #,n,Set(__NODEST=)
exten => #,n,Goto(app-directory,#,1)
exten => h,1,Hangup
exten => s,1,Set(MSG=custom/ePillars_IVR)
exten => s,n,Set(LOOPCOUNT=0)
exten => s,n,Set(__DIR-CONTEXT=default)
exten => s,n,Set(_IVR_CONTEXT_${CONTEXT}=${IVR_CONTEXT})
exten => s,n,Set(_IVR_CONTEXT=${CONTEXT})
exten => s,n,GotoIf($["${CDR(disposition)}" = "ANSWERED"]?begin)
exten => s,n,Answer
exten => s,n,Wait(1)
exten => s,n(begin),Set(TIMEOUT(digit)=3)
exten => s,n,Set(TIMEOUT(response)=10)
exten => s,n,Set(__IVR_RETVM=)
exten => s,n,ExecIf($["${MSG}" != ""],Background,${MSG})
exten => s,n,WaitExten(,)
exten => hang,1,Playback(vm-goodbye)
exten => hang,n,Hangup
exten => 0,1,dbDel(${BLKVM_OVERRIDE})
exten => 0,n,Set(__NODEST=)
exten => 0,n,Goto(from-did-direct,603,1)
exten => 1,1,dbDel(${BLKVM_OVERRIDE})
exten => 1,n,Set(__NODEST=)
exten => 1,n,Goto(from-did-direct,603,1)
exten => 2,1,dbDel(${BLKVM_OVERRIDE})
exten => 2,n,Set(__NODEST=)
exten => 2,n,Goto(from-did-direct,603,1)
exten => 3,1,dbDel(${BLKVM_OVERRIDE})
[ivr-6]
include => ivr-6-custom
include => from-did-direct-ivr
include => app-directory
exten => #,1,dbDel(${BLKVM_OVERRIDE})
exten => #,n,Set(__NODEST=)
exten => #,n,Goto(app-directory,#,1)
exten => h,1,Hangup
exten => s,1,Set(MSG=custom/ePillars_IVR)
exten => s,n,Set(LOOPCOUNT=0)
exten => s,n,Set(__DIR-CONTEXT=default)
exten => s,n,Set(_IVR_CONTEXT_${CONTEXT}=${IVR_CONTEXT})
exten => s,n,Set(_IVR_CONTEXT=${CONTEXT})
exten => s,n,GotoIf($["${CDR(disposition)}" = "ANSWERED"]?begin)
exten => s,n,Answer
exten => s,n,Wait(1)
exten => s,n(begin),Set(TIMEOUT(digit)=3)
exten => s,n,Set(TIMEOUT(response)=10)
exten => s,n,Set(__IVR_RETVM=)
exten => s,n,ExecIf($["${MSG}" != ""],Background,${MSG})
exten => s,n,WaitExten(,)
exten => hang,1,Playback(vm-goodbye)
exten => hang,n,Hangup
exten => 0,1,dbDel(${BLKVM_OVERRIDE})
exten => 0,n,Set(__NODEST=)
exten => 0,n,Goto(ext-meetme,696,1)
exten => 1,1,dbDel(${BLKVM_OVERRIDE})
exten => 1,n,Set(__NODEST=)
exten => 1,n,Goto(ext-meetme,696,1)
exten => 2,1,dbDel(${BLKVM_OVERRIDE})
exten => 2,n,Set(__NODEST=)
exten => 2,n,Goto(ext-meetme,696,1)

[ivr-7]
include => ivr-7-custom
include => from-did-direct-ivr
include => app-directory
exten => #,1,dbDel(${BLKVM_OVERRIDE})
exten => #,n,Set(__NODEST=)
exten => #,n,Goto(app-directory,#,1)
exten => h,1,Hangup
exten => s,1,Set(MSG=custom/Call)
exten => s,n,Set(LOOPCOUNT=0)
exten => s,n,Set(__DIR-CONTEXT=default)
exten => s,n,Set(_IVR_CONTEXT_${CONTEXT}=${IVR_CONTEXT})
exten => s,n,Set(_IVR_CONTEXT=${CONTEXT})
exten => s,n,GotoIf($["${CDR(disposition)}" = "ANSWERED"]?begin)
exten => s,n,Answer
exten => s,n,Wait(1)
exten => s,n(begin),Set(TIMEOUT(digit)=3)
exten => s,n,Set(TIMEOUT(response)=3)
exten => s,n,Set(__IVR_RETVM=)
exten => s,n,ExecIf($["${MSG}" != ""],Background,${MSG})
exten => s,n,WaitExten(,)
exten => hang,1,Playback(vm-goodbye)
exten => hang,n,Hangup
exten => 0,1,dbDel(${BLKVM_OVERRIDE})
exten => 0,n,Set(__NODEST=)
exten => 0,n,Goto(ext-meetme,696,1)
exten => 1,1,dbDel(${BLKVM_OVERRIDE})
exten => 1,n,Set(__NODEST=)
exten => 1,n,Goto(ext-meetme,696,1)
exten => 2,1,dbDel(${BLKVM_OVERRIDE})
exten => 2,n,Set(__NODEST=)
exten => 2,n,Goto(ext-meetme,696,1)

meetme_additional.conf

conf => 696,

, , , , , , , , , ,

2 Comments

FreePBX – Call Recording and RAMDISK

Asterisk call recording is resource intensive especially when the number of calls in the PBX is high. If you record all the calls directly to the HDD in asterisk  pbx and you got a large call volume (number of calls) then it will damage your PBX’s HDD very soon. On such cases using RAMDISK and seperate HDD may solve the problem.

Install freepbx. If you are not using SAN  use 2 HDDs for better results. One for OS+asterisk and one as a storage for recorded files.  Here I’m using /record as the storage location and  /astrec as the mount point for RAMDISK. Format and mount the 2nd HDD  to /record at the time of OS installation(or create an fstab entry if you are doing it later). After installation give write permission or assign asterisk user as the owner of /record & /astrec.

/bin/chown -R asterisk.asterisk /record
/bin/mkdir  /astrec
/bin/chown -R asterisk.asterisk /astrec

After the freepbx installation edit “/boot/grub/grub.conf” and put the the ramdisk size.

#boot=/dev/hda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Elastix (2.6.18-194.3.1.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-194.3.1.el5 ro root=LABEL=/
ramdisk_size=1000000
initrd /initrd-2.6.18-194.3.1.el5.img

Here I used RAMDISK size as 1GB(1000000) . The size depends on the number of calls,the average time for one call,and the recording format.

Remove the 3 directories from asterisk spool directory because we are going to use ramdisk instead of those.

rm -rf /var/spool/asterisk/monitor
rm -rf /var/spool/asterisk/system
rm -rf /var/spool/asterisk/tmp

Edit the file “/etc/rc.local” and append the  below code.

#Put this in rc.local to create ramdisk during bootup
/sbin/mke2fs -m 0 /dev/ram0
/bin/mount /dev/ram0 /astrec
/bin/mkdir /astrec/monitor
/bin/mkdir /astrec/system
/bin/mkdir /astrec/tmp
/bin/chown -R asterisk.asterisk /astrec
#For more infor on ramdisk:
#http://www.vanemery.com/Linux/Ramdisk/ramdisk.html

#Link asterisk's default folders to our ramdisk
/bin/ln -s /astrec/system /var/spool/asterisk
/bin/ln -s /astrec/tmp /var/spool/asterisk
/bin/ln -s /astrec/monitor /var/spool/asterisk

At the time of booting the above lines in rc.local creates RAMDISK and mount it to “/astrec”.

Create the file “/var/lib/asterisk/agi-bin/mvrec.sh” and put the below contents.

#!/bin/bash
/bin/mv $1/$2.$3 /record 3>&1 1>&2 2>&3 | tee /var/log/asterisk/mvrec.log

The above code will transfer the recorded file from RAMDISK to the location /record., Use the file “/var/log/asterisk/mvrec.log”  for troubleshooting purpose. Make the script executable.

chmod 755 /var/lib/asterisk/agi-bin/mvrec.sh

Log in to freepbx interface and change the General Settings as shown in screen shot.

Extension Recording Override:Enabled
Call recording format:	wav
Recording Location:	/var/spool/asterisk/monitor/
Run after record: /var/lib/asterisk/agi-bin/mvrec.sh ^{MIXMON_DIR} ^{CALLFILENAME} ^{MIXMON_FORMAT}

On FreePBX GUI goto  “Extensions” and select one of the extensions in which you want to enable call recording.

If you are using Elastix change the recording directory in elastix monitoring configuration file.

 /var/www/html/modules/monitoring/configs/default.conf.php
 $arrConfModule['records_dir']       = '/record/';

Select the appropriate recording option.

Try calling between 2 extension after enabling call recording.  See the asterisk cli output. Use the file “/var/log/asterisk/mvrec.log” for troubleshooting.

If you are using specific context other than from-internnal context, don’t forget to add the Macros. For example

[custom-checklock]
exten => _.,1,NoOp(AMPUSER/${CALLERID(num)}/locked)
exten => _.,n,Gotoif($[${DB_EXISTS(AMPUSER/${CALLERID(num)}/locked)}=0]?carryon)
exten => _.,n,Set(PINCOUNT=0)
;exten => _.,n,Set(VALIDPIN=1234)
exten => _.,n(readpin),Read(PIN,vm-password,4,,,4)
exten => _.,n,Gotoif($[${PIN}=${VALIDPIN}]?carryon)
exten => _.,n,Gotoif($[${PIN}=${DB(AMPUSER/${CALLERID(num)}/locked)}]?carryon)
exten => _.,n,Set(PINCOUNT=$[${PINCOUNT}+1])
exten => _.,n,Playback(vm-incorrect)
exten => _.,n,GotoIf($[${PINCOUNT}>2]?h)
exten => _.,n,Wait(1)
exten => _.,n,Goto(readpin)
exten => _.,n(carryon),Set(DB(AMPUSER/${CALLERID(num)}/unlocked)=${PIN})
exten => _.,n,NoOp(${DB_DELETE(AMPUSER/${CALLERID(num)}/locked)})
;exten => _.,n,Dial(DAHDI/g0/${EXTEN})
exten => _.,n,Macro(user-callerid,SKIPTTL,)
exten => _.,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _.,n,Macro(dialout-trunk,2,${EXTEN},)
exten => h,1,Macro(hangupcall,)
;exten => 911,1,Goto(CallingRule_Out39,${EXTEN},1)
;exten => h,1,Hangup

[custom-setlock]
exten => s,1,NoOp(In Set Lock)
exten => s,n,Gotoif($[${DB_EXISTS(AMPUSER/${CALLERID(num)}/unlocked)}=1]?lockit)
exten => s,n,Gotoif($[${DB_EXISTS(AMPUSER/${CALLERID(num)}/locked)}=0]?readit)
exten => s,n,Read(LOCKEY,vm-password,4,,,4)
exten => s,n,Gotoif($[${LOCKEY}=${DB(AMPUSER/${CALLERID(num)}/locked)}]?readit)
exten => s,n,Playback(vm-pls-try-again)
exten => s,n,Hangup
exten => s,n(readit),Read(PIN1,vm-newpassword,4,,,4)
exten => s,n,Read(PIN2,vm-reenterpassword,4,,,4)
exten => s,n,Gotoif($[${PIN1}=${PIN2}]?okey)
exten => s,n,Playback(an-error-has-occured)
exten => s,n,Hangup
exten => s,n(okey),Set(DB(AMPUSER/${CALLERID(num)}/locked)=${PIN1})
exten => s,n,Playback(locked)
exten => s,n,Hangup
exten => s,n(lockit),Set(DB(AMPUSER/${CALLERID(num)}/locked)=${DB(AMPUSER/${CALLERID(num)}/unlocked)})
exten => s,n,NoOp(${DB_DELETE(AMPUSER/${CALLERID(num)}/unlocked)})
exten => s,n,Playback(locked)
exten => h,1,Hangup

[national]
include => from-internal
exten => _XXXXXXXXX,1,Goto(custom-checklock,${EXTEN},1)

[international]
include => from-internal
exten => _XXXX.,1,NoOp(AMPUSER/${CALLERID(num)}/locked)
exten => _XXXX.,n,Goto(custom-checklock,${EXTEN},1)

[mobile]
include => from-internal
exten => 123,1,Goto(custom-setlock,s,1)
exten => _XXXXXXXXX,1,Goto(custom-checklock,${EXTEN},1)
exten => _XXXXXXXXXX,1,Goto(custom-checklock,${EXTEN},1)

[changepw]
exten => s,1,Read(LOCKEY,vm-password,4,,,4)
exten => s,n,Gotoif($[${LOCKEY}=2008]?okey)
exten => s,n,Hangup
exten => s,n(okey),Read(EXTNO,superlock,3,,,4)
exten => s,n,Set(DB(AMPUSER/${EXTNO}/locked)=1234)
exten => s,n,Playback(locked)
exten => h,1,Hangup

, , , , , , , , , , , , , ,

13 Comments

Useful Commands

Show hide My Computer

desk.cpl ,,5

Add motd : Ubuntu

echo -en "\033[1;33m" > /etc/motd
echo " Put your comments here.." >> /etc/motd
echo -en "\033[0m" >> /etc/motd

Esacpe from Ubuntu apt-get Error

sudo sed -i -re 's/([a-z]{2}\.)?archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
sudo apt-get update 

Add XP to Windows 2012 R2 Domain

Open Regedit.exe in Domain Server
Navigate to
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\DependOnService

Original Value: SamSS Srv2

Change to: SamSS Srv
After changing the value, restart “Server Service” on DC

Add the XP client again to Domain.

 

Active Directory Import Contacts

csvde -i -f contacts.csv

DN objectClass givenName telephoneNumber
CN=Shyju Kan, OU=Contacts,DC=company,DC=local contact Shyju 6511933

The CSV contents will be imported to Active Directory under OU Contacts

 

Excel Extract Text

=RIGHT(F2,LEN(F2)-FIND(“=”,F2))

Find and replace word in text files in a directory

sed -i -- 's/dir.cfg/dir.cfg, 000000000000-license.cfg/g' *

It searches for  the text “dir.cfg” and replaces it with “dir.cfg, 000000000000-license.cfg” in current directory.

Remove comments from a file

grep -vE ‘^#|^;|^$’ /etc/openvpn/server.conf >/root/test.conf

IPtables Enable Port 80

Edit the file  /etc/sysconfig/iptables

add the below line

 -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT

Recover USB Drive

Recover USB Drive

chkdsk E: /F /R

Where is E: is the USB drive

Restore Putty  Profile

regedit /e “%userprofile%\desktop\putty-registry.reg” HKEY_CURRENT_USER\Software\Simontatham

Find Directory size in GB : Linux

du -h / | grep ^[0-9.]*G

How add AD users as RDP Users

Add a user group fro remote desktop access and add it to “Remote Desktop Users”. Then goto Group Policy Editor (gpedit.msc) and add this group to “Allow logon through remote desktop services” policy.

RDP_Group Enable_RDP

Install Telnet on Windows 7/8

pkgmgr /iu:"Telnet Client"

Access Systems Under Remote Network through SSH

[root@mylaptop ~]# ssh -N -f -L :10002:192.168.1.119:80 myserver.mine.nu

I want to access a webserver(192.168.1.119) which can not be access from outside.  But I have ssh access to a system(myserver.mine.nu) which is hosted on the same network. Run above command to create a ssh tunnel between your laptop and remote ssh server and port map 80 port from remote webserver to mylaptops 10002 port., so that you can access the remote webserver through http://mylaptop:10002 ( Or if mylatop’s ip is 192.168.1.2, access using URL http://192.168.1.2:10002).

Asterisk Call from CLI

CLI> originate DAHDI/1/4880722 extension 604@from-internal

Convert VMVARE Workstation disk to ESXi Disk

Copy the VMWARE Workstation disk to ESXi Server using vSphere Client from Configuration >> Storage>>datastore1>>Browse Database

Enable SSH from Configuration >> Security Profile >> Firellwall>>Properties

Login to ESXi server using putty.

Goto to the folder path where you copied the Workstation vmdk file. Usually it will come under /vmfs/volumes/datastore1/<newdiskfolder>

vmkfstools -i WSDISK.vmdk -d zeroedthick ESXiDISK.vmdk

Then create a new VM and add the new disk (Eg.  ESXiDISK.vmdk) to the VM and start it.

Change Windows 2008 Password Policy Made Simple

Run the command.
secedit /export /cfg c:\local.cfg
Open c:\local.cfg file with notpad and change
"PasswordComplexity = 0"
"MinimumPasswordLength = 1"
Then run the command
secedit /configure /db %windir%\security\local.sdb /cfg c:\local.cfg /areas SECURITYPOLICY

Windows simple setup file maker

Start>Run>iexpress

Rename multiple files/ Remove characters from beginning of a file name

# for f in monitor*; do mv “$f” “${f#monitor}”;done

Send a command error to file

The following command will put linux command error output to a file.

mv /tmp/dfa /record/ 3>&1 1>&2 2>&3 | tee /tmp/stderr.txt

If  /tmp/dfa does not exists you will get following line in /tmp/stderr.txt file

mv: cannot stat `/tmp/dfa’: No such file or directory

Find Text in a folder 

grep -lir “text to find” *

Steps to Reverse SSH:

 client : Is the Server which is behind nat and  you want to access it without altering firewall configuration.

 Server: Is the machine which can be accessed through WAN(internet).

  1. On the client run the following commands:
    $ mkdir -p $HOME/.ssh
    $ chmod 0700 $HOME/.ssh
    $ ssh-keygen -t dsa -f $HOME/.ssh/id_dsa -P ''

    This should result in two files, $HOME/.ssh/id_dsa (private key) and $HOME/.ssh/id_dsa.pub (public key).

  2. Copy $HOME/.ssh/id_dsa.pub to the server.
    scp ~/.ssh/id_dsa.pub server:
  3. On the server run the following commands:
    $ cat id_dsa.pub >> $HOME/.ssh/authorized_keys2
    $ chmod 0600 $HOME/.ssh/authorized_keys2

    Depending on the version of OpenSSH the following commands may also be required:

    $ cat id_dsa.pub >> $HOME/.ssh/authorized_keys
    $ chmod 0600 $HOME/.ssh/authorized_keys

    An alternative is to create a link from authorized_keys2 to authorized_keys:

    $ cd $HOME/.ssh && ln -s authorized_keys2 authorized_keys
  4. On the client test the results by ssh’ing to the server:
    $ ssh -i $HOME/.ssh/id_dsa server
  5. (Optional) Add the following $HOME/.ssh/config on the client:
    Host server
             IdentityFile ~/.ssh/id_dsa

    This allows ssh access to the server without having to specify the path to the id_dsa file as an argument to ssh each time.

  6. Test the connectivity by ssh. It should not ask for password.
    ssh user@server -p 8022
  7. Put the below command in client’s /etc/rc.local
    nohup ssh -f -N -R 10000:localhost:22 user@server -p 8022
  8. To access the client run following command from the server.
    ssh user@localhost -p 10000

Unzip Multiple files with full path

#for z in *.zip; do 7za x -o/mnt/oebs/oracle/ $z;  done

If you are using command unzip use "unzip $z" instead of  "7za x -o/mnt/oebs/oracle/ $z;"
Another Option
#!/bin/bash
for zipfile in `ls /mnt/c/zipfiles/*.zip`; do unzip -o $zipfile -d /extracted/;
done
linux Find physical memory module installed in each memory slot
dmidecode --type 17
Enable x86 processors to access more than 4 GB of physical memory for Windows

Windows Server 2003 and Windows XP/2000:  To enable PAE, use the /PAE switch in the boot.ini file. To disable PAE, use the /NOPAE switch. To disable DEP, use the /EXECUTE switch.

bcdedit /set  pae ForceEnable

PAE is only used in 32 bit Windows versions. 32 GB is the limit for 64 bit Windows 2003 Standard Edition.

In 32-bit Windows running on x64-based systems, PAE also enables several advanced system and processor features, including hardware-enabled Data Execution Prevention (DEP), non-uniform memory access (NUMA), and the ability to add memory to a system while it is running (hot-add memory).

SumatraPDF: Change Background color 

C:\Program Files\SumatraPDF>SumatraPDF.exe -bg-color #999999

Bash Commands

URL : http://www.quora.com/Linux/What-are-the-useful-shortcut-keys-that-one-must-use-in-bash

I have quite a few favorites that save a ton of time in the terminal. Here are some of them:

1) Ctrl+r (reverse-i-search)
For all those times when you’ve typed a looooooong command into terminal sometime in the past, and remember only fragements of it, this is a huge timesaver. Just type Ctrl+r and type the fragement you remember, and the terminal “remembers” the command you typed. If you remember a command that was used just before or after the command you need, use Ctrl+R to find the command you remember and then scroll through your history using Ctrl+n (to move forward) or Ctrl+p (to move back). You can also use a similar command of ‘history’ to search history, but Ctrl+r, for me atleast is superior in every way.

2) !! (repeat last command)
Especially useful when running the same process over and over, !! simply performs the last command. This is especially useful when you run a command that needs root privileges, but you forgot to provide it, then you can just do sudo !! to run the same command with root priviledges

3)Ctrl+a,Ctrl+e, Alt+f, Alt+b (terminal command moverments)
These four commands are commands everyone on a terminal should learn to save endless hours spent traversing through commands to correct typos or arguments. Here’s the breakdown:
Ctrl+a : Goto beginning of command
Ctrl+e: Goto end of line
Alt+f : Move forward one word
Alt+b: Go backward one word
Protip: Mac Users, set your option key to be used as meta key ( in terminal preference) to be able to use the Alt commands

4)Ctrl+u, Ctrl+k (Deletions)
Deletion is always a matter of contention for people who’re new to the terminal. Most of them are used to the world of Ctrl+a -> Del to select and delete everything, that the terminal seems daunting. Fear not, for you can use Ctrl+u to delete everything you’ve typed out, or the nifty Ctrl+k to delete everything that comes after the current cursor position 🙂

5) TAB (Autocompletion)
This is easily the most widely used Terminal shortcut, and in many ways, the most effective. Tab is magical in it’s working, especially when working with files names abcdefg-54321-cmd-logs-journal-tabs.log, where you can just type an ‘a’ and press tab to autocomplete the filename. Traversing through folders is a breeze thanks to Tab, and the fact that it uses a very smart autocompletion scheme (eg. if you have files named abcd-1234.log and abcd-1235.log, and type ‘a’ followed by tab, it autocompletes till ‘abcd-123′, which is the common substring of both files’) makes this very useful

Ofcourse, there are many more shortcuts to learn to use, but once you learn a set of commands you’re comfortable with (and which you use often), both speed and productivity through the terminal increases exponentially. (And, superspeed alongside a green text on black terminal will get you the occasional ‘ooh, you’re just like Neo from the Matrix’ comments from people around you 😉 )
Traversing the Command
ctrl+f to go forward
ctrl+b to go backward
ctrl+a to go start of the line
ctrl+e to go end of the line
ctrl+p to go previous command
ctrl+n to go next command
ctrl+w to delete word backward
ctrl+k to delete from cursor to end of line
ctrl+d to delete letter under cursor
ctrl+l to clear the screen
ctrl+r increment search backwards, use ctrl+r to go next.
Ctrl + a : Go to the beginning of the line (Home)
Ctrl + e : Go to the end of the line ( End )
Alt + b : Back one word on Left
Alt + f : Forward one word on right

Ctrl + l : Clear the screen

Ctrl + p and Ctrl + n : walk back in history command in backward and forward respectively.

Alt + . : Use last word of previous command
Ctrl + t : swap the last two characters before the cursor. (typo)

Tab : Auto completion. [Everyone knows this 😛 ]

kill all running PHP processes you can type kill $(pidof php) to do it fast

RPM

Find the rpm of installed binary.

rpm -qf `which kinit`

How to find PCI / PCIe Slot information linux command

# dmidecode –type 9

Installing PHP from source on CentOS x86_64 (w/ apache)

Installing PHP from source is much easier than most people think. In this tutorial I will describe how to install a bare PHP build with mysql/mysqli support in addition to configuring apache to interpret PHP scripts.

Compiling PHP Source

Alright, well in order to compile the php source code you must first have gcc install (# yum install gcc). Also if you want to be able to use PHP in apache then you need to have httpd and httpd-devel packages installed. Here is how I did my install. (Please note that I used PHP 5.2.6 for my install, but this will work with just about any php version, just be sure to untar and cd into the proper directory for your version of php.)

1
2
3
4
5
6
7
8
[root@nitrogen ~]# yum install gcc-c++ httpd httpd-devel apr-devel libxml2-devel zlib zlib-devel mysql-devel openssl-devel
[root@nitrogen ~]# tar -zxvf php-5.2.6.tar.gz
[root@nitrogen ~]# cd php-5.2.6
[root@nitrogen cd php-5.2.6]# ./configure –with-config-file-path=/etc –with-config-file-scan-dir=/etc/php.d –with-apxs2 –with-libdir=lib64  –with-mysql –with-mysqli –with-zlib
[root@nitrogen cd php-5.2.6]# make clean
[root@nitrogen cd php-5.2.6]# make
[root@nitrogen cd php-5.2.6]# make install

You’re also going to want to place a php.ini into /etc/php.ini and make the /etc/php.d directory if you have not done so already.

1
2
[root@nitrogen cd php-5.2.6]# cp php.ini-recommended /etc/php.ini
[root@nitrogen cd php-5.2.6]# mkdir /etc/php.d

Installing PHP into apache

To install PHP into apache all you need to do is place the following configuration file in /etc/httpd/conf.d/php.conf.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# /etc/httpd/conf.d/php.conf
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages
#
LoadModule php5_module modules/libphp5.so
#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php
#
# Uncommenting the following line to allow PHP to pretty-print .phps
# files as PHP source code:
#
#AddType application/x-httpd-php-source .phps

Finalizing our install is fairly simple, just restart apache by typing the following command and you should be good to run PHP applications for the web.

1
[root@nitrogen ~]# /sbin/service httpd restart
Tagged . Bookmark the permalink.

http://www.wolflabs.org/2008/12/08/installing-php-from-source-on-centos-x86_64-w-apache/

 

 

Reconfigure IPTables by deleting all previous rules

iptables -F
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP
iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp -s 192.168.20.0 -m tcp --dport 22 -j ACCEPT
iptables -I INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -L -n
iptables-save | sudo tee /etc/sysconfig/iptables
service iptables restart

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

1 Comment

Increase size of OracleVM Hard Disk

Normally a 10 GB Hard disk will not take that much space when you create an “dynamically expanding storage” HDD in OracleVM.  The size will be  the total size of data which you store on that hard disk.  So when you create an HDD in OracleVM select “dynamically expanding storage” and put maximum size you may require.

The OracleVM does  not have a built in utility to increase the hard disk size.  But the following work around helped me to increase the  size.

1. Select the OracleVM which has got the low disk space.

2. Select Settings and click on “Storage” and click on the icon “Add Hard disk”

3.  Select “Create new disk” and create a hard disk with the required disk space.

4. Select the newly created hard disk and change the attribute as shown in figure below. If your first hard disk is “IDE Primary Master” then your second hard disk should be “IDE Secondary Master”.

5. Boot the VM and install any disk cloning tool which works with your OS in VM.  I used demo version of  Migrate Easy from Acronis which worked just fine for me to clone my Windows 2003 VM HDD. If you does not have enough space to install the software add a new hdd to VM  and install the software on that. If you have little space on first hdd change the  TEMP settings of existing VM from the “Environment Variables” settings. See the screen shot.

6.  After the installation open the disk cloning tool and click trial and then click on “Disk Clone”. Click “Next”  and select “Automatic” and click next select the first hard(disk with low disk space ) disk and click next and select the second hdd and continue. It will ask restart the system, restart the VM so that the cloning will start automatically when the VM starts. After cloning the first hdd to new hdd shutdown the VM.

7. Select the VM and click settings. select “Storage” and remove the first hdd. Select the new vdi image  and change the Attribute to “IDE Primary Master”  which is the attribute of the first hdd  you  removed.

Boot into to the VM with the new hdd with increased space !

, , , , , , ,

4 Comments

Asterisk – Skill Based Routing

**skills or specialties = priority 1 / priority 2 / priority 3

agent 1 = mac

agent 2 = linux

agent 3 = linux

agent 4 = mac / linux

agent 5 = linux / mac

When agent 1 is busy, next call should go to agent 4. But when both agent 1 and 4 is busy (both have priority skill for MAC), call should go to agent 5 (can accept calls for MAC) because it has priority 2 for MAC. Is this possible?

Asterisk doesn’t really have skills based routing yet, but you can do the same thing with multiple queues. Each queue being a skill. Below you will find my interpretation of your requirements. In your example, agent 4 and 5 are members of both queues, but have their penalties set appropriately.

queues.conf

[general]
autofill=yes 

[linux]
; Put whatever other queue options you want here
strategy=rrmemory
member => Agent/agent2,1
member => Agent/agent3,1
member => Agent/agent4,3
member => Agent/agent5,2 

[mac]
; Put whatever other queue options you want here
strategy=rrmemory
member => Agent/agent1,1
member => Agent/agent4,2
member => Agent/agent5,3

http://forums.digium.com/viewtopic.php?t=19527

, , , , , , , , , ,

Leave a comment

Nokia E6 VOIP Configuration

Nokia E6 with ACTIONVOIP

Here I brifely describes how to configure nokia E6 with a voip provider.  I could successfully configure  actionvoip with E6.

On your phone and goto Menu -> Settings->connectivity->Admin. settings ->  SIP settings

From the options select  ” New sip profile”

Profile Name: shyju’s VOIP

Put just a name as you wish.

Service profile : IETF

Default destination: None

Access point in use : LINKSYS

Use this to select your access point SSID which your are connected(Your router’s Wireless connection’s name).

Public username:  sip:shyju@sip.actionvoip.com

Use your username@yoursipserveraddress(No need to put “sip: ” it will  pre append automatically)

Use compression: No

Registration: Always on

Use security: No

Proxy Server

Proxy server address: sip.actionvoip.com

Realm: None

Username: shyju

Your VOIP username

Password:password

Your VOIP password.

Allow loose routing: Yes

Transport type: UDP

Port : 5060

Registrar Server

Registrar server address: sip.actionvoip.com

Realm: None

Username: shyju

Your voip username.

Password: password

Your voip password.

Allow loose routing: Yes

Transport type: UDP

Port : 5060

If your all settings are OK. , then it will show the SIP profile “Registered”.

, , , , , , , , , , , , , ,

22 Comments