CentOS 5.5 + Asterisk 1.6 + Digium TDM410P (2FXO + 2FXS) for dummies

Posted in In the mood | No Comments »

CentOS 5.5 + Asterisk 1.6 + Digium TDM410P (2FXO + 2FXS)

For Thailand change yum repository to mirror1.ku.ac.th
# wget http://mirror1.ku.ac.th/yum-centos/5/CentOS-Base.repo
# mv CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo

Installing Asterisk With Yum

http://www.asterisk.org/downloads/yum

Install Digium TDM410P
# dahdi_hardware
# dahdi_scan
# dahdi_genconf

# vi /etc/asterisk/chan_dahdi.conf
Add
#include dahdi-channels.conf

restart asterisk
# /etc/init.d/asterisk restart

# asterisk -r
dhcp-100*CLI> dahdi show channels
Chan Extension  Context         Language   MOH Interpret        Blocked    State
pseudo            default                    default                         In Service
1            from-pstn                  default                         In Service
2            from-pstn                  default                         In Service
3            from-internal              default                         In Service
4            from-internal              default                         In Service

# vi /etc/asterisk/sip.conf
Add
[2000]
context=default
type=friend
defaultuser=2000
secret=123456
host=dynamic
qualify=yes
dtmfmode=rfc2833
rfc2833compensate=yes
insecure=port,invite

[2001]
context=default
type=friend
defaultuser=2001
secret=123456
host=dynamic
qualify=yes
dtmfmode=rfc2833
rfc2833compensate=yes
insecure=port,invite

[2002]
context=default
type=friend
defaultuser=2002
secret=123456
host=dynamic
qualify=yes
dtmfmode=rfc2833
rfc2833compensate=yes
insecure=port,invite

# vi /etc/asterisk/extensions.conf
Add to default context after line include => demo
exten => _20XX,1,Dial(SIP/${EXTEN},10,rt);
exten => _20XX,2,HangUp

exten => 2099,1,Dial(SIP/2000&SIP/2001&SIP/2002,10,rt);
exten => 2099,2,HangUp

exten => 3000,1,Dial(DAHDI/3,10,rt)
exten => 3000,2,Dial(DAHDI/4,10,rt)
exten => 3000,3,HangUp

exten => 3001,1,Dial(DAHDI/4,10,rt)
exten => 3001,2,Dial(DAHDI/3,10,rt)
exten => 3001,3,HangUp

exten => 3099,1,Dial(DAHDI/3&DAHDI/4,10,rt)
exten => 3099,2,HangUp

[from-internal]

include => default

trixbox 2.8.0.4 Setting up Fax to Email

Posted in In the mood | No Comments »

General Settings,

FAX machine: system
my email address
return address

Inbound Routes page,

Fax Extension: FreePBX Default
Fax Email: my email address
Fax Detection Type: NVFax
Pause After Answer: 3

/etc/asterisk/extensions.conf
find [macro-faxreceive]

exten => s,3,rxfax(${FAXFILE})
change “rxfax” to “ReceiveFAX”

trixbox 2.8.0.4 – YOU MUST ACCESS THE CDR THROUGH THE ASTERISK MANAGEMENT PORTAL!

Posted in Knowledge | No Comments »

YOU MUST ACCESS THE CDR THROUGH THE ASTERISK MANAGEMENT PORTAL!

# /etc/init.d/memcached start
# chkconfig –level 345 memcached on

OpenVox a1200p + trixbox 2.8.0.4

Posted in Knowledge | No Comments »

# yum install kernel-devel
# wget http://downloads.openvox.cn/pub/drivers/dahdi-linux/openvox_dahdi-linux-2.2.0.tar.gz
# wget http://downloads.openvox.cn/pub/drivers/dahdi-tools/openvox_dahdi-tools-2.2.0.tar.gz
move files to /usr/src/dahdi/dahdi-com/ and extract all
# cd /usr/src/dahdi/dahdi-com/dahdi-linux-2.2.0/drivers/dahdi/
# wget http://downloads.openvox.cn/pub/drivers/dahdi/a800p_a1200p/opvxa1200.c
# vi opvxa1200.c
add 1 line
#include <linux/sched.h>
# cd ../../
# make && make install
# /usr/src/dahdi/dahdi-com/dahdi-tools-2.2.0/
# ./configure
# make && make install
# make config
# vi /etc/dahdi/modules
add 1 line
opvxa1200
# /etc/init.d/dahadi restart
# setup-pstn

