<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>System Network Programming Solution - Linux - windows - centos- security- cpanel - plesk -directadmin helm</title>
	<atom:link href="http://thegioinguonmo.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://thegioinguonmo.com</link>
	<description>SHARING EVERYTHING</description>
	<lastBuildDate>Wed, 22 Feb 2012 10:39:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>I&#8217;ve deleted /home, how do I recreate the directories?</title>
		<link>http://thegioinguonmo.com/hosting-controller/directadmin/deleted-home-recreate-directories.html</link>
		<comments>http://thegioinguonmo.com/hosting-controller/directadmin/deleted-home-recreate-directories.html#comments</comments>
		<pubDate>Wed, 22 Feb 2012 10:39:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DirectAdmin]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[directadmin]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2354</guid>
		<description><![CDATA[Generally, this isn&#8217;t the best thing to have happen because all of the data is stored there.  You&#8217;ll need to recreate all of the directory structures, as well as a few files required for DA to run: 1) Create the DA tmp directory so you can log into DA again: mkdir -p /home/tmp chmod 1777 [...]]]></description>
			<content:encoded><![CDATA[<p>Generally, this isn&#8217;t the best thing to have happen because all of the data is stored there.  You&#8217;ll need to recreate all of the directory structures, as well as a few files required for DA to run:</p>
<p>1) Create the DA tmp directory so you can log into DA again:</p>
<pre class="brush:shell">mkdir -p /home/tmp
chmod 1777 /home/tmp</pre>
<p>2) Create the /home/username directories and subdirectories:</p>
<pre class="brush:shell">cd /home
vi make_dirs.sh</pre>
<p>press &#8216;i&#8217; to go into &#8220;insert mode&#8221; then paste the following script (right click)</p>
<pre class="brush:shell">#!/bin/sh
for i in `ls /usr/local/directadmin/data/users`; do
{
 for d in `cat /usr/local/directadmin/data/users/${i}/domains.list`; do
 {
  mkdir -p /home/${i}/domains/${d}/public_html/cgi-bin
  mkdir -p /home/${i}/domains/${d}/private_html
  mkdir -p /home/${i}/domains/${d}/public_ftp
  mkdir -p /home/${i}/domains/${d}/stats
  mkdir -p /home/${i}/domains/${d}/logs
 };
 done;
 mkdir -p /home/${i}/backups    

 chown -R $i:$i /home/${i}
 chmod -R 755 /home/${i}
};
done;
exit 0;</pre>
<p>Press &#8220;ctrl-c&#8221; to exit &#8220;insert mode&#8221;, then press &#8220;shift-Z&#8221; twice to save and exit.  Once the file is saved, type:</p>
<pre class="brush:shell">chmod 755 make_dirs.sh
./make_dirs.sh</pre>
]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/hosting-controller/directadmin/deleted-home-recreate-directories.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disk Usage is showing 0.00</title>
		<link>http://thegioinguonmo.com/hosting-controller/directadmin/disk-usage-showing-000.html</link>
		<comments>http://thegioinguonmo.com/hosting-controller/directadmin/disk-usage-showing-000.html#comments</comments>
		<pubDate>Wed, 22 Feb 2012 10:36:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DirectAdmin]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[directadmin]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2351</guid>
		<description><![CDATA[*** Note: If you&#8217;re running a VPS with a &#8220;simfs&#8221; file system, quotas usually cannot be enabled with normal means.  Contact yoru VPS provider to enable quotas for you. DirectAdmin relies on the system quotas to return a value for how much space is being used.  DirectAdmin will run /usr/sbin/repquota /home Where /homeis the quota_partition [...]]]></description>
			<content:encoded><![CDATA[<p><strong>*** <span style="color: #ff0000;">Note</span></strong>: If you&#8217;re running a VPS with a &#8220;simfs&#8221; file system, quotas usually cannot be enabled with normal means.  Contact yoru VPS provider to enable quotas for you.</p>
<p>DirectAdmin relies on the system quotas to return a value for how much space is being used.  DirectAdmin will run</p>
<pre class="brush:shell">/usr/sbin/repquota /home</pre>
<p>Where <strong>/home</strong>is the quota_partition value set in the /usr/local/directadmin/conf/directadmin.conf file (eg, /home, / or /usr).  The command should output a large list of numbers, eg</p>
<p>[root@server]# <strong>/usr/sbin/repquota /home</strong><br />
*** Report for user quotas on device /dev/hda3<br />
Block grace time: 7days; Inode grace time: 7days<br />
Block limits                File limits<br />
User            used    soft    hard  grace    used  soft  hard  grace<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
root      &#8211;  417796       0       0           7446     0     0<br />
nobody    &#8211;       4       0       0              1     0     0<br />
bin       &#8212;   56880       0       0            510     0     0<br />
majordomo &#8212;       8       0       0              2     0     0<br />
diradmin  &#8211;       8       0       0              2     0     0<br />
admin     &#8212;     200       0       0             44     0     0<br />
user123   &#8212;     100       0       0             22     0     0<br />
user456   &#8212;     100       0       0             22     0     0</p>
<p>If the &#8220;used&#8221; column is not showing anything, or users are not in the list, then you&#8217;ll need to run the quotacheck program:</p>
<p>Redhat:</p>
<pre class="brush:shell">/sbin/quotaoff -a; /sbin/quotacheck -avugm; /sbin/quotaon -a;</pre>
<p>FreeBSD:</p>
<pre class="brush:shell">/usr/sbin/quotaoff -a; /sbin/quotacheck -avug; /usr/sbin/quotaon -a;</pre>
<p>If are getting errors and no output is displayed for the repquota command, you&#8217;ll need to check your /etc/fstab file to make sure that it contains the <strong>rw,userquota,groupquota</strong> line beside the partition that is using the quotas.<br />
*Important:  On Linux (Redhat/Debian), it&#8217;s <strong>usrquota,grpquota</strong>, and on FreeBSD it&#8217;s <strong>userquota,groupquota</strong>.</p>
<p>Sample /etc/fstab (do not make your&#8217;s look identical if it&#8217;s different, this is one example from a specific OS):</p>
<p># Device                Mountpoint      FStype  Options         Dump    Pass#<br />
/dev/ad0s1a                     <strong>/</strong>                       ufs     rw<strong>,userquota,groupquota</strong> 1       1<br />
/dev/ad0s1e             /tmp            ufs     rw              2       2<br />
proc                    /proc           procfs  rw              0       0</p>
<p>In this case, the quota_partition is <strong>/</strong>.  The quota partition should be the partition that holds your users.  Generally, this will be one of /home, / or /usr.</p>
<p>Once the repquota program is returning a normal value, then you can run the tally to get the correct usage to show up in DirectAdmin:</p>
<pre class="brush:shell">echo "action=tally&amp;value=all" &gt;&gt; /usr/local/directadmin/data/task.queue</pre>
<p>This task.queue command will get picked up by the dataskq binary.   It calls the repquota command and dumps it into /home/tmp/quota-dump.<br />
Check /var/log/directadmin/errortaskq.log for any errors with this.<br />
<a rel="nofollow" target="_blank" href="http://help.directadmin.com/item.php?id=222">Running the tally manually for a User</a> can also help with debugging these issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/hosting-controller/directadmin/disk-usage-showing-000.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setup a per-user php.ini to allow open_basedir with suPhp</title>
		<link>http://thegioinguonmo.com/hosting-controller/directadmin/setup-peruser-phpini-openbasedir-suphp.html</link>
		<comments>http://thegioinguonmo.com/hosting-controller/directadmin/setup-peruser-phpini-openbasedir-suphp.html#comments</comments>
		<pubDate>Wed, 22 Feb 2012 09:41:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DirectAdmin]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[cgi]]></category>
		<category><![CDATA[directadmin]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[suphp]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2347</guid>
		<description><![CDATA[new way: If you wish to use per-user php.ini files in: /usr/local/directadmin/data/users/username/php/php.ini then you can use this guideto add the code: SetEnv PHP_INI_SCAN_DIR /usr/local/directadmin/data/users/&#124;USER&#124;/php/ to the VirtualHost entires for that domain and it&#8217;s subdomains.   This will tell suPhp to look in that path for a php.ini. It&#8217;s loaded after the main php.ini, so if [...]]]></description>
			<content:encoded><![CDATA[<p><strong>new way:</strong></p>
<p>If you wish to use per-user php.ini files in:<br />
/usr/local/directadmin/data/users/<strong>username</strong>/php/php.ini<br />
then you can use <a rel="nofollow" target="_blank" href="http://help.directadmin.com/item.php?id=2">this guide</a>to add the code:</p>
<p>SetEnv PHP_INI_SCAN_DIR /usr/local/directadmin/data/users/|USER|/php/</p>
<p>to the VirtualHost entires for that domain and it&#8217;s subdomains.   This will tell suPhp to look in that path for a php.ini.<br />
It&#8217;s loaded after the main php.ini, so if it&#8217;s not there, it&#8217;s not a big deal.  You can add just the php entries that you wish to override the global php.ini&#8217;s defaults.<br />
Note for complete usage of this setting, a how-to has been created here, which should be consulted with first: <a rel="nofollow" target="_blank" href="http://www.directadmin.com/forum/showpost.php?p=156958&amp;postcount=25">http://www.directadmin.com:80/forum/showpost.php?p=156958&amp;postcount=25</a></p>
<p>If you only want to set a custom php.ini for individual users, and not all users, then you can use <a rel="nofollow" target="_blank" href="http://help.directadmin.com/item.php?id=3">this guide</a> to insert just the one line of code into the VirtualHost entires for that domain.</p>
<p>Sample /usr/local/directadmin/scripts/custom/user_create_post.sh</p>
<pre class="brush:shell">#!/bin/sh

HOME=/home/$username
OBD="${HOME}/:/tmp:/var/tmp:/usr/local/lib/php/"

P=/usr/local/directadmin/data/users/$username
if [ ! -e ${P}/php ]; then
            mkdir ${P}/php
fi

PI=${P}/php/php.ini
if [ ! -e ${PI} ]; then
            cp -f /usr/local/lib/php.ini.template ${PI}
            TMP="perl -pi -e 's#open_basedir = OBD#open_basedir = ${OBD}#' ${PI}"
            eval $TMP
fi
exit 0;</pre>
<p>Where the /usr/local/lib/php.ini.template might look like this:</p>
<p>[PHP]<br />
open_basedir = OBD</p>
<p>so that the regex in the user_create_post.sh will swap OBD will the user&#8217;s open_basedir path.</p>
<p>Related:<br />
<a rel="nofollow" target="_blank" href="http://www.php.net/ini.sections">http://www.php.net/ini.sections</a><br />
<a rel="nofollow" target="_blank" href="http://www.php.net/ChangeLog-5.php#5.3.0">Improved php.ini handling in 5.3.0</a></p>
<hr />
<p><strong>old way:</strong></p>
<p>In order to setup a php.ini for each user with suPhp (installed by custombuild), edit:<br />
/etc/httpd/conf/extra/httpd-suphp.conf</p>
<p>Find this line:</p>
<p>suPHP_ConfigPath /usr/local/etc/php5/cgi/</p>
<p>and comment it out by changing it to</p>
<p><strong>#</strong>suPHP_ConfigPath /usr/local/etc/php5/cgi/</p>
<p>(just add a # in front of it).</p>
<p>Doing this will let suPhp be more flexible in using a different php.ini file.  By default, it will still fall back to the /usr/local/etc/php5/cgi/php.ini if nothing else is set, but by not setting it, it allows us to change it (suPhp only accepts the first call of that command).</p>
<p>The next step is to tell apache where to find the php.ini that you want.<br />
Go to:<br />
Admin Level -&gt; Custom httpd configuration -&gt; <strong>domain.com</strong></p>
<p>Insert the following 1 line into the top textarea:</p>
<p>suPHP_ConfigPath |HOME|/</p>
<p>exactly as written, then hit save.  You can do this for as many single domains as you wish.</p>
<p>Note that you can also make this a global change by adding that line to the virtualhost templates using this guide:<br />
<a rel="nofollow" target="_blank" href="http://help.directadmin.com/item.php?id=2">help.directadmin.com/item.php?id=2</a>.</p>
<p>Restart apache when you&#8217;re done.</p>
<p>Don&#8217;t forget to actually add a php.ini file into /home/<strong>username</strong>/php.ini and save it with root as the owner if you don&#8217;t want the user changing it at all.   In that php.ini file, you can specify a custom open_basedir path, thus preventing the user from wandering about the system.  Automating a new php.ini can be done with the user_create_post.sh script.</p>
]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/hosting-controller/directadmin/setup-peruser-phpini-openbasedir-suphp.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache give each user their own cgi-bin directory</title>
		<link>http://thegioinguonmo.com/web-server/apache/apache-give-user-cgibin-directory.html</link>
		<comments>http://thegioinguonmo.com/web-server/apache/apache-give-user-cgibin-directory.html#comments</comments>
		<pubDate>Wed, 22 Feb 2012 09:39:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[home]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[user]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=1846</guid>
		<description><![CDATA[Apache has public_html directory support. With this you specify the name of the directory which is appended onto a user&#8217;s home directory if a ~user request is received. For example http://domain.com/~rocky/file.html will be rocky&#8217;s home directory /home/rocky/public_html/file.html. Recently I took small part time job to setup web server for university. I want to give every [...]]]></description>
			<content:encoded><![CDATA[<p>Apache has public_html directory support. With this you specify the name of the directory which is appended onto a user&#8217;s home directory if a ~user request is received. For example http://domain.com/~rocky/file.html will be rocky&#8217;s home directory /home/rocky/public_html/file.html. Recently I took small part time job to setup web server for university. I want to give every student access to cgi-bin so that they can use perl. I don&#8217;t wanna give everyone access to /var/www/cgi-bin or /usr/lib/cgi-bin directory. ScriptAliases enables documents in the cgi-bin directory treated as applications and run by the server when requested rather than as documents sent to the client. So first I did setup ScriptAlias. However it was not working.<br />
So all students was able to see each others perl source code <img src='http://thegioinguonmo.com/wp-includes/images/smilies/icon_sad.gif' alt="icon sad Apache give each user their own cgi bin directory" class='wp-smiley' title="Apache give each user their own cgi bin directory" />  so I was called again to fix this problem. After searching little bit, I found solution from offical Apache docs. So I modified httpd.conf and added following two directives to /home/*/public_html/cgi-bin section:</p>
<pre>Options ExecCGI
SetHandler cgi-script</pre>
<p>At the end final entry looked like as follows:</p>
<pre>&lt;Directory /home/*/public_html/cgi-bin&gt;
Options ExecCGI
SetHandler cgi-script
&lt;/Directory&gt;</pre>
<p>Then I restarted apache and it worked like a charm. See Apache document <a rel="nofollow" target="_blank" href="http://httpd.apache.org/docs/1.3/howto/cgi.html">Dynamic Content with CGI</a>. Update: As pointed out by Randal you just need to add above four lines.</p>
]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/web-server/apache/apache-give-user-cgibin-directory.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to setup jailed ssh and jailed cgi (beta)</title>
		<link>http://thegioinguonmo.com/hosting-controller/directadmin/setup-jailed-ssh-jailed-cgi-beta.html</link>
		<comments>http://thegioinguonmo.com/hosting-controller/directadmin/setup-jailed-ssh-jailed-cgi-beta.html#comments</comments>
		<pubDate>Wed, 22 Feb 2012 09:38:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DirectAdmin]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[cgi]]></category>
		<category><![CDATA[directadmin]]></category>
		<category><![CDATA[jailed]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2342</guid>
		<description><![CDATA[If you run custombuild, the jailed script portion of this guide is in the options.conf. #Jailed shell (beta) jail=yes Then type ./build all_jail The &#8220;./jail/jail_user.sh user&#8221; (from the custombuild dir) would be used for each user you want to jail.   The remaining httpd.conf and other options from this guide still apply. 1) First, install [...]]]></description>
			<content:encoded><![CDATA[<p>If you run custombuild, the jailed script portion of this guide is in the options.conf.</p>
<p>#Jailed shell (beta)<br />
jail=yes</p>
<p>Then type</p>
<p>./build all_jail</p>
<p>The &#8220;./jail/jail_user.sh <strong>user</strong>&#8221; (from the custombuild dir) would be used for each user you want to jail.   The remaining httpd.conf and other options from this guide still apply.</p>
<hr />
<p>1) First, install the scripts and binaries (note, currently for apache 1.3.x only):</p>
<pre class="brush:shell">cd /usr/local/directadmin/customapache
mkdir jail
cd jail
wget http://files.directadmin.com/services/customapache/jail/build
chmod 755 build
./build update
./build all</pre>
<p>2) It&#8217;s recommended you make backups of /etc/passwd, /etc/shadow, /etc/group, and /etc/master.passwd (if you have it)</p>
<pre class="brush:shell">cp -f /etc/passwd /etc/passwd.backup
cp -f /etc/group /etc/group.backup
cp -f /etc/shadow /etc/shadow.backup
cp -f /etc/master.passwd /etc/master.passwd.backup</pre>
<p>3) To jail a specific user, this command is used:</p>
<pre class="brush:shell">cd /usr/local/directadmin/customapache/jail
./jail_user.sh username</pre>
<p><strong></strong></p>
<p>If they are to use jailed CGI, then</p>
<p>SetEnv JAIL_DIR |HOME|</p>
<p>would need to be added to their virtualhosts (where home is their home directory, eg: /home/<strong>username</strong>).</p>
<p>Note that php through apache is not jailed, so enableing safemode and open_basedir would be recommended.</p>
<p>To *automate* the jailing process, you can create /usr/local/directadmin/scripts/custom/user_create_post.sh and fill it with:</p>
<pre class="brush:shell">#!/bin/sh
if [ $ssh = "ON" ]; then
  cd /usr/local/directadmin/customapache/jail
  ./jail_user.sh $username
fi
exit 0;</pre>
<p>Then chmod it to 755:</p>
<pre class="brush:shell">chmod 755 /usr/local/directadmin/scripts/custom/user_create_post.sh</pre>
<p>To automate the cgi jailing, then the SetEnv option has to be added to any virtualhost that is to use the jailing.  Create /usr/local/directadmin/scripts/custom/domain_create_post.sh with the following:</p>
<pre class="brush:shell">#!/bin/sh
COUNT=`grep -e "^${username}:" /etc/passwd | grep -c /bin/jail`
if [ $COUNT -eq 1 ]; then
  echo "SetEnv JAIL_DIR |HOME|" &gt; /usr/local/directadmin/data/users/${username}/domains/${domain}.cust_httpd
  echo "action=rewrite&amp;value=httpd&amp;user=${username}" &gt;&gt; /usr/local/directadmin/data/task.queue
fi
exit 0;</pre>
<p>and chmod to 755, like the user_create_post.sh script.</p>
<p>4) Since a user can be created without ssh, and it gets added later, we&#8217;ll need to create a user_modify_post.sh script as well, but since it&#8217;s the same code, we&#8217;ll just create a symbolic link.</p>
<pre class="brush:shell">ln -s user_create_post.sh /usr/local/directadmin/scripts/custom/user_modify_post.sh</pre>
<p>Note, that the jail_user.sh isn&#8217;t going to be very speedy as it has to transfer over all program binaries and libraries that would be needed inside the jail.  This takes time.  It also takes a huge amount of space that will not be counted in the users total disk usage.</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/hosting-controller/directadmin/setup-jailed-ssh-jailed-cgi-beta.html" title="enable jailed shell openvz">enable jailed shell openvz</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/hosting-controller/directadmin/setup-jailed-ssh-jailed-cgi-beta.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Basic system security</title>
		<link>http://thegioinguonmo.com/hosting-controller/directadmin/basic-system-security.html</link>
		<comments>http://thegioinguonmo.com/hosting-controller/directadmin/basic-system-security.html#comments</comments>
		<pubDate>Wed, 22 Feb 2012 09:34:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DirectAdmin]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[directadmin]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2338</guid>
		<description><![CDATA[Note that it&#8217;s ultimately the responsibility of the server admin to ensure his system is secure.  These are some basic security tips that can be done to help protect your system.  This is not an end-all guide for server security, admins must be diligent, but rather some suggestions for a start to securing your server. [...]]]></description>
			<content:encoded><![CDATA[<p>Note that it&#8217;s ultimately the responsibility of the server admin to ensure his system is secure.  These are some basic security tips that can be done to help protect your system.  This is not an end-all guide for server security, admins must be diligent, but rather some suggestions for a start to securing your server.</p>
<p><strong>1)</strong> At install time, the easiest thing to do is to mount your /tmp partition with the <strong>noexec,nosuid</strong> options, and mount the /home partition with the <strong>nosuid</strong>option.  This is done in your /etc/fstab and requires those paths to exist as partitions, and not just as subdirectories of /.  If you&#8217;re unsure, type:</p>
<p>mount</p>
<p>to get a listing of your partitions and their current mounting options.  Use google for more information on these mounting options. Be very careful when editing your /etc/fstab, as any errors could prevent your system from starting up.  Note that you must not have &#8220;nosuid,noexec&#8221; for / or /usr, as those partitions have suid binaries normally (su, passwd, etc).</p>
<p><strong>2)</strong> After the system is installed, a good idea is to add dangerous php functions to the <strong>disable_functions</strong>list.  This prevents php scripts from running &#8220;raw&#8221; functions that could be used to execute programs on your system.  Note that some php scripts do legitimately require these functions to operate, so if your scripts don&#8217;t run after enabling this function, edit your php.ini to remove the required functions from the list, and restart apache.  To add the disable_functions with custombuild, type the following then restart apache:</p>
<pre class="brush:shell">cd /usr/local/directadmin/custombuild
./build update
./build secure_php</pre>
<p><strong>3)</strong>Do regular updates of system services, libraries and scripts.  It&#8217;s important to keep your system updated once installed.   This is the responsibility of the server administrator.  There are several tools and options avaiable to help the admin do this.  For system libraries like openssl and other low level system items, this is left to the admin to do how he wish, usually package systems like yum or apt-get can do this for you.  For services and scripts that DA installs, you can use the custombuild script.   A typical update command with custombuild is:</p>
<pre class="brush:shell">cd /usr/local/directadmin/custombuild
./build update
./build all d</pre>
<p>Note that in the custombuild directory is a file called &#8220;options.conf&#8221;.  In this file is a list of all options you&#8217;ve got regarding what custombuild will do.   Regarding updates, ensure you have <strong>clean_old_webapps=yes</strong> present.  This removes all scripts from /var/www/html, after updating you do a new one.     The options.conf also has cron options to check for updates nightly, or even install these options nightly.  I recommend having the nightly cron check, and then a hand-on admin proceed with the update after he gets the notice.  To enable a nightly notice replace the following <strong>bold</strong>options with your relevant information:</p>
<pre class="brush:shell">#Cron settings
cron=yes
email=email@domain.com
notifications=yes
updates=no
webapps_updates=yes</pre>
<p><strong></strong></p>
<p>Then type:</p>
<pre class="brush:shell">./build cron</pre>
<p>These are the settings for getting nightly notices for updates, but it won&#8217;t do the updates for you.<br />
After getting the notice in your inbox, you&#8217;d run the following from the custombuild directory:</p>
<pre class="brush:shell">./build update_versions</pre>
<p>to update just those items that require updating.  Note that doing &#8220;./build all d&#8221; can be simpler, but takes longer to run.<br />
If you wish to have &#8220;./build update_versions&#8221; be run automatically, change the updates=<strong>no</strong> to become updates=<strong>yes</strong>.  Just keep in mind that the server admin is still required to be fully aware of the system and it&#8217;s state if he choses yes for this option.  The webapps_updates option only applies when updates=no is used.  It&#8217;s there to still allow updates to the php scripts in /var/www/html, while not affecting compiled services.  Set webapps_updates=<strong>yes</strong> if updates=no and you wish to have automated updates of the webapps scripts with the cron option.  If updates=yes, then the webapps_updates value doesn&#8217;t matter.</p>
<p><strong>4)</strong> If you&#8217;re running php in &#8220;CLI&#8221; mode, then enabling both php <a rel="nofollow" target="_blank" href="http://www.php.net/manual/en/features.safe-mode.php">SafeMode</a> and open_basedir is wise.  Safemode is an internal form of disable_functions which also does a bit more checking.  See <a rel="nofollow" target="_blank" href="http://www.php.net/manual/en/features.safe-mode.php">the documentation on Safemode</a> for more info on this.   Open_basedir, which is enabled by default, tells php to not allow scripts to access files outside of the set list of paths.<br />
To control SafeMode and Open_Basedir on your php CLI system (default), go to:</p>
<p>Admin Level -&gt; Php Safemode Config</p>
<p><strong>5)</strong> suPhp is one option which some admin&#8217;s like, other&#8217;s do not.  What suPhp (php CGI) does is runs php scripts as the system user of the account, rather than the &#8220;apache&#8221; user.   This solves many issues like permission/ownership when a php script uploads files.  It also allows an admin to track down rogue scripts more easily as it&#8217;s not running as a generic user.  Another benefit of suPhp is that you can chmod your php scripts to 700 instead of 755.  This makes them more secure in the case you&#8217;re storing passwords in your scripts.   Drawbacks to suPhp include a slight slowdown in performance since there are a few more hoops to jump through to have php run as the user instead of &#8220;apache&#8221;.  Also, the items in point <strong>4)</strong> above have no effect since suPhp does not monitor VirtualHost php flags.  All settings must be done in php.ini files.  Note that you can have per-user php.ini files to allow per-user settings, see <a rel="nofollow" target="_blank" href="http://help.directadmin.com/item.php?id=183">this link</a>.</p>
<p>To enable suPhp, see <a rel="nofollow" target="_blank" href="http://help.directadmin.com/item.php?id=197">this guide</a>.</p>
<p><strong>6)</strong> If you don&#8217;t plan on doing any remote access to mysql, then setting up mysqld to only listen on 127.0.0.1 would be a good idea.  Note you&#8217;ll have to keep this in mind if your users start asking you why they can&#8217;t connect to mysql from a remote location.  To set mysql to only bind to 127.0.0.1, add the following to the <strong>[mysqld]</strong>section of your /etc/my.cnf, then restart mysqld:</p>
<p>bind-address = 127.0.0.1</p>
<p><strong>7)</strong> One filtering option for apache is mod_security.  This is not part of our installation, but mod_security is an apache filter which checks all http requests sent by clients to ensure they&#8217;re valid.  Note that if not setup correctly, it can break frontpage, or other php scripts that often have long URL requests, so proper setup and testing would be important.  Check our forum for guides on this, it&#8217;s not covered by our support.</p>
<p><strong> <img src='http://thegioinguonmo.com/wp-includes/images/smilies/icon_cool.gif' alt="icon cool Basic system security" class='wp-smiley' title="Basic system security" /> </strong> A firewall is always a good idea.  Many people use iptables or apf.  A new free plugin is also <a rel="nofollow" target="_blank" href="http://www.directadmin.com/forum/showthread.php?t=29807">available here</a>.</p>
<p><strong>9)</strong> Set the User&#8217;s domains directory to block other Users on the system from seeing in:<br />
<a rel="nofollow" target="_blank" href="http://help.directadmin.com/item.php?id=254">http://help.directadmin.com/item.php?id=254</a></p>
<p><strong>10)</strong> Setup your named.conf to not allow recursion.  This should be done by default now, but check anyway with <a rel="nofollow" target="_blank" href="http://help.directadmin.com/item.php?id=115">this guide</a>.</p>
<p><strong>11)</strong> Prevent Users from using weak passwords by enabling <a rel="nofollow" target="_blank" href="http://www.directadmin.com/features.php?id=910">difficult password enforcement.</a></p>
<p><strong>12)</strong> Prevent Users from creating subdomains belonging to other Users with <a rel="nofollow" target="_blank" href="http://www.directadmin.com/features.php?id=925">this option</a>.</p>
<p><strong>13)</strong> If you&#8217;re using <a rel="nofollow" target="_blank" href="http://help.directadmin.com/item.php?id=15">DirectAdmin with SSL</a>, it&#8217;s a good idea to <a rel="nofollow" target="_blank" href="http://www.directadmin.com/features.php?id=957">force all SSL connections to use SSLv3</a> instead of other older protocols.</p>
<p><strong>14)</strong> To add another layer of security with the permissions of the perl binary, using a trick similar to step <strong>9</strong>, run the following:</p>
<pre class="brush:shell">chgrp apache /usr/bin/perl /usr/bin/wget /usr/local/bin/wget /usr/local/bin/curl /usr/bin/curl
chmod 705 /usr/bin/perl /usr/bin/wget /usr/local/bin/wget /usr/local/bin/curl /usr/binl/curl</pre>
<p>what this will do is tell the system that any user in group &#8220;apache&#8221; is not allowed to execute /usr/bin/perl.  If you did implement step <strong>9</strong> you could in theory use &#8220;access&#8221; instead of &#8220;apache&#8221; for the chgrp value, to also prevent other system account from running it, but apache is the main one.   This technique can be applies to other binaries as well, like wget, fetch, etc.. anything you don&#8217;t want the &#8220;apache&#8221; user from running.  Keep in mind that using suPhp (step <strong>5</strong>) essentially negates this issue since php scripts run as the user instead.  Note that this is another layer of security, so using it anyway wouldn&#8217;t hurt anything, in the event that an apache exploit happens independant of php completely.</p>
<p><strong>15)</strong> Brute Force Login Attempts are more common, so it&#8217;s best <strong>not</strong> to have direct ssh logins for common accounts like root or admin.  Generally, it&#8217;s safe to use a hidden &#8220;su&#8221; user first, then login to root or other accounts once connected.  Disable any accounts (root, admin, etc) that don&#8217;t need direct access by editing the /etc/ssh/sshd_config.   Always test changes before logging out else you may lock yourself out from the box.</p>
]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/hosting-controller/directadmin/basic-system-security.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unzip: skipping filename.zip need PK compat. v4.5</title>
		<link>http://thegioinguonmo.com/os/linux/unzip-skipping-filenamezip-pk-compat-v45.html</link>
		<comments>http://thegioinguonmo.com/os/linux/unzip-skipping-filenamezip-pk-compat-v45.html#comments</comments>
		<pubDate>Wed, 22 Feb 2012 09:14:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Plesk]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[plesk]]></category>
		<category><![CDATA[plesk control panel]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2334</guid>
		<description><![CDATA[While accessing the Plesk control panel, you may encounter an error message as follows: ERROR: PleskFatalException StatInfo-&#62; getProductVersion failed OR ERROR: PleskFatalException StatInfo-&#62; getProductVersion failed: file_get_contents () failed: mktime() [&#60;a href='function.mktime'&#62;function.mktime&#60;/a&#62;] The “Plesk getProductVersion failed ” message states that either the Plesk version file /usr/local/psa/version is empty AND/OR the plesk version in the ‘psa.misc’ table [...]]]></description>
			<content:encoded><![CDATA[<p>While accessing the Plesk control panel, you may encounter an error message as follows:</p>
<blockquote>
<pre>ERROR: PleskFatalException StatInfo-&gt; getProductVersion failed</pre>
<pre>OR</pre>
<pre>ERROR: PleskFatalException StatInfo-&gt; getProductVersion failed:</pre>
<pre>file_get_contents () failed: mktime()</pre>
<pre>[&lt;a href='function.mktime'&gt;function.mktime&lt;/a&gt;]</pre>
</blockquote>
<p>The “Plesk getProductVersion failed ” message states that either the Plesk version file /usr/local/psa/version is empty AND/OR the plesk version in the ‘psa.misc’ table is incorrect. This is mostly caused due to a failed Plesk upgrade OR by removing/installing some Plesk modules.</p>
<p>To fix the issue do the following:</p>
<p><strong>1.</strong> First, check the Plesk version installed on the server</p>
<blockquote>
<pre># rpm -qi psa</pre>
</blockquote>
<p>note down the ‘version’ and ‘release’ values (these values will be different on your server).</p>
<blockquote>
<pre>Version : 9.5.3 Release : cos5.build95301122.20</pre>
</blockquote>
<p>now, check the OS installed on the server (for example, on CentOS)</p>
<blockquote>
<pre># cat /etc/redhat-release</pre>
<pre>CentOS release 5.5 (Final)</pre>
</blockquote>
<p>Using the above Plesk and OS info, insert a line as follows (your values will differ) in the /usr/local/psa/version file.</p>
<blockquote>
<pre>9.5.3 CentOS 5 95301122.20</pre>
</blockquote>
<p>Save the file and restart the psa serivce. <strong></strong></p>
<p><strong><strong>2. </strong>If the above fix doesn’t work, do the following<br />
</strong></p>
<p>Check the current value of  Plesk in the psa.misc table.</p>
<blockquote>
<pre>mysql&gt; select * from psa.misc where param='version';</pre>
</blockquote>
<p>If the value is not 0953 (example from my server), run the mysql update query to set the proper value. You should use the value that is returned by the ‘rpm -qi psa’  command on your server.</p>
<blockquote>
<pre>mysql&gt; update psa.misc set val="0953" where param="version";</pre>
</blockquote>
<p>Exit and restart mysql. That is it.</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/os/linux/unzip-skipping-filenamezip-pk-compat-v45.html" title="pk unzip">pk unzip</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/os/linux/unzip-skipping-filenamezip-pk-compat-v45.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create a Callback option</title>
		<link>http://thegioinguonmo.com/voip/asterisk/create-callback-option.html</link>
		<comments>http://thegioinguonmo.com/voip/asterisk/create-callback-option.html#comments</comments>
		<pubDate>Wed, 22 Feb 2012 09:08:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Asterisk]]></category>
		<category><![CDATA[Callback]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[voip]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2330</guid>
		<description><![CDATA[1. Overview This tutorial will show you how to create a queue, where your incoming calls to arrive. Noting so special, but we are also going to show you how to give a choice to the callers &#8211; they will be able to leave the queue at any time and in our example they will [...]]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: underline;"><em>1. Overview</em></span></p>
<div>This tutorial will show you how to create a queue, where your incoming calls to arrive. Noting so special, but we are also going to show you how to give a choice to the callers &#8211; they will be able to leave the queue at any time and in our example they will have the choice to leave a number at which you could callback them later. The best part is that the number will be nicely emailed to your email box with details not only about the left number, but also the CallerID, the queue at which the caller was initially placed and the date and time at which he has left his number.</div>
<p>&nbsp;</p>
<div></div>
<p><span style="text-decoration: underline;"><em>2. Prerequisites</em></span></p>
<div>Before we start we will assume that you have <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/general_asterisk_installation_compilation.html">a working Asterisk PBX</a> with registered users in <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/iax_conf.html"><em>iax.conf</em></a>, <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/sip_conf.html"><em>sip.conf</em></a> or <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/mgcp_conf.html"><em>mgcp.conf</em></a>(It depends on which protocol you would like to use)</p>
<p>We will show you how to create your extensions in <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/extensions_conf.html">extensions.conf</a>.</p>
<div></div>
<p>To test how the setup works we recommend to use our <span style="text-decoration: underline;"><strong>IAX softphone Idefisk</strong></span>. You can download it <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tools/idefisk_beta.php" target="_blank">from our website &#8211; here</a>. If you do so, you can also take a look at our <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/idefisk_softphone.html">tutorial</a> about how to configure it to work with <strong>Asterisk PBX</strong>.</p>
<p>For the sending of the emails you will need to install the <strong>mime-construct</strong> package. <strong>apt-get install mime-construct</strong> (in Debian) should do the trick. Of course you will need a SMTP server too.</div>
<p>&nbsp;</p>
<div></div>
<p><span style="text-decoration: underline;"><em>3. Asterisk PBX configurations</em></span></p>
<div>We need to create one user in the <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/iax_conf.html"><em>iax.conf</em></a> file. This is because we are going to use Idefisk and its <strong>IAX2</strong> support. Idefisk supports the <strong>SIP</strong> protocol too. So if you want to use it, you have to do the configurations below respectively in <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/sip_conf.html"><em>sip.conf</em></a>.</div>
<p>&nbsp;</p>
<div>Here is the configuration.</p>
<p><em>[general]<br />
trunkmtu = 4000<br />
bandwidth=low<br />
disallow=lpc10<br />
jitterbuffer=no<br />
forcejitterbuffer=no<br />
tos=lowdelay<br />
autokill=yes</p>
<p>[caller1]<br />
secret=caller1<br />
type=friend<br />
host=dynamic<br />
context=incoming_calls</em></div>
<p>&nbsp;</p>
<div>So, we now we have the user <em>caller1</em></p>
<p><em>Type=friend</em> means that this user can make and receive calls. <em>Host=dynamic</em> means that the IP is not statically assigned but dynamically through a DHCP server. <em>Allow=all</em> means that the line which this user will use, support all available audio codecs, supported by Asterisk. <em>Context=test</em> &#8211; this shows that the user is allowed to work with the extensions in the context with this name in the configuration file <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/extensions_conf.html">extensions.conf</a>.</p>
<p>Our <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/extensions_conf.html">extensions.conf</a> looks like:</div>
<p>&nbsp;</p>
<div>The configuration is below:</p>
<p><em>[incoming_calls]</p>
<p>exten =&gt; 100100,1,Set(CALLERID(name)=queue1)<br />
exten =&gt; 100100,n,Queue(queue1)<br />
exten =&gt; 100100,n,Hangup()</p>
<p>exten =&gt; 200200,1,Set(CALLERID(name)=queue2)<br />
exten =&gt; 200200,n,Queue(queue2)<br />
exten =&gt; 200200,n,Hangup()</p>
<p>exten =&gt; 300300,1,Set(CALLERID(name)=queue3)<br />
exten =&gt; 300300,n,Queue(queue3)<br />
exten =&gt; 300300,n,Hangup()</p>
<p>[queue1out]</p>
<p>exten =&gt; 1,1,Set(FLAG=1)<br />
exten =&gt; 1,n,Playback(CallBack)<br />
exten =&gt; 1,n,Read(NUMBER|beep|10|||5)<br />
exten =&gt; 1,n,Wait(1)<br />
exten =&gt; 1,n,Set(FLAG=2)<br />
exten =&gt; 1,n,GoToIf($[${NUMBER} = ""]?empty:full)<br />
exten =&gt; 1,n(empty),System(/usr/bin/call/mailnonumber.sh callback@test.org ${CALLERID(num)} Queue1)<br />
exten =&gt; 1,n,Hangup()<br />
exten =&gt; 1,n(full),System(/usr/bin/call/mailnumber.sh ${NUMBER} callback@test.org ${CALLERID(num)} Queue1)<br />
exten =&gt; 1,n,Hangup()</p>
<p>exten =&gt; h,1,NoOp(${FLAG})<br />
exten =&gt; h,2,GoToIf($[${FLAG} = 1]?h|3:h|4)<br />
exten =&gt; h,3,System(/usr/bin/call/mailnonumber.sh callback@test.org ${CALLERID(num)} Queue1)<br />
exten =&gt; h,4,Hangup()</p>
<p>[queue2out]</p>
<p>exten =&gt; 1,1,Set(FLAG=1)<br />
exten =&gt; 1,n,Playback(CallBack)<br />
exten =&gt; 1,n,Read(NUMBER|beep|10|||5)<br />
exten =&gt; 1,n,Wait(1)<br />
exten =&gt; 1,n,Set(FLAG=2)<br />
exten =&gt; 1,n,GoToIf($[${NUMBER} = ""]?empty:full)<br />
exten =&gt; 1,n(empty),System(/usr/bin/call/mailnonumber.sh callback@test.org ${CALLERID(num)} Queue2)<br />
exten =&gt; 1,n,Hangup()<br />
exten =&gt; 1,n(full),System(/usr/bin/call/mailnumber.sh ${NUMBER} callback@test.org ${CALLERID(num)} Queue2)<br />
exten =&gt; 1,n,Hangup()</p>
<p>exten =&gt; h,1,NoOp(${FLAG})<br />
exten =&gt; h,2,GoToIf($[${FLAG} = 1]?h|3:h|4)<br />
exten =&gt; h,3,System(/usr/bin/call/mailnonumber.sh callback@test.org ${CALLERID(num)} Queue2)<br />
exten =&gt; h,4,Hangup()</p>
<p>[queue3out]</p>
<p>exten =&gt; 1,1,Set(FLAG=1)<br />
exten =&gt; 1,n,Playback(CallBack)<br />
exten =&gt; 1,n,Read(NUMBER|beep|10|||5)<br />
exten =&gt; 1,n,Wait(1)<br />
exten =&gt; 1,n,Set(FLAG=2)<br />
exten =&gt; 1,n,GoToIf($[${NUMBER} = ""]?empty:full)<br />
exten =&gt; 1,n(empty),System(/usr/bin/call/mailnonumber.sh callback@test.org ${CALLERID(num)} Queue3)<br />
exten =&gt; 1,n,Hangup()<br />
exten =&gt; 1,n(full),System(/usr/bin/call/mailnumber.sh ${NUMBER} callback@test.org ${CALLERID(num)} Queue3)<br />
exten =&gt; 1,n,Hangup()</p>
<p>exten =&gt; h,1,NoOp(${FLAG})<br />
exten =&gt; h,2,GoToIf($[${FLAG} = 1]?h|3:h|4)<br />
exten =&gt; h,3,System(/usr/bin/call/mailnonumber.sh callback@test.org ${CALLERID(num)} Queue3)<br />
exten =&gt; h,4,Hangup()<br />
</em></div>
<p>&nbsp;</p>
<div>As we are talking about queues, we are going to create three different queues in the <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queues_conf.html"><strong>queues.conf</strong></a> configuration file</div>
<p>&nbsp;</p>
<div>The configuration:</p>
<p><em>[general]</p>
<p>[default]</p>
<p>[queue1]</p>
<p>music = default<br />
strategy = ringall<br />
timeout=15<br />
retry = 5<br />
context = queue1out<br />
periodic-announce-frequency = 60<br />
periodic-announce = Call_Back_1</p>
<p>member =&gt; IAX2/user1<br />
member =&gt; IAX2/user2<br />
member =&gt; IAX2/user3<br />
member =&gt; IAX2/user4<br />
member =&gt; IAX2/user5<br />
member =&gt; IAX2/user6<br />
member =&gt; IAX2/user7<br />
member =&gt; IAX2/user8<br />
member =&gt; IAX2/user9</p>
<p>[queue2]</p>
<p>music = default<br />
strategy = ringall<br />
timeout=15<br />
retry = 5<br />
context = queue2out<br />
periodic-announce-frequency = 60<br />
periodic-announce = Call_Back_1</p>
<p>member =&gt; IAX2/user1<br />
member =&gt; IAX2/user2<br />
member =&gt; IAX2/user3<br />
member =&gt; IAX2/user4<br />
member =&gt; IAX2/user5<br />
member =&gt; IAX2/user6<br />
member =&gt; IAX2/user7<br />
member =&gt; IAX2/user8<br />
member =&gt; IAX2/user9</p>
<p>[queue3]</p>
<p>music = default<br />
strategy = ringall<br />
timeout=15<br />
retry = 5<br />
context = queue3out<br />
periodic-announce-frequency = 60<br />
periodic-announce = Call_Back_1</p>
<p>member =&gt; IAX2/user1<br />
member =&gt; IAX2/user2<br />
member =&gt; IAX2/user3<br />
member =&gt; IAX2/user4</em></div>
<div>Now let’s take a look at the shell script you will need if you want to send emails with the left number. The script will use the <strong>mime-construct</strong> program to create the email message and send it to the desired recipient. The second script has the same purpose and the only change is in the body of the email message.</div>
<p>&nbsp;</p>
<div>Here are the configurations:</p>
<p><strong><span style="text-decoration: underline;">Script 1:</span></strong></p>
<p><em>#!/bin/sh</p>
<p>NUMBER=$1<br />
RECIPIENT=$2<br />
CALLERID=$3<br />
QUEUE=$4</p>
<p>mime-construct &#8211;to $RECIPIENT &#8211;subject &#8220;You have just missed a call&#8221; &#8211;string &#8220;The number that have been left by the caller: $NUMBER. The CallerID we have received: $CALLERID. The call is coming from the $QUEUE queue. Call was received at `date`&#8221;</em></p>
<p><strong><span style="text-decoration: underline;">Script 2:</span></strong></p>
<p><em>#!/bin/sh</p>
<p>RECIPIENT=$1<br />
CALLERID=$2<br />
QUEUE=$3</p>
<p>mime-construct &#8211;to $RECIPIENT &#8211;subject &#8220;You have just missed a call&#8221; &#8211;string &#8220;The caller did not left a telephone number. The CallerID we have received: $CALLERID. The call is coming from the $QUEUE queue. Call was received at `date`&#8221;</em></div>
<p>&nbsp;</p>
<div></div>
<p><span style="text-decoration: underline;"><em>4. Explanation</em></span></p>
<div>Now, we are going to explain you what the configurations about actually means and how it works.</p>
<p>However, keep in mind that we are going to explain you only the configurations concerning the Callback possibility. If you want to learn more about the used configuration files and their options &#8211; take a look at one of our tutorials:</p>
<div><em><a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/iax_conf%20internall" target="_blank">iax.conf</a><br />
<a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/extensions_conf.html">extensions.conf</a><br />
<a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queues_conf.html">queues.conf</a></em></div>
<p><span style="text-decoration: underline;">Let&#8217;s start with <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queues_conf.html"><em>queues.conf</em></a></span>.</p>
<div>In the example above you could see three different queues each one with different number of agents.</p>
<p>Each queue has its own configuration. Most of the settings are common, unless one option &#8211; the <strong>context</strong>.</p>
<p>This option is giving you the possibility to define a context, where eventually, by pressing a single digit, the caller will be &#8220;transferred&#8221;. The digit could be pressed at any time while the caller is waiting in the queue. The context we are talking about has to be created in the <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/extensions_conf.html">extensions.conf</a> configuration file. There is one more requirement and it is that you have to create an extension of one digit, in this context &#8211; the digit that the caller will press in order to exit the queue.</p>
<p>Despite of the fact, that for all the queues, the setup for leaving a number and then emailing it to our email address will be pretty much the same, we recommend you to create different contexts for every different queue. That is because we are going to email not only the left number but also some other information such as the queue from which the caller has quitted. Of course you could do it with one common and more complicated context for all the queues, but we think that it will be much easier to manage and change the settings for each queue independently of the other ones.</p>
<p>So here are all the options in our queue and what they are doing&#8221;</p>
<div><em>music = default</em> &#8211; the music class defined in <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/musiconhold_conf" target="_blank"><em>musiconhold.conf</em></a>, where Asterisk will be looking for mp3 files, which will be played to the caller instead of ringing tone, while he is waiting in the queue.<br />
<em>strategy = ringall</em> &#8211; one of six ringing strategies that you could choose. This one means the phone of each agent, assigned to the queue, will start ringing in case of incoming call. For details about the other strategies take a look at our tutorial about <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queues_conf.html">queues.conf</a><br />
<em>timeout=15</em> &#8211; a timeout in seconds. It defines after how many seconds with no answer the agent phone to stop ringing. For more information about refer to our tutorial about <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queues_conf.html">queues.conf</a> .<br />
<em>retry = 5</em> &#8211; after how many seconds to try to ring all the agents again. For more information about refer to our tutorial about <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queues_conf.html">queues.conf</a>.<br />
<em>context = queue3out</em> &#8211; we have already explained this above.<br />
<em>periodic-announce-frequency = 60</em> &#8211; define in seconds an interval of time after which the caller, waiting in the queue, will hear a prerecorded message. It could be a message with instructions or something else. It is up to you. For more information about refer to our tutorial about <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queues_conf.html">queues.conf</a>.<br />
<em>periodic-announce = Call_Back_1</em> &#8211; that is the name of the prerecorded message that should be played after the periodic announce timeout expires. For more information about refer to our tutorial about <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queues_conf.html">queues.conf</a>.</p>
<p><em>member =&gt; IAX2/user1</em> &#8211; there are two different ways to assign agents to a specific queue. We have picked up the easies one. Whenever a phone with username <strong>user1</strong> is registered successfully to the Asterisk system, the incoming calls in the queue will be send to this phone. You could have as many as you want agents assigned to the queue in this way and the incoming call will be send to all of them according to the chosen strategy. For more information about refer to our tutorial about <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queues_conf.html">queues.conf</a>.</div>
</div>
<p><span style="text-decoration: underline;">Now let&#8217;s take a look at the configurations in <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/extensions_conf.html">extensions.conf</a>.</span></p>
<div>First of all we have three extensions for the incoming calls. They are all put in the <strong>[incoming_calls]</strong> context. Their purpose is to put the incoming calls in the corresponding queue.</p>
<p>When we have an incoming call, the first thing we are doing is to change the Callerid name to the name of the queue where the caller will be put. Thus the agent who is answering the call will know from which queue exactly the call is coming. It is not absolutely necessary, but the idea is that one agent could be assigned to many different queues. In order to do the change we are using the <em><a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/set.html">Set application &#8211; More information about it in our tutorial</a></em></p>
<p>The next step is to actually send the call in the queue &#8211; pretty easy one. There is an application called <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queue.html"><em>Queue</em></a> to which you just have to pass the name of the desired queue as an argument. We are not going to use any extra options. You could <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queue.html"><em>find more information about how to use the QUEUE application in our tutorial</em></a></p>
<p>You could notice and the usage of the <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/hangup.html"><em>Hangup application</em></a>. It is always a good idea to use it as last application for all of your extensions. Thus, you will always be sure that the used channel will be released when the conversation is over. <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/hangup.html"><em>Refer to our tutorial for more information on this application</em></a></p>
<p>Next step is to create the contexts, where the callers should be &#8220;transferred&#8221; in case they have decided to exit the queue. As we have mentioned above we have different context for each of the queue.</p>
<p>Before we continue &#8211; a few words about the idea behind. We are running queues with a callback option. In other words, when we have a caller waiting in the queue, we will play him a message every 60 seconds. The message will saying: <em>&#8220;All of our lines are busy. You could leave your number by pressing one and we will call you back as soon as possible or you could stay in the queue and wait to be served.&#8221;</em>.</p>
<p>If the caller decides to exit the queue, he will be asked to leave his number after the &#8220;beep&#8221; signal. At this stage, you have to keep in mind that the caller might not leave his number for some reason. So what we will have a check and if the number is not left we will send an email message that the caller has decided not to leave his number.</p>
<p>So what do we need as extensions? The first thing we are doing is to set a flag. Why? In case the caller hangs up at some point before leaving his number, we need to send a message that we did not received the number. For the purpose we are using the so called <strong>predefined</strong> extension &#8211; <strong><em>h</em></strong>, which allows you to execute something in case of hang up. <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/extensions_conf.html"><em>Refer to our tutorial for more information</em></a></p>
<p>However, there is a slight chance that the caller might wait for the timeout to expires without leaving his number or to have a problem with the sending of DTMF tone, that we will have an email saying that the caller has left his number but the number field will be empty and because we have a hang up event even if the caller has left his number, we need the flag to determine whether the hang up is before the application that will store the number or after it and on that basis we will know whether we need to send an email message on hang up or not. In this way we omit the sending of one message twice.</p>
<p>On the next step we have the <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/playback.html"><em>Playback application</em></a>. Its simple purpose is to play a sound files. We have a sound message, which instructs the caller to type his number after the beep tone and to press the pound key (#) when he is ready. For more information <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/playback.html"><em>refer to our tutorial about the Playback application</em></a></p>
<p>Next, comes the <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/read.html"><em>Read application</em></a>. It’s the one used to store the number typed by the caller. It has many options.</p>
<p>There is a small limitation in the application we are going to use to save the number typed by the caller. We need to know, when he has finished with the typing. So there are two ways.</p>
<p>The first one is to ask him to press the pound key (#) once he is ready and the second one is to limit the length of the number the caller could type plus a timeout.<br />
In our example we are going to limit the length of the number to 10 digits and we are going to put a timeout of 5 seconds. We are going to store the number typed by the caller in the <strong>NUMBER</strong> variable. The <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/read.html"><em>Read application</em></a> gives you the possibility to play a sound file before the typing of the number. In our case we will are going to play a <strong>beep</strong> tone</p>
<p><a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/read.html"><em>Refer to our tutorial for more information and details about the Read application</em></a></p>
<p>Next steps &#8211; we have the <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/wait.html"><em>Wait application</em></a>, which is not absolutely necessary and then we set the flag variable to <strong>2</strong>. This, as we have already described above will be used to omit the sending of one and the same email message twice. For more information about the Wait application, <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/wait.html"><em>refer to our tutorial</em></a>.</p>
<p>We now have to check whether the caller has actually left his number or not. For the purpose we can use the <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/gotoif.html"><em>GoToIf application</em></a>. It has a very specific syntax, but its idea is simple to verify whether one condition is true or false. So, in our case we are just checking whether the <strong>NUMBER</strong> variable is empty or not. If it is empty then the execution of the dialplan will continue with the next step, marked as <strong>n(empty)</strong>. <strong>n</strong> makes your life easier as you do not have to write and follow the steps (priorities) &#8211; <strong>n</strong> means that you take the previous priority and increase it with 1. <strong>(empty)</strong> is a label showing to you and the system to which <strong>n</strong> you will be send.</p>
<p>If the <strong>NUMBER</strong> variable contains even one digit then we assume that we have the number of the caller so the execution of the dialplan will be send to the step with label <strong>(full)</strong>. Refer to our <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/gotoif.html"><em>Tutorial for more information, details and option about the GoToIf application</em></a>.</p>
<p>Both steps <strong>(empty)</strong> and <strong>(full)</strong> have one and the same task &#8211; to execute the shell script, which will form the email message and send it. The only difference would be in the body of the email message. The application, which we have to use is called <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/system.html"><em>System</em></a>. It just executes system commands as you will do it in your Linux CLI. Refer to our <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/system.html"><em>Tutorial for more information about the System application</em></a>.</p>
<p>In our case we are executing our own scripts called <strong>mailnumber</strong> and <strong>mailnonumber</strong>. They are written in such way that we have to pass them a few parameters. You could see them above as screenshots and in pure text</p>
<p>If we do not have the caller&#8217;s number, we will execute the script called <strong>mailnonumber</strong>. We need to add, as first parameter, the email address of the recipient. The second parameter is the CallerId number as we have received it in our system. The last parameter is the name of the queue from which the caller has exited.</p>
<p>If we have the caller&#8217;s number we will have executed another shell script called <strong>mailnumber</strong> which has a different body, but the same parameters plus one more, which of course is the number left by the caller.</p>
<p>The sending of the email is the last step we need to do and that is why after it we have to hang up the channel. For the purpose we will use once again the <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/hangup.html"><em>Hangup application</em></a>.</p>
<p>In the <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/extensions_conf.html"><em>predefined extensions</em></a> starting with <strong>h</strong> we have a simple check of the <strong>FLAG</strong> variable to help use determine whether we have to send an email with saying that we do not have the caller&#8217;s number. (this step is only needed in case the caller hangs up before the prompt to leave his number)</div>
<p><span style="text-decoration: underline;">A few words about the shell scripts.</span></p>
<div>They are not very complicated. All you need is a basic knowledge of shell scripts and the <strong><em>mime-construct package</em></strong>. <strong>apt-get install mime-construct</strong> (in Debian) and you will have it. Then its just up to the <strong>mime-construct&#8217;s</strong> syntax</div>
<p>Now all you have to do is to register your <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tools/idefisk_beta.php" target="_blank">IAX2 base softphone Idefisk</a> to your Asterisk system with the settings, shown above, in <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/iax_conf.html"><em>iax.conf</em></a> and dial one of the extensions created in the <strong>[incoming_calls]</strong> context.</p>
<p>What will happen (if you have followed our setup) is that you will be put in a queue and on every 60 seconds you will hear a message saying that you could exit the queue and leave your number by pressing 1. If you press one you will hear a prompt to leave you number after the signal. Then you will hear beep and if you leave your number followed by the pound key (#), the number will be emailed to the desired email address and you will probably receive a callback.</p></div>
<p>&nbsp;</p>
<div></div>
<p><strong><span style="text-decoration: underline;">4. Uploaded files</span></strong></p>
<div><a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/274673/extensions.conf">extensions.conf</a><br />
<a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/274674/iax.conf">iax.conf</a><br />
<a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/274675/queues.conf">queues.conf</a><br />
<a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/274676/mailnumber.sh">mailnumber.sh</a><br />
<a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/274677/mailnonumber.sh">mailnonumber.sh</a></div>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/voip/asterisk/create-callback-option.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatically call all phones to check if they work</title>
		<link>http://thegioinguonmo.com/voip/asterisk/automatically-call-phones-check-work.html</link>
		<comments>http://thegioinguonmo.com/voip/asterisk/automatically-call-phones-check-work.html#comments</comments>
		<pubDate>Wed, 22 Feb 2012 09:05:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Asterisk]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[voip]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2327</guid>
		<description><![CDATA[1. Description: The purpose of this system is the automated testing of all accounts which can receive calls, with the Echo() application. It is based on a bash script which creates a call file and an extension in the dialplan. Basically when the system is started the script selects all users, starts calling (via call [...]]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: underline;"><strong>1. Description:</strong></span></p>
<div>The purpose of this system is the automated testing of all accounts which can receive calls, with the Echo() application. It is based on a bash script which creates a call file and an extension in the dialplan. Basically when the system is started the script selects all users, starts calling (via call files) them one after another. This is very basic example of the &#8220;reverse application manipulation&#8221;.</div>
<p><span style="text-decoration: underline;"><strong>2. Pre-setup:</strong></span></p>
<div>Before running through the core of this tutorial, let&#8217;s make some small preparations for it.</p>
<div></div>
<div><em>* </em>Ensure that you have a working Asterisk server.<br />
<em>* </em>Ensure that you have rights to read/write at /var/spool/asterisk directory.<br />
<em>* </em>Ensure that you have rights to write in /etc/asterisk/extensions.conf file.<br />
<em>* </em>Make a recording of the following announcement: &#8220;This is an automated test. Excuse us for the inconvenience. After the signal you will be able to hear your voice like an echo. If you are unable to hear your voice, please press the pound key. By pressing the pound key we will be notified for your problem.&#8221;<br />
<em>* </em>Make a recording of the following announcement: &#8220;We have been notified for your problem. We will contact you with more information.&#8221;</div>
</div>
<p><span style="text-decoration: underline;"><strong>3. Setup:</strong></span></p>
<div>The setup that we are going to use has the following properties: the system should find all users for curtain channel (iax2 or sip). Every user is been called by the Asterisk and is been greeted with <em>announcement one</em>. We will set an absolute timeout to two minutes (120 seconds). After that the Echo() application is going to start in order to make the test. If the user hangs up, Asterisk will do nothing, and the system is going to call the next user. If the user press the pound key, the system is going to run a program or script which will notify us for the problem.</p>
<p><span style="text-decoration: underline;">Step 3.1: Creating the needed extensions</span><br />
Let&#8217;s create the extension that we are going to use. Since we are going to use a call file, there is no significance where (at which context) the extension will be placed. For this tutorial we will create a special context named `echotest`. Here what you have to do:</p>
<pre>	Open your extensions.conf using a text redactor.
	At the bottom of the file (on new line) add new context by typing `[echotest]` (without the quotes).
	Add the following extension:
		exten =&gt; echo,1,<span style="text-decoration: underline;">Answer</span>()
			<em>; Answer the line</em>
		exten =&gt; echo,n,<span style="text-decoration: underline;">Set</span>(<span style="text-decoration: underline;">TIMEOUT</span>(<span style="text-decoration: underline;">absolute</span>)=120)
			<em>; Sets maximum length of the call to two minutes (if someone forgets to hang up)</em>
		exten =&gt; echo,n,<span style="text-decoration: underline;">Playback</span>(<span style="text-decoration: underline;">file1</span>)
			<em>; Playbacks file named `f1`. The user will hear the contents of `f1`</em>
			<em>; In our tutorial `f1` is the first announcement that we have recorded.</em>
		exten =&gt; echo,n,<span style="text-decoration: underline;">Echo</span>()
			<em>; starting Echo() application which will create the echo effect</em>
		exten =&gt; echo,n,<span style="text-decoration: underline;">Playback</span>(<span style="text-decoration: underline;">f2</span>)
			<em>; Playbacks file named `f2`. The user will hear the contents of `f2`</em>
			<em>; In our tutorial `f2` is the first announcement that we have recorded.</em>
		exten =&gt; echo,n,<span style="text-decoration: underline;">System</span>(<span style="text-decoration: underline;">/bin/notify_us ${CUR}</span>)
			<em>; Notification script which will notify us that curtain user is experiencing problems.</em>
		exten =&gt; echo,n,<span style="text-decoration: underline;">HangUp</span>()
			<em>; Hangs up the call.</em></pre>
<p>Here is an screenshot of what it should look like:</p>
<p>This extension is very usefull even if you use it alone (without the script). If the user follows the instructions, there are two possible outcomes:</p>
<div><em>* </em>the user hears his voice and hangs up the call. In this case Asterisk will terminate the call and the second part of the extension won&#8217;t execute (the part with second playback and running notification program/script). The user may not hang up the call, but because of the absolute timeout that we have set, the call will be termincated in 120 seconds. If we look at Asterisk console, the output should be something like this:</p>
<p><em>* </em>the user doesn&#8217;t hear his voice, and presses the pound key. In this case, Asterisk will continue with the next priority of the extension (which is the run of the notification program/script). If we look at Asterisk console, the output should be something like this:</div>
<p><strong>Remark:</strong> if you have only write access to /<em>etc</em>/<em>asterisk</em>/<em>extensions</em>.<em>conf </em>, create somewhere a file in which write the context and the extension. Then run the command:</p>
<pre>		`<strong><span style="text-decoration: underline;">cat</span> /<em>route</em>/<em>to</em>/<em>somewhere</em>/<em>file </em>&gt;&gt; /<em>etc</em>/<em>asterisk</em>/<em>extensions.conf</em></strong>`</pre>
<p>where `/<em>route</em>/<em>to</em>/<em>somewhere</em>/<em>file</em>` is the path and the file in which you have written the thing.</p>
<p><span style="text-decoration: underline;">Step 3.2: Preparation for the creation of call files</span><br />
Now let&#8217;s create a prototype for our call files. We will create it in /var/spool/asterisk/ directory. However the location of the prototype is not important for script (<em>the location have to differs important dirs like </em>`/<em>dev</em>`, `/<em>boot</em>`, `/<em>var</em>/<em>spool</em>/<em>asterisk</em>/<em>outgoing</em>`, <em>etc</em>&#8230;).</p>
<pre>	Context: <span style="text-decoration: underline;">echotest</span>
		# Asterisk will execute extension in this string
	Extension: <span style="text-decoration: underline;">echo</span>
		# Name of the extension
	Priority: <span style="text-decoration: underline;">1</span>
		# At which priority Asterisk will begin the execution
	Callerid: <span style="text-decoration: underline;">Automated Test System &lt;&gt;</span>
		# Setting the CallerID to the specified string.</pre>
<p>If you copy/paste the protoype file, notice that you have to remove the comments marked with <strong>#</strong>. Asterisk will not escape those comments, and their might lead to unexpected results. The file should look like this one:</p>
<div></div>
<p>You may notice that the only not optional keyword for the call files (Channel: CHAN/USER) is missing. Don&#8217;t worry we will not make with this file. We will just use it for creation of the actual call files. We will use this prototype call file with the filename `echotest.org.call` at the following directory: /var/spool/asterisk/ echotest-$i.call;</p>
<p><span style="text-decoration: underline;">Step 3.3: Making a list of people to call</span><br />
Now let&#8217;s create a small bash script which will make the whole work for us.<br />
We will need to get all users which are added to our configuration files. There are two ways to do this:</p>
<div>1. parsing sip.conf or accordingly iax.conf &#8211; you have to have read access to those files if you want to proceed in this way.</p>
<div><em>cat /etc/asterisk/$1.conf | grep -a &#8216;[' | grep -a ']&#8216; | grep -va &#8216;;[' | cut -d[ -f 2 | cut -d] -f 1</em></div>
<p>2. parsing the console output for the actually loaded users into the memory of our Asterisk server.</p>
<div><em>asterisk -rx &#8220;$1 list users&#8221; | grep -va Username | grep -va Verbosity | grep -va &#8220;UNIX Connection&#8221; | cut -d -f 1</em></div>
</div>
<p>Both methods have both pros and cons:</p>
<div><em>* </em>parsing the configuration files &#8211; we will write a bash script for this method. We will name it `example1`.</p>
<div>- configuration files might be very long (parsing them might be a slow task)<br />
- there might be more than one configuration file<br />
- there might be some account which are not activated (if someone made changes in them, but haven&#8217;t reloaded Asterisk)<br />
+ configuration files are more predictable and there are less things that you should escape</div>
<p><em>* </em>parsing console output &#8211; we will write a bash script for this method. We will name it `example2`.</p>
<div>- you have to mess with the verbose level of Asterisk in order to escape the NOTICES and ERRORS. This might escape important events.<br />
+ console output is far shorter (as length of the information) than the configuration files</div>
</div>
<div>
<div>`example1`<br />
#! /bin/bash</p>
<p>cd /var/spool/asterisk;</p>
<p>for i in $(cat /etc/asterisk/$1.conf | grep -a &#8216;[' | grep -a ']&#8216; | grep -va &#8216;;[' | cut -d[ -f 2 | cut -d] -f 1); do<br />
echo &#8220;Channel: $1/$i&#8221; &gt;&gt; echotest-$i.call;<br />
cat echotest.org.call &gt;&gt; echotest-$i.call;<br />
echo &#8220;SetVar: CUR=$1/$i&#8221; &gt;&gt; echotest-$i.call;<br />
echo &#8221; &#8212; Makeing echo test with $1/$i&#8221;;<br />
sleep 120;<br />
mv echotest-$i.call outgoing/<br />
done;</p></div>
</div>
<p>Run the script in the following way:<br />
./echotest iax to test IAX2 users<br />
./echotest sip to test SIP users</p>
<div></div>
<p>`example2`</p>
<div>
<div>
#! /bin/bash</p>
<p>cd /var/spool/asterisk;</p>
<p>for i in $(asterisk -rx &#8220;$1 list users&#8221; | grep -va Username | grep -va Verbosity | grep -va &#8220;UNIX Connection&#8221; | cut -d -f 1); do<br />
echo &#8220;Channel: $1/$i&#8221; &gt;&gt; echotest-$i.call;<br />
cat echotest.org.call &gt;&gt; echotest-$i.call;<br />
echo &#8220;SetVar: CUR=$1/$i&#8221; &gt;&gt; echotest-$i.call;<br />
echo &#8221; &#8212; Makeing echo test with $1/$i&#8221;;<br />
sleep 120;<br />
mv echotest-$i.call outgoing/<br />
done;</p></div>
</div>
<p>Run the script in the following way:<br />
./echotest IAX2 to test IAX2 users<br />
./echotest SIP to test SIP users</p>
<p><span style="text-decoration: underline;">Step 3.4: Improve the scripts to reduce the amount of extensions we forgot to call</span></p>
<p>`example1`</p>
<div>
<div>
#! /bin/bash</p>
<p>cd /var/spool/asterisk;</p>
<p>for i in $(cat /etc/asterisk/$1.conf | grep -a &#8216;[' | grep -a ']&#8216; | grep -va &#8216;;[' | cut -d[ -f 2 | cut -d] -f 1); do<br />
echo &#8220;Channel: $1/$i&#8221; &gt;&gt; echotest-$i.call;<br />
cat echotest.org.call &gt;&gt; echotest-$i.call;<br />
echo &#8220;SetVar: CUR=$1/$i&#8221; &gt;&gt; echotest-$i.call;<br />
echo &#8221; &#8212; Makeing echo test with $1/$i&#8221;;<br />
sleep 121;<br />
mv echotest-$i.call outgoing/<br />
done;</p>
<p>for j in $(cat iax.conf | grep -a &#8220;include&#8221; | cut -d -f 3); do<br />
echo &#8221; &#8212; Parsing included file $j&#8221;;<br />
for f in $(cat $j | grep -a &#8216;[' | grep -a ']&#8216; | grep -va &#8216;;[' | cut -d[ -f 2 | cut -d] -f 1); do<br />
echo &#8220;Channel: $1/$f&#8221; &gt;&gt; echotest-$i.call;<br />
cat echotest.org.call &gt;&gt; echotest-$i.call;<br />
echo &#8220;SetVar: CUR=$1/$f&#8221; &gt;&gt; echotest-$i.call;<br />
echo &#8221; &#8212; Makeing echo test with $1/$i&#8221;;<br />
sleep 121;<br />
mv echotest-$i.call outgoing/<br />
done;<br />
done;</p></div>
</div>
<p>Run the script in the following way:<br />
./echotest iax to test IAX2 users<br />
./echotest sip to test SIP users</p>
<div></div>
<p>`example2`</p>
<div>
<div>
#! /bin/bash</p>
<p>cd /var/spool/asterisk;</p>
<p>OldVerbose=`asterisk -rx &#8220;set verbose 1&#8243; | grep was | cut -d -f 3`</p>
<p>echo Verbose will be set to 0. Old Verbose (equal to $OldVerbose) will be restored later;</p>
<p>asterisk -rx &#8220;set verbose 0&#8243;;</p>
<p>cd /var/spool/asterisk;</p>
<p>for i in $(asterisk -rx &#8220;$1 list users&#8221; | grep -va Username | grep -va Verbosity | grep -va &#8220;UNIX Connection&#8221; | cut -d -f 1); do</p>
<p>echo &#8220;Channel: $1/$i&#8221; &gt;&gt; echotest-$i.call;<br />
cat echotest.org.call &gt;&gt; echotest-$i.call;<br />
echo &#8220;SetVar: CUR=$1/$i&#8221; &gt;&gt; echotest-$i.call;<br />
echo &#8221; &#8212; Makeing echo test with $1/$i&#8221;;<br />
sleep 121;<br />
mv echotest-$i.call outgoing/<br />
done;<br />
asterisk -rx &#8220;set verbose $OldVerbose&#8221;;</p></div>
</div>
<p>Run the script in the following way:<br />
./echotest IAX2 to test IAX2 users<br />
./echotest SIP to test SIP users</p>
<div></div>
<p>The second version of those scripts were upgraded in some ways:<br />
configuration file parsing &#8211; recurse search and parse of included files<br />
configuration file parsing &#8211; script will place a message on the console for every user it calls<br />
configuration file parsing &#8211; script will place a message on the console for file it starts to parse<br />
console output &#8211; escape most of the messages by temporally setting the VERBOSE level to 0<br />
configuration file parsing &#8211; script will place a message on the console for every user it calls</p>
<p>I am sure that the reader of this tutorial will try to modify these scripts. That&#8217;s why I will leave some notifications which will help you:<br />
SetVar: CUR=$1/$i &#8211; is setting a variable in the dialplan so Asterisk will be able to notify (in some way) that a problem occurred with curtain user<br />
sleep 121; &#8211; removing this line may case the following problem &#8211; Asterisk will try to dial too much calls and might crash.<br />
sleep 121; &#8211; setting a different value to the sleep command may cause the following bug &#8211; Asterisk will change the ${CUR} variable and if the user presses the pound key, you might be notified for an other user.</p></div>
<p>Enjoy your testing!</p>
]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/voip/asterisk/automatically-call-phones-check-work.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Asterisk Installation on CentOS</title>
		<link>http://thegioinguonmo.com/voip/asterisk/asterisk-installation-centos.html</link>
		<comments>http://thegioinguonmo.com/voip/asterisk/asterisk-installation-centos.html#comments</comments>
		<pubDate>Wed, 22 Feb 2012 09:01:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Asterisk]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[voip]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2322</guid>
		<description><![CDATA[The first step that you should make is to you to choose which version of Asterisk you want to install. * Asterisk 1.2 &#8211; the stable version * Asterisk 1.4 &#8211; the version that is currently in beta testing When you know which version you want to install download the according packages. Note that we [...]]]></description>
			<content:encoded><![CDATA[<p>The first step that you should make is to you to choose which version of Asterisk you want to install.</p>
<div><em>* </em>Asterisk 1.2 &#8211; the stable version<br />
<em>* </em>Asterisk 1.4 &#8211; the version that is currently in beta testing</div>
<p>When you know which version you want to install download the according packages.</p>
<p>Note that we will install also libpri and zaptel packages. They are optional for Asterisk but if you want to use Asterisk with MeetMe (see <a rel="nofollow" target="_blank" href="http://asteriskguru.com/tutorials/meetme.html" target="_blank">MeetMe application</a> and <a rel="nofollow" target="_blank" href="http://asteriskguru.com/tutorials/meetme_conf.html" target="_blank">meetme.conf</a>) or to use MusicOnHold you&#8217;ll have to install zaptel. The <a rel="nofollow" target="_blank" href="http://asteriskguru.com/tutorials/wildcard_tdm400p.html" target="_blank">TDMoE cards</a> will also need the zaptel module in order to work correctly. If you will use <a rel="nofollow" target="_blank" href="http://asteriskguru.com/tutorials/pri.html" target="_blank">PRI cards</a> you&#8217;ll have to install libpri module.</p>
<div><ins><ins id="aswift_0_anchor"><br />
</ins></ins><strong>For Asterisk 1.2:</strong></p>
<div><em>* </em><a rel="nofollow" target="_blank" href="http://ftp.digium.com/pub/asterisk/releases/asterisk-1.2.13.tar.gz" target="_blank">Asterisk sources</a><br />
<em>* </em><a rel="nofollow" target="_blank" href="http://ftp.digium.com/pub/zaptel/releases/zaptel-1.2.11.tar.gz" target="_blank">Zaptel sources</a><br />
<em>* </em><a rel="nofollow" target="_blank" href="http://ftp.digium.com/pub/libpri/releases/libpri-1.2.4.tar.gz" target="_blank">Libpri sources</a></div>
<p><strong>For Asterisk 1.4:</strong></p>
<div><em>* </em><a rel="nofollow" target="_blank" href="http://ftp.digium.com/pub/asterisk/asterisk-1.4.0.tar.gz" target="_blank">Asterisk sources</a><br />
<em>* </em><a rel="nofollow" target="_blank" href="http://ftp.digium.com/pub/zaptel/zaptel-1.4.0.tar.gz" target="_blank">Zaptel sources</a><br />
<em>* </em><a rel="nofollow" target="_blank" href="http://ftp.digium.com/pub/libpri/libpri-1.4.0.tar.gz" target="_blank">Libpri sources</a></div>
<div></div>
<div>
<p>Now check the exact version of your kernel. You can achieve this by typing `uname -a`. The output should be something like this: `<em>Linux luser <strong>2.6.17-1.2142</strong>_EL #1 Tue Jul 11 22:41:14 EDT 2006 i686 i686 i386 GNU/Linux</em>`. Check if you are using 2.6 or 2.4 kernel. Notice that. We&#8217;ll need this info later. You should check if you have installed the kernel sources (<em>for the current version of the kernel</em>) on your machine. To achieve this type `rpm -q kernel-devel` The output of the screen should be something like this:</p>
<p>Note that if you don&#8217;t have kernel sources you should install them. You can use <strong>yum</strong> again: `<em>yum install kernel-devel</em>`. If you use this command <strong>yum</strong> will install the sources for your current version of the kernel.</p>
<p>It is time to check for the availability of some other packages:</p>
</div>
<blockquote>
<div>
<div>rpm -q bison<br />
rpm -q bison-devel<br />
rpm -q ncurses<br />
rpm -q ncurses-devel<br />
rpm -q zlib<br />
rpm -q zlib-devel<br />
rpm -q openssl<br />
rpm -q openssl-devel<br />
rpm -q gnutls-devel<br />
rpm -q gcc<br />
rpm -q gcc-c++</div>
</div>
</blockquote>
<p>If any of those packages are not installed install them by using yum</p>
<blockquote>
<div>yum install bison<br />
yum install bison-devel<br />
yum install ncurses<br />
yum install ncurses-devel<br />
yum install zlib<br />
yum install zlib-devel<br />
yum install openssl<br />
yum install openssl-devel<br />
yum install gnutls-devel<br />
yum install gcc<br />
yum install gcc-c++</div>
<div></div>
</blockquote>
<p>If yum is unable to find one or more of these packages, try your luck with <a rel="nofollow" target="_blank" href="http://rpm.pbone.net/" target="_blank">PBone</a>. You should find the required packages there. When you download them, install them with either of those:</p>
<div>rpm -i PACKAGE.rpm<br />
rpm -Uvh PACKAGE.rpm</div>
<div></div>
<div>
<p>CentOS doesn&#8217;t install the kernel sources into the <em>/usr/src/linux</em> directory as is written in Zaptel&#8217;s and Asterisk&#8217;s Makefile. Go to `<em>/usr/src</em>` and create a link named &#8216;<em>linux</em>&#8216; to your kernel sources directory (<em>the default place for your kernel&#8217;s sources is /usr/src/kernels/&#8230;</em>). The result should look like this:</p>
<p>Now extract the downloaded sources by the command `<strong><em>tar -vxzf PACKAGE.tar.gz</em></strong>`, where PACKAGE.tar.gz are the packages that we downloaded (libpri, zaptel and asterisk itself).</p>
<p><strong>Installing Libpri:</strong></p>
</div>
<div>
<p>&nbsp;</p>
<pre class="brush:shell">cd /path/to/source/libpri
make
make install</pre>
<p><strong>Installing Zaptel:</strong></p>
</div>
<div>cd /usr/src/asterisk/zaptel<br />
# if you have a 2.4 kernel you should type just make<br />
make<br />
# if you have a 2.6 kernel you should type make linux26<br />
make linux26 &#8211; if you have a 2.6 kernel<br />
make install</div>
<div></div>
<p><strong>Installing Asterisk:</strong></p>
<div>cd /usr/src/asterisk/asterisk<br />
# before making Asterisk you have to install mpg123 package (to be able to play mp3 files for music on hold).<br />
make mpg123<br />
# for Asterisk v1.4 you should start configure script</div>
<div>
<pre class="brush:shell">./configure
make
make install
make samples</pre>
</div>
<div></div>
<p>In order to verify the asterisk installation start your asterisk daemon by typing `safe_asterisk` and connect to its console by typing `asterisk -vvvvvr`. Now reload the entire configuration by typing `reload`.</p>
</div>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/voip/asterisk/asterisk-installation-centos.html" title="how to install rpm packages in windows">how to install rpm packages in windows</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/voip/asterisk/asterisk-installation-centos.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: thegioinguonmo.com @ 2012-02-23 07:21:04 -->