crontab gpg + scp

Posted in Knowledge | No Comments »

gpg –always-trust -es –passphrase $passphrase -r $email $file_out_gz

#!/usr/local/bin/expect -f

set source [lrange $argv 0 0]
spawn scp $source user@host:path/
expect {
-re “.*es.*o.*” {
exp_send “yes\r”
exp_continue
}
-re “.*sword.*” {
exp_send “password\r”
}
}
interact

mysqldump insert per row with filed name

Posted in Knowledge | No Comments »

mysqldump -u root -p –all-database –skip-extended-insert –complete-insert > mysql.sql

THNIC public check domain available API

Posted in Knowledge | No Comments »

THNIC เปิดให้เช็คโดเมนแล้ว

How to use THNIC public check domain available API
You can use both $_GET and $_POST method to sent domainname to check
API support .in.th, .co.th, .or.th, .ac.th, mi.th, .go.th, .net.th

https://www.thnic.co.th/domain_avail_api.php?domain=xxx.xx.th

* return 0 (false) is domainname is not available
* return 1 (true) is domainname is available

Note !
Reserve Word or Incorrect domainname format (Ex. domain.in.th) Server Will Return 0

ref : https://www.thnic.co.th/domain_avail_api.php

Grep to remove files

Posted in Knowledge | No Comments »

grep -lir ‘string to search in files’ * |xargs rm -rf

Options
l – for listing file name only
i – ignore case while searching
r – search recursively within sub directories also
xargs – the list of files from grep command are passed as parameter to “rm -rf” command

วิธี foward attach mail บน android

Posted in Android | No Comments »

หลายครั้งที่เราพยายาม forward mail ที่มี attach file มาด้วย บน android แต่ attach file ไม่ยอมไปด้วย
วันนี้มีวิธีแก้แล้ว วิธีแก้ที่พบโดยบังเอิญ
วิธีก็คือให้ทำการคลิ๊กโหลดไฟล์ที่ต้องการ forward ก่อน (ไม่ต้อง save ลง SD)
แล้วค่อยคลิ๊ก forward mail ไฟล์ที่โหลดมาจะถูก forward ไปด้วย

test by hTc Magic (Sense UI)

Many email messages are sent from PHP scripts on the server. How can I find what domains these scripts are running on?

Posted in Knowledge | No Comments »

Article ID: 1711
Last Review: Nov,25 2009
Author: Bezborodova Anastasiya
Last updated by: Bezborodova Anastasiya APPLIES TO:

* Plesk 9.x for Linux/Unix
* Plesk 8.x for Linux/Unix

Resolution
There is a way to find what the folder the PHP script that sends mail was run from. Note, the paths can be slightly differ from the listed below depending on your OS and Plesk version:

1) create /var/qmail/bin/sendmail-wrapper script with the content:

#!/bin/sh
(echo X-Additional-Header: $PWD ;cat) | tee -a /var/tmp/mail.send|/var/qmail/bin/sendmail-qmail “$@”

Note, it should be the two lines including ‘#!/bin/sh’.

2) then create log file /var/tmp/mail.send and grant it “a+rw” rights, make the wrapper executable, rename old sendmail and link it to the new wrapper:

~# touch /var/tmp/mail.send
~# chmod a+rw /var/tmp/mail.send
~# chmod a+x /var/qmail/bin/sendmail-wrapper
~# mv /var/qmail/bin/sendmail /var/qmail/bin/sendmail-qmail
~# ln -s /var/qmail/bin/sendmail-wrapper /var/qmail/bin/sendmail
3) Wait for an hour or so and revert sendmail back:

~# rm -f /var/qmail/bin/sendmail
~# ln -s /var/qmail/bin/sendmail-qmail /var/qmail/bin/sendmail

Examine /var/tmp/mail.send file, there should be lines starting with “X-Additional-Header:” pointing out to domains’ folders where the scripts which sent the mail are located.
You can see all the folders mail PHP scripts were run from with the following command:

~# grep X-Additional /var/tmp/mail.send | grep `cat /etc/psa/psa.conf | grep HTTPD_VHOSTS_D | sed -e ‘s/HTTPD_VHOSTS_D//’ `

f you see no output from the command above, it means that no mail was sent using PHP mail() function from the Plesk virtual hosts directory.

ref : http://kb.parallels.com/en/1711