<?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>Vargas Emmanuel Weblog</title>
	<atom:link href="http://www2.crapules.com/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://www2.crapules.com/wordpress</link>
	<description>Linux, solaris, IA, AI, robot, robotique, windows, tips, network</description>
	<lastBuildDate>Tue, 16 Sep 2008 12:45:30 +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>Comment a block of text in VIM</title>
		<link>http://www2.crapules.com/wordpress/2008/07/17/comment-a-block-of-text-in-vim/</link>
		<comments>http://www2.crapules.com/wordpress/2008/07/17/comment-a-block-of-text-in-vim/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 13:33:44 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Vrac]]></category>
		<category><![CDATA[block]]></category>
		<category><![CDATA[comment]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[edit]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[texts]]></category>
		<category><![CDATA[vi]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[visual]]></category>
		<category><![CDATA[zone]]></category>

		<guid isPermaLink="false">http://www.crapules.com/wordpress/?p=47</guid>
		<description><![CDATA[it&#8217;s easy to comment a large text zone in VIM: switch in visual mode (CTRL + V) press touch I (upcase i) Enter the comment caractere (# for exemple or // for exemple) And now press ESC. Et voilà!]]></description>
			<content:encoded><![CDATA[<p>it&#8217;s easy to comment a large text zone in VIM:</p>
<p>switch in visual mode (CTRL + V)<br />
press touch <strong>I </strong>(upcase i)<br />
Enter the comment caractere (<strong>#</strong> for exemple or <strong>//</strong> for exemple)<br />
And now press <strong>ESC</strong>.</p>
<p>Et voilà!</p>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2008/07/17/comment-a-block-of-text-in-vim/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dell OpenManage 5 (OMSA) on Debian setup.</title>
		<link>http://www2.crapules.com/wordpress/2008/07/17/dell-openmanage-5-omsa-on-debian-setup/</link>
		<comments>http://www2.crapules.com/wordpress/2008/07/17/dell-openmanage-5-omsa-on-debian-setup/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 09:32:41 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[32]]></category>
		<category><![CDATA[64]]></category>
		<category><![CDATA[64 bits]]></category>
		<category><![CDATA[64bits]]></category>
		<category><![CDATA[apt-get]]></category>
		<category><![CDATA[aptitude]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[deb]]></category>
		<category><![CDATA[dell]]></category>
		<category><![CDATA[dell openmanage]]></category>
		<category><![CDATA[manage]]></category>
		<category><![CDATA[modprobe]]></category>
		<category><![CDATA[mtp]]></category>
		<category><![CDATA[omsa]]></category>
		<category><![CDATA[open]]></category>
		<category><![CDATA[package]]></category>
		<category><![CDATA[paquet]]></category>
		<category><![CDATA[sas]]></category>

		<guid isPermaLink="false">http://www.crapules.com/wordpress/?p=44</guid>
		<description><![CDATA[Cet aricle est tiré du site de john parnefjord. Merci à lui pour ce fabuleux article! Dell OpenManage 5 (OMSA) est maintenant disponible en package .deb. Rien de plus facile pour l&#8217;installer dorénaveant. A condition d&#8217;avoir toutes les informations nécessaires! Dans ce tutoriel nous verrons comment l&#8217;installer rapidement. This article come from the john parnefjord [...]]]></description>
			<content:encoded><![CDATA[<p>Cet aricle est tiré du site de <a href="http://john.parnefjord.se/node/39">john parnefjord</a>. Merci à lui pour ce fabuleux article! <img src='http://www2.crapules.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Dell OpenManage 5 (OMSA) est maintenant disponible en package .deb. Rien de plus facile pour l&#8217;installer dorénaveant. A condition d&#8217;avoir toutes les informations nécessaires!<br />
Dans ce tutoriel nous verrons comment l&#8217;installer rapidement.</p>
<p>This article come from the <a href="http://john.parnefjord.se/node/39">john parnefjord</a> website. Many thanks to him! <img src='http://www2.crapules.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Since the advent of the debianized version of Dell OMSA installation has been a breeze.<br />
Follow this tut to install quickly Dell OpenManage on a Debian system.</p>
<p><span id="more-44"></span></p>
<p><a href="#french">Francais Version</a><br />
<a href="#english">English Version</a></p>
<p><a name="french"><br />
<h2>Français</h2>
<p></a></p>
<p>Ajouter les lignes suivants dans le fichier /etc/apt/sources.list</p>
<p><code>
# OMSA
deb http://ftp.sara.nl/pub/sara-omsa dell sara
</code></p>
<p>Installer OMSA en utilisant apt-get (aptitude installera beaucoup de paquets non nécessaires. je vous conseille d&#8217;utiliser apt-get pour éviter d&#8217;installer des paquets non nécessaires)</p>
<p><code>
apt-get update
apt-get install dellomsa
</code></p>
<p>Si vous utilisez un SAS controleur mpt vous devez charger le module mptctl. Je ne l&#8217;ai pas testé mais j&#8217;ai eu des retours d&#8217;utilisateurs du SAS 5/i storage controllers. Merci pour l&#8217;info!<br />
Il vous suffit de charger le module et de redémarrer OMSA et les informations disques seront accessibles.</p>
<p><code>modprobe mptctl
/etc/init.d/instsvcdrv restart
</code></p>
<p>Attention: sur un noyau 64bits vous ne pourrez pas vous logguer sur l&#8217;interface web tant que vous n&#8217;aurez pas rajouter quelques librairies 32bits et éditer le fichier de conf qui va bien. Si vous avez un kernel 64bits, copiez les fichiers suivants d&#8217;une install 32bits:</p>
<p><code>/lib/libselinux.so.1
/lib/libsepol.so.1
/lib/security/pam_nologin.so
/lib/security/pam_unix.so</code></p>
<p>John a crée un zip avec tt les librairies si vous n&#8217;avez pas d&#8217;install 32bits sous la main. (voir le lien à la fin de l&#8217;article).<br />
Si il n&#8217;existe pas, crée le répertoire /lib32 et copiez y les fichiers. Vous aurez également besoin du paquet ia32-libs qui permet de faire tourner la plupart des applis 32bis avec un noyau 64.</p>
<p>Editez le fichier /etc/pam.d/omauth et remplacez /lib par /lib32:</p>
<p><code>#%PAM-1.0
#auth       required     pam_stack.so service=system-auth
#auth       required    /lib/security/pam_nologin.so
#account    required    pam_stack.so service=system-auth
auth       required     /lib32/security/pam_unix.so nullok
auth       required     /lib32/security/pam_nologin.so
account    required     /lib32/security/pam_unix.so nullok</code></p>
<p>Redémarrer les services:</p>
<p><code>/etc/init.d/instsvcdrv restart</code></p>
<p>Démarrer l&#8217;interface web:</p>
<p><code>/etc/init.d/dsm_om_connsvc start</code></p>
<p>Si vous voulez la lancer automatiquement au démarrage:</p>
<p><code>update-rc.d dsm_om_connsvc defaults 95</code></p>
<p>Et voilà!<br />
Vous n&#8217;avez plus qu&#8217;a vous connecter:</p>
<p>https://192.168.0.10:1311/</p>
<p>Si vous ne pouvez pas vous logguer, vérifiez dans votre syslog. Vous devriez pouvoir vous connecter en utilisant un compte user du serveur. En vous logguant en root, vous devriez avoir accès à toutes les informations. </p>
<p><a name="english"><br />
<h2>English</h2>
<p></a><br />
Just add the following lines to /etc/apt/sources.list</p>
<p><code># OMSA
deb http://ftp.sara.nl/pub/sara-omsa dell sara</code></p>
<p>and then install using</p>
<p><code>apt-get update
apt-get install dellomsa
</code><br />
(using aptitude instead apt-get will install a lot of uneeded packages)</p>
<p>In case you have the mpt-based SAS controller you need to load the mptctl module. I haven&#8217;t tested this myself but I had some feedback from user using the SAS 5/i storage controllers. Thanks for that info! Well, just load the module and restart OMSA and the storage information should be available.</p>
<p><code>modprobe mptctl
/etc/init.d/instsvcdrv restart
</code></p>
<p>On a 64-bit machine you will not be able to login to the web interface unless you add some files from a 32-bit installation and edit a configuration file. So if you have a 64-bit installation of Etch then copy these files from a 32-bit version of an Etch installation:</p>
<p><code>/lib/libselinux.so.1
/lib/libsepol.so.1
/lib/security/pam_nologin.so
/lib/security/pam_unix.so</code></p>
<p>john have put up the files from a Debian Etch 32-bit in case you don&#8217;t have a 32-bit system. See link below.</p>
<p>Start with copying the following libraries to /lib32/. You might need to install the package ia32-libs to get 32-bit applications playing on a 64-bit system.</p>
<p>Edit /etc/pam.d/omauth and replace /lib with /lib32 so the end result looks like this:</p>
<p><code>#%PAM-1.0
#auth       required     pam_stack.so service=system-auth
#auth       required    /lib/security/pam_nologin.so
#account    required    pam_stack.so service=system-auth
auth       required     /lib32/security/pam_unix.so nullok
auth       required     /lib32/security/pam_nologin.so
account    required     /lib32/security/pam_unix.so nullok</code></p>
<p>Restart the services after this change:</p>
<p><code>/etc/init.d/instsvcdrv restart</code></p>
<p>The web service hasn&#8217;t started yet.</p>
<p><code>/etc/init.d/dsm_om_connsvc start</code></p>
<p>If you want it to start after a reboot then run:</p>
<p><code>update-rc.d dsm_om_connsvc defaults 95</code></p>
<p>After this you should be able to login to your server.</p>
<p>https://192.168.0.10:1311/</p>
<p>Check the syslog for errors if you can&#8217;t login. You can login using a ordinary user account on the machine and if logging in as root you will be able to do some more stuff. I believe I don&#8217;t have to tell you that you should be very restrictive about who is having access to this service. </p>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2008/07/17/dell-openmanage-5-omsa-on-debian-setup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress 2.6 is available</title>
		<link>http://www2.crapules.com/wordpress/2008/07/15/wordpress-26-is-available/</link>
		<comments>http://www2.crapules.com/wordpress/2008/07/15/wordpress-26-is-available/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 13:27:55 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Vrac]]></category>
		<category><![CDATA[2.6]]></category>
		<category><![CDATA[version]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.crapules.com/wordpress/?p=41</guid>
		<description><![CDATA[New WordPress version is available right now: Download WordPress 2.6 More information on this brief video tour presentation of 2.6: Read more to see &#8220;what&#8217;s new&#8221; What&#8217;s news? Post Revisions: Wiki-like tracking of edits With the power of modern computers, it’s silly that we still use save and editing metaphors from the time when the [...]]]></description>
			<content:encoded><![CDATA[<p>New <a href="http://wordpress.org/">WordPress </a>version is available right now:<br />
<a href="http://wordpress.org/download/">Download WordPress 2.6</a></p>
<p>More information on this brief video tour presentation of 2.6:</p>
<p><embed src="http://v.wordpress.com/mARhRBcT/fmt_std" type="application/x-shockwave-flash" width="400" height="250" flashvars="blog_domain=http://wordpress.org/development/2008/07/wordpress-26/&#038;width=400&#038;height=250"> </embed> </p>
<p>Read more to see &#8220;what&#8217;s new&#8221;<br />
<span id="more-41"></span></p>
<p>What&#8217;s news?</p>
<h2>Post Revisions: Wiki-like tracking of edits</h2>
<p>With the power of modern computers, it’s silly that we still use save and editing metaphors from the time when the most common method of storage was floppy disks. WordPress has always respected the importance of your writing with auto-save, and now we’re taking that to another level by allowing you to view who made what changes when to any post or page through a super-easy interface, much like <a href="http://en.wikipedia.org/w/index.php?title=Wikipedia&#038;action=history">Wikipedia </a>or a version control system.<br />
This is handy on any blog in case you make a mistake and want to go back to an older version of a post, and it’s super handy for multi-author blogs where you can see every change tracked by person.</p>
<h2>Press This!: Post from wherever you are on the web</h2>
<p>A few months ago on my blog <a href="http://ma.tt/2008/05/favorite-posting-bookmarklet/">we started a conversation</a> about the posting bookmarklet in WordPress and which systems we should look to for inspiration, like Flock, FriendFeed, Facebook, Tumblr, and Delicious. From these suggestions and the Quick Post plugin by Josh Kenzer, we developed a Press This bookmark you can add to your toolbar that provides a fast and smart popup to do posts to your WordPress blog:</p>
<p>For example, if you click “Press This” from a <a href="http://youtube.com">Youtube </a>page it’ll magically extract the video embed code, and if you do it from a Flickr page it’ll make it easy for you to put the image in your post. On my blog I’ve been experimenting with using different categories and the in_category() function — such as video, quote, aside, et cetera — to create a more tumblelog-like format.</p>
<h2>Shift Gears: Turbo-speed your blogging</h2>
<p><a href="http://gears.google.com/">Gears </a>is an open source browser extension project started by Google that developers like us can use to give you features we wouldn’t normally be able to. There are a lot of things we can do with Gears in the future, but in this release we’ve stuck to using what’s called a “Local Server” to cache or keep a copy of commonly-used Javascript and CSS files on your computer, which can speed up the loading of some pages by several seconds (they just pop right up!). You can install Gears for Firefox or Internet Explorer, with support for Safari and Opera pending. WordPress works just fine without it, you just get a little extra juice when you have it installed.</p>
<h2>Theme Previews: See it before your audience does</h2>
<p>Now when you select a theme it pops up a window that shows the theme live with all your content, instead of immediately making it active on your site. This is great for just test driving themes before making a switch over publicly, and it is also helpful when you are developing a theme and need to test it but don’t want everybody to see your ongoing mistakes development.</p>
<h2>Here are some of the smaller features and improvements in 2.6:</h2>
<p>    * Word count! Never guess how many words are in your post anymore.<br />
    * Image captions, so you can add sweet captions like Political Ticker does under your images.<br />
    * Bulk management of plugins.<br />
    * A completely revamped image control to allow for easier inserting, floating, and resizing. It’s now fully integrated with the WYSIWYG.<br />
    * Drag-and-drop reordering of Galleries.<br />
    * Plugin update notification bubble.<br />
    * Customizable default avatars.<br />
    * You can now upload media when in full-screen mode.<br />
    * Remote publishing via XML-RPC and APP is now secure (off) by default, but you can turn it on easily through the options screen.<br />
    * Full SSL support in the core, and the ability to force SSL for security.<br />
    * You can now have many thousands of pages or categories with no interface issues.<br />
    * Ability to move your wp-config file and wp-content directories to a custom location, for “clean” SVN checkouts.<br />
    * Select a range of checkboxes with “shift-click.”<br />
    * You can toggle between the Flash uploader and the classic one.<br />
    * A number of proactive security enhancements, including cookies and database interactions.<br />
    * Stronger better faster versions of TinyMCE, jQuery, and jQuery UI.<br />
    * Version 2.6 fixes approximately <a href="http://trac.wordpress.org/query?status=closed&#038;milestone=2.6">194 bugs.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2008/07/15/wordpress-26-is-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ethernet bonding (aggregating multiple ethernet channels)</title>
		<link>http://www2.crapules.com/wordpress/2008/06/30/ethernet-bonding-aggregating-multiple-ethernet-channels/</link>
		<comments>http://www2.crapules.com/wordpress/2008/06/30/ethernet-bonding-aggregating-multiple-ethernet-channels/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 17:15:47 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[aggregating]]></category>
		<category><![CDATA[aggregation]]></category>
		<category><![CDATA[balancing]]></category>
		<category><![CDATA[bond0]]></category>
		<category><![CDATA[bonding]]></category>
		<category><![CDATA[channel]]></category>
		<category><![CDATA[channels]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[ethernet]]></category>
		<category><![CDATA[ifenslave]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[load]]></category>
		<category><![CDATA[load balancing]]></category>
		<category><![CDATA[redundancy]]></category>

		<guid isPermaLink="false">http://www.crapules.com/wordpress/?p=37</guid>
		<description><![CDATA[Ethernet bonding refers to aggregating multiple ethernet channels together to form a single channel. This is primarily used for redundancy in ethernet paths or for load balancing. To use Bonding Ethernet for High-Availability (fail-over) on Debian you need to: install package ifenslave-2.6.To install this package follow this command #apt-get install ifenslave-2.6 edit /etc/network/interfaces to look [...]]]></description>
			<content:encoded><![CDATA[<p>Ethernet bonding refers to aggregating multiple ethernet channels together to form a single channel. This is primarily used for redundancy in ethernet paths or for load balancing.</p>
<p>To use Bonding Ethernet for High-Availability (fail-over) on Debian you need to:</p>
<p>install package ifenslave-2.6.To install this package follow this command<br />
<em>#apt-get install ifenslave-2.6</em></p>
<p>edit /etc/network/interfaces to look like this:</p>
<p><em># This file describes the network interfaces available on your system<br />
# and how to activate them. For more information, see interfaces(5).<br />
# The loopback network interface<br />
auto lo<br />
iface lo inet loopback<br />
auto bond0<br />
iface bond0 inet static<br />
        address 192.168.1.14<br />
        netmask 255.255.255.0<br />
        gateway 192.168.1.1<br />
        dns-search     MyDomain.net<br />
        dns-nameservers 192.168.1.1<br />
        up ifenslave bond0 eth0 eth1<br />
        down ifenslave -d bond0 eth0 eth1</em></p>
<p>comment or borrow the lines referring to your real NICs in the same file<br />
add the following lines to your /etc/modprobe.d/bonding:</p>
<p><em><br />
alias bond0 bonding<br />
alias eth0 e1000<br />
alias eth1 e1000<br />
options bonding mode=0 miimon=100</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2008/06/30/ethernet-bonding-aggregating-multiple-ethernet-channels/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Export/Import an existing list of packages</title>
		<link>http://www2.crapules.com/wordpress/2008/06/30/exportimport-an-existing-list-of-packages/</link>
		<comments>http://www2.crapules.com/wordpress/2008/06/30/exportimport-an-existing-list-of-packages/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 14:14:08 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[apt-get]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[dpkg]]></category>
		<category><![CDATA[duplicate]]></category>
		<category><![CDATA[export]]></category>
		<category><![CDATA[farm]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[packages]]></category>
		<category><![CDATA[paquet]]></category>
		<category><![CDATA[paquets]]></category>
		<category><![CDATA[restore]]></category>
		<category><![CDATA[save]]></category>
		<category><![CDATA[select]]></category>
		<category><![CDATA[selections]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[serveur]]></category>
		<category><![CDATA[setup]]></category>

		<guid isPermaLink="false">http://www.crapules.com/wordpress/?p=36</guid>
		<description><![CDATA[It is possible to export a list of all packages on a server and import this list to a new one. It&#8217;s very usefull if you have a big server farm to manage. Il est possible d&#8217;exporter la liste de toutes les packages d&#8217;un serveur et d&#8217;importer cette liste sur un autre serveur. Cette commande [...]]]></description>
			<content:encoded><![CDATA[<p>It is possible to export a list of all packages on a server and import this list to a new one.<br />
It&#8217;s very usefull if you have a big server farm to manage.</p>
<p>Il est possible d&#8217;exporter la liste de toutes les packages d&#8217;un serveur et d&#8217;importer cette liste sur un autre serveur. Cette commande est très pratique si vous avez une ferme de serveurs à gérer.</p>
<p>Export packages list from the primary server:<br />
<em>dpkg &#8211;get-selections > mes_paquetages</em></p>
<p>Import the list on the new server:<br />
<em>dpkg &#8211;set-selections < mes_paquetages</em></p>
<p>And finally install the packages:<br />
</em><em>apt-get dselect-upgrade</em></p>
<p>Importons la liste des packages sur le serveur primaire:<br />
<em>dpkg &#8211;get-selections > mes_paquetages</em></p>
<p>Sur le nouveau serveur importons la liste des packages du serveur primaire:<br />
<em>dpkg &#8211;set-selections < mes_paquetages</em></p>
<p>Et enfin installons les paquets:<br />
</em><em>apt-get dselect-upgrade</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2008/06/30/exportimport-an-existing-list-of-packages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Alienware M15x and Ubuntu</title>
		<link>http://www2.crapules.com/wordpress/2008/06/02/alienware-m15x-and-ubuntu/</link>
		<comments>http://www2.crapules.com/wordpress/2008/06/02/alienware-m15x-and-ubuntu/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 18:49:31 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[alien]]></category>
		<category><![CDATA[alienware]]></category>
		<category><![CDATA[amsn]]></category>
		<category><![CDATA[issue]]></category>
		<category><![CDATA[M15x]]></category>
		<category><![CDATA[no sound]]></category>
		<category><![CDATA[no sounds]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[sound]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.crapules.com/wordpress/?p=34</guid>
		<description><![CDATA[Just received my Alienware M15x and install Ubuntu 8.04 on it. No problem except for the sound. Need to add the line options snd-hda-intel model=mbp3 in file /etc/modprobe.d/alsa-base Another little issue if you&#8217;re using AMsn and you don&#8217;t have sounds when you receive a message or when someone connect: Go to Accound / Preferences / [...]]]></description>
			<content:encoded><![CDATA[<p>Just received my Alienware M15x and install Ubuntu 8.04 on it.<br />
No problem except for the sound.<br />
Need to add the line<br />
<code>
options snd-hda-intel model=mbp3
</code><br />
in file<br />
/etc/modprobe.d/alsa-base</p>
<p>Another little issue if you&#8217;re using AMsn and you don&#8217;t have sounds when you receive a message or when someone connect:<br />
Go to <strong>Accound / Preferences / Others</strong> and replace<br />
play $sound<br />
with<br />
aplay $sound</p>
<p>to use alsa sound server instead default library.</p>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2008/06/02/alienware-m15x-and-ubuntu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Get the Dell Service Tag number with Linux</title>
		<link>http://www2.crapules.com/wordpress/2008/05/27/get-the-dell-service-tag-number-with-linux/</link>
		<comments>http://www2.crapules.com/wordpress/2008/05/27/get-the-dell-service-tag-number-with-linux/#comments</comments>
		<pubDate>Tue, 27 May 2008 09:35:52 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[dell]]></category>
		<category><![CDATA[dmi]]></category>
		<category><![CDATA[dmidecode]]></category>
		<category><![CDATA[manage]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[open]]></category>
		<category><![CDATA[openmanage]]></category>
		<category><![CDATA[serial]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[service tag]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[tags]]></category>

		<guid isPermaLink="false">http://www.crapules.com/wordpress/?p=32</guid>
		<description><![CDATA[[root@SERVER ~]# dmidecode &#124; grep “Serial Number” Serial Number: 8HZZ42C]]></description>
			<content:encoded><![CDATA[<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 8em">
<pre>
<code>
[root@SERVER ~]# dmidecode | grep “Serial Number”
                Serial Number: 8HZZ42C</code>
</pre>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2008/05/27/get-the-dell-service-tag-number-with-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Horrorist Live @ Paris 2008 04 01</title>
		<link>http://www2.crapules.com/wordpress/2008/04/12/the-horrorist-live-paris-2008-04-01/</link>
		<comments>http://www2.crapules.com/wordpress/2008/04/12/the-horrorist-live-paris-2008-04-01/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 14:29:01 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Photos Concerts]]></category>
		<category><![CDATA[acrosome]]></category>
		<category><![CDATA[alexander chesler]]></category>
		<category><![CDATA[arrivers]]></category>
		<category><![CDATA[dance]]></category>
		<category><![CDATA[doomcore]]></category>
		<category><![CDATA[flesh is the fever]]></category>
		<category><![CDATA[gothic]]></category>
		<category><![CDATA[hardcore]]></category>
		<category><![CDATA[hypnotizer]]></category>
		<category><![CDATA[industrial]]></category>
		<category><![CDATA[miro]]></category>
		<category><![CDATA[mp3]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[oliver chesler]]></category>
		<category><![CDATA[one night in ny]]></category>
		<category><![CDATA[rave]]></category>
		<category><![CDATA[raver]]></category>
		<category><![CDATA[superpower]]></category>
		<category><![CDATA[techno]]></category>
		<category><![CDATA[the horrorist]]></category>
		<category><![CDATA[the new direction]]></category>
		<category><![CDATA[things to come]]></category>
		<category><![CDATA[ttc]]></category>

		<guid isPermaLink="false">http://www.crapules.com/wordpress/?p=31</guid>
		<description><![CDATA[All pictures available here: http://www.crapules.com/gallery2/main.php/v/concerts/Horrorist/]]></description>
			<content:encoded><![CDATA[<p>All pictures available here:<br />
<a href="http://www.crapules.com/gallery2/main.php/v/concerts/Horrorist/">http://www.crapules.com/gallery2/main.php/v/concerts/Horrorist/</a></p>
<p><a href="http://www.crapules.com/gallery2/main.php/v/concerts/Horrorist/"><img src="http://www.crapules.com/gallery2/main.php/d/4658-1/20080401_Horro01.jpg" alt="20080401_Horro01.jpg" height="250"/></a></p>
<p><a href="http://www.crapules.com/gallery2/main.php/v/concerts/Horrorist/"><img src="http://www.crapules.com/gallery2/main.php/d/4661-1/20080401_Horro02.jpg" alt="20080401_Horro02.jpg" width="250"/></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2008/04/12/the-horrorist-live-paris-2008-04-01/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JO: un journaliste de FR2 viré par des officiels chinois</title>
		<link>http://www2.crapules.com/wordpress/2008/04/12/jo-un-journaliste-de-fr2-vire-par-des-officiels-chinois/</link>
		<comments>http://www2.crapules.com/wordpress/2008/04/12/jo-un-journaliste-de-fr2-vire-par-des-officiels-chinois/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 13:45:05 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Vrac]]></category>
		<category><![CDATA[abus]]></category>
		<category><![CDATA[crs]]></category>
		<category><![CDATA[flamme]]></category>
		<category><![CDATA[FR2]]></category>
		<category><![CDATA[france2]]></category>
		<category><![CDATA[jeanmarcmorandini]]></category>
		<category><![CDATA[JO]]></category>
		<category><![CDATA[olympique]]></category>
		<category><![CDATA[paris]]></category>
		<category><![CDATA[pekin]]></category>
		<category><![CDATA[police]]></category>
		<category><![CDATA[tv]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.crapules.com/wordpress/2008/04/12/jo-un-journaliste-de-fr2-vire-par-des-officiels-chinois/</guid>
		<description><![CDATA[Je ne suis pas fan de morandini, mais une vidéo intéressante lors de la flamme à paris: Un journaliste de France2 qui filmait les manifestants et les officiels chinois c&#8217;est fait sortir par les officiels chinois qui visiblement demandaient à la police et obtenaient ce qu&#8217;ils voulaient.]]></description>
			<content:encoded><![CDATA[<p>Je ne suis pas fan de morandini, mais une vidéo intéressante lors de la flamme à paris:<br />
Un journaliste de France2 qui filmait les manifestants et les officiels chinois c&#8217;est fait sortir par les officiels chinois qui visiblement demandaient à la police et obtenaient ce qu&#8217;ils voulaient.</p>
<div><object width="558" height="509"><param name="FlashVars" value="modeType=custom"/><param name="movie" value="http://www.wat.tv/swf2/113411lk5rUaS956037/894942" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><embed src="http://www.wat.tv/swf2/113411lk5rUaS956037/894942" type="application/x-shockwave-flash" width="558" height="509" FlashVars="modeType=custom" allowScriptAccess="always" allowFullScreen="true"></embed></object></div>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2008/04/12/jo-un-journaliste-de-fr2-vire-par-des-officiels-chinois/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setup Sendmail without DNS</title>
		<link>http://www2.crapules.com/wordpress/2008/04/04/setup-sendmail-without-dns/</link>
		<comments>http://www2.crapules.com/wordpress/2008/04/04/setup-sendmail-without-dns/#comments</comments>
		<pubDate>Fri, 04 Apr 2008 15:04:59 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[host name]]></category>
		<category><![CDATA[lookup failure]]></category>
		<category><![CDATA[mailhost]]></category>
		<category><![CDATA[Name server]]></category>
		<category><![CDATA[red hat]]></category>
		<category><![CDATA[redhat]]></category>
		<category><![CDATA[sendmail]]></category>
		<category><![CDATA[sendmail-cf]]></category>

		<guid isPermaLink="false">http://www.crapules.com/wordpress/2008/04/04/setup-sendmail-without-dns/</guid>
		<description><![CDATA[Configure Sendmail is not very funny. In my case I have several box in a DMZ and i would like these box will be available to send email from my mail server. But sendmail need a valid MX reply to relay emails. Without this valid MX you should have this error in the log file [...]]]></description>
			<content:encoded><![CDATA[<p>Configure Sendmail is not very funny.<br />
In my case I have several box in a DMZ and i would like these box will be available to send email from my mail server. But sendmail need a valid MX reply to relay emails.<br />
Without this valid MX you should have this error in the log file</p>
<p><code>Apr  4 15:46:32 SERVER-01 sendmail[2422]: [ID 801593 mail.info] m34DdKJC002400: to=&lt;evargas@mycompany.com&gt;,&lt;hello@SERVER-01.internaldomain.fr&gt;, delay=00:07:12, xdelay=00:00:00, mailer=relay, pri=240354, relay=mail, dsn=4.0.0, stat=Deferred: Name server: mailhost: host name lookup failure
</code></p>
<p>When DNS doesn’t arrive for the party, sendmail gets mad.</p>
<p>How to solve this?<br />
<span id="more-29"></span></p>
<p><strong>Linux</strong> (Redhat, Fedora, Debian)<br />
First make sure you have <strong>the sendmail-cf </strong>package installed. Either install it and use yum/up2date/apt-get to get it.</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 8em">
<pre><code>rpm -Uvh sendmail-cf-8.13.1-3.fc2.i386.rpm</code></pre>
</div>
</div>
</div>
<p>Next, add your smart relay host to your /etc/hosts file (your mail server)</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 8em">
<pre><code>192.168.1.100 mail mail.yourdomain.com</code></pre>
</div>
</div>
</div>
<p>Go into /etc/mail/ and vi the sendmail.mc file. Add the following lines:</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 8em">
<pre><code>FEATURE(`accept_unresolvable_domains')dnl
FEATURE(`accept_unqualified_senders')dnl
FEATURE(nocanonify)
define(`confSERVICE_SWITCH_FILE', `/etc/mail/service.switch')dnl
define(`SMART_HOST',`mail')</code></pre>
</div>
</div>
</div>
<p>Of course, replace the <strong>mail </strong>with the host you entered in your /etc/hosts file.<br />
Now create a file in /etc/mail called service.switch and add the following:</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 8em">
<pre><code>root@SERVER-01 # cat /etc/mail/service.switch
hosts files
root@SERVER-01 #</code></pre>
</div>
</div>
</div>
<p>Edit the submit.mc file in /etc/mail and add the following line:</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 8em">
<pre><code>define(`confDIRECT_SUBMISSION_MODIFIERS', `C')dnl</code></pre>
</div>
</div>
</div>
<p>Now that we’re done making our file modifications, simply type <strong>make</strong> while in the /etc/mail directory.</p>
<p>Restart sendmail</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 8em">
<pre><code>/etc/init.d/sendmail restart</code></pre>
</div>
</div>
</div>
<p>That&#8217;s it!</p>
<p>just need to test it:</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 8em">
<pre><code>mail -s test toto@mydomain.com &lt; /dev/null 2&gt;&amp;1 &gt;&gt; /dev/null</code></pre>
</div>
</div>
</div>
<p><strong>Solaris</strong></p>
<p>More easy on solaris 10 (same thing on V8 and V9)<br />
Edit the files /etc/mail/sendmail.cf and /etc/mail/submit.cf<br />
and uncomment the following lines:</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 8em">
<pre><code># service switch file (name hardwired on Solaris, Ultrix, OSF/1, others)
O ServiceSwitchFile=/etc/mail/service.switch

# hosts file (normally /etc/hosts)
O HostsFile=/etc/hosts</code></pre>
</div>
</div>
</div>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 8em">
<pre><code>root@SERVER-01 # more service.switch
hosts files
</code></pre>
</div>
</div>
</div>
<p>don&#8217;t forget to setup your host file</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 8em">
<pre><code>
127.0.0.1       localhost       SERVER-01.mydomain.com
192.168.1.100    mail    mail.mydomain.com
</code></pre>
</div>
</div>
</div>
<p>Check in your /etc/nsswitch.conf file the line &#8220;hosts&#8221; like this:</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 8em">
<pre><code>
hosts:      files
</code></pre>
</div>
</div>
</div>
<p>Check in your sendmail conf file (main.cf, sendmail.cf, subsidiary.cf) your relay host is setup</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 8em">
<pre><code>
# "Smart" relay host (may be null)
DSmail</code></pre>
</div>
</div>
</div>
<p>In the same files replace the following lines </p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 8em">
<pre><code>
# pass to name server to make hostname canonical
R$* $| $* &lt; @ $* &gt; $*          $: $2 &lt; @ $[ $3 $] &gt; $4
R$* $| $*                      $: $2
</code></pre>
</div>
</div>
</div>
<p>by</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 8em">
<pre><code>
# pass to name server to make hostname canonical
R$* $| $* &lt; @ $* &gt; $*           $: $2 &lt; @ $3 &gt; $4
R$* $| $*                       $: $2
</code></pre>
</div>
</div>
</div>
<p>Be VERY carreful with the tabulations!</p>
<p>Just relaunch sendmail</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 8em">
<pre><code>svcadm refresh network/smtp:sendmail</code></pre>
</div>
</div>
</div>
<p>And test again &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2008/04/04/setup-sendmail-without-dns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>recursive mass rename script</title>
		<link>http://www2.crapules.com/wordpress/2008/03/24/recursive-mass-rename-script/</link>
		<comments>http://www2.crapules.com/wordpress/2008/03/24/recursive-mass-rename-script/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 13:47:57 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.crapules.com/wordpress/2008/03/24/recursive-mass-rename-script/</guid>
		<description><![CDATA[Hello, here a little script called myrename.pl to mass rename all the file of a directory and all the sub-directory and all files. I need this script to delete the space character in the filename The script: #!/usr/bin/perl # # Usage: rename perlexpr [files] ($regexp = shift @ARGV) &#124;&#124; die "Usage: rename perlexpr [filenames]\n"; #print [...]]]></description>
			<content:encoded><![CDATA[<p>Hello,</p>
<p>here a little script called <strong>myrename.pl </strong> to mass rename all the file of a directory and all the sub-directory and all files.<br />
I need this script to delete the <em>space</em> character in the filename</p>
<p><span id="more-28"></span><br />
The script:</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 25em">
<pre>
<code>
#!/usr/bin/perl
#
# Usage: rename perlexpr [files]

($regexp = shift @ARGV) || die "Usage:  rename perlexpr [filenames]\n";
#print "REGEXP :$regexp:\n";

if (!@ARGV) {
    @ARGV = &lt;STDIN&gt;;
    chomp(@ARGV);
}


foreach $_ (@ARGV) {
    $old_name = $_;
    eval $regexp;
#    print "Regexp after :$regexp:\n";
    die $@ if $@;
####   rename($old_name, $_) unless $old_name eq $_;
    rename($old_name, $_) unless $old_name eq $_; #or
####    warn "Couldn't rename $old_name to $_: $!\n";
    print "$old_name ----&gt; $_\n";
}

exit(0);

</code>
</pre>
</div>
</div>
</div>
<p>Using the script:</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 7em">
<pre>
<code>
find ./ -print | tac | /usr/bin/myrename.pl '($file) = (m|.+/(.+)|); $file = $_ if (!defined($file));($newfile = $file) =~ s/ /_/g;$file2=quotemeta($file); s/$file2/$1$newfile/;'
</code>
</pre>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2008/03/24/recursive-mass-rename-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>listing &amp; zip Dir on the Fly</title>
		<link>http://www2.crapules.com/wordpress/2008/03/05/directory-listing-and-zip-on-the-fly-directory-2/</link>
		<comments>http://www2.crapules.com/wordpress/2008/03/05/directory-listing-and-zip-on-the-fly-directory-2/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 11:30:16 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Vrac]]></category>

		<guid isPermaLink="false">http://www.crapules.com/wordpress/2008/03/05/directory-listing-and-zip-on-the-fly-directory-2/</guid>
		<description><![CDATA[Hello, Sometime I need to access my music from work. To do this I have made a quick php script to print my private collection hosted on my own server and added a script to create archive file (.zip) on the fly. J&#8217;ai développé une petite page php pour gerer ma musique sur mon server [...]]]></description>
			<content:encoded><![CDATA[<p>Hello,<br />
Sometime I need to access my music from work.<br />
To do this I have made a quick php script to print my private collection hosted on my own server and added a script to create archive file (.zip) on the fly.</p>
<p><strong>J&#8217;ai développé une petite page php pour gerer ma musique sur mon server perso. Ce script me permet de créer un fichier zip a la volée pour chaque album que je veux prendre chez moi.</strong></p>
<p><img id="image25" src="http://www.crapules.com/wordpress/wp-content/uploads/2008/03/list_zip.JPG" alt="homelist" width="700" /></p>
<p><span id="more-27"></span><br />
<em>Prequesities:<br />
you need the package zipArchives for php5<br />
On Fedora:</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 5em">
<pre>
<code>
yum install php-pecl-zip
</code>
</pre>
</div>
</div>
</div>
<p>On Debian</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 5em">
<pre>
<code>
apt-get install php5-zip
</code>
</pre>
</div>
</div>
</div>
<p></em></p>
<p>Let me explain: if you go to http://www.crapules.com/test.zip this will create a test.zip file on the fly with all the content of http://www.crapules.com/test directory.<br />
To do this you need to change your .htaccess file like this.<br />
<strong><br />
Le principe est simple. Lorsque un utilisateur utilise une URL avec une extension .zip dans certain répertoire, le script créer un fichier archive contenant l&#8217;intégralité du repertoire. Par exemple http://www.crapules.com/test.zip, créera un zip avec l&#8217;intégralité de http://www.crapules.com/test.<br />
La première étape est de créer un fichier .htaccess dans ledit répertoire comme suit:</strong></p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 10em">
<pre>
<code>
RewriteEngine On
Options +FollowSymlinks
RewriteCond %{REQUEST_URI} .zip$ [NC]
RewriteRule ^(.*).zip$ download.php?download=$1 [L]
</code>
</pre>
</div>
</div>
</div>
<p>This change will redirect all the link like</p>
<p>http://www.crapules.com/test.zip</p>
<p>in</p>
<p>http://www.crapules.com/download.php?download=test</p>
<p>Now you need to create a download.php in the same directory:<br />
<strong>On crée un fichier download.php dans le même répertoire:</strong></p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 20em">
<pre>
<code>
&lt;?php
# download.php
# This script is an adaptation from the balupton's script from b2evolution.net.
# Thanks to him

function myDownloadFile ( $file_path, $content_type = NULL, $buffer_size = 20000 )
{    // Credits go out to; pechkin at zeos dot net - http://au3.php.net/manual/en/function.header.php#65667
    // Modified into function by balupton
    // A shitload of upgrade to this done by balupton
    // Modified by Pateretou to delete file after downloading

    if ( empty($content_type) )
        $content_type = 'application/force-download';

    // Define variables
    $fpath = $file_path;
    $fname = basename($file_path);
    $fsize = filesize($fpath);
    $bufsize = $buffer_size;

    if ( isset($_SERVER['HTTP_RANGE']) )
    {    // Partial download
        if( preg_match("/^bytes=(\\d+)-(\\d*)$/", $_SERVER['HTTP_RANGE'], $matches) )
        {    // Parsing Range header
            $from = $matches[1];
            $to = $matches[2];

            if( empty($to) )
            {
                $to = $fsize - 1;  // -1  because end byte is included
            }

            $content_size = $to - $from + 1;

            header("HTTP/1.1 206 Partial Content");
            header('Pragma: public');
            header('Cache-control: must-revalidate, post-check=0, pre-check=0');
            header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
            header("Content-Range: $from-$to/$fsize");
            header("Content-Length: $content_size");
            header("Content-Type: $content_type");
            if ( $content_type == 'application/force-download' )
                header("Content-Disposition: attachment; filename=$fname");
            header("Content-Transfer-Encoding: binary");

           if(file_exists($fpath) &amp;&amp; $fh = fopen($fpath, "rb"))
           {
               fseek($fh, $from);
               $cur_pos = ftell($fh);
               while($cur_pos !== FALSE &amp;&amp; ftell($fh) + $bufsize &lt; $to+1)
               {
                   $buffer = fread($fh, $bufsize);
                   print $buffer;
                   $cur_pos = ftell($fh);
               }

               $buffer = fread($fh, $to+1 - $cur_pos);
               print $buffer;

               fclose($fh);
                unlink($fpath);
           }
           else
           {
           header("HTTP/1.1 500 Internal Server Error");
           exit;
       }
    }
    else // Usual download
    {
        // die ( $fpath.':::'.$fsize);
        header("HTTP/1.1 200 OK");
        header('Pragma: public');
        header('Cache-control: must-revalidate, post-check=0, pre-check=0');
        header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header("Content-Length: $fsize");
        header("Content-Type: $content_type");
        if ( $content_type == 'application/force-download' )
          header("Content-Disposition: attachment; filename=$fname");
        header("Content-Transfer-Encoding: binary");
        if( file_exists($fpath) )
        {
            readfile($fpath);
            unlink($fpath);
        }
        else
        {
           header("HTTP/1.1 404 Not Found");
        }
    }
}

/*
* Recurse function to create a zip file
*/
function myCreateArchive( $dir , &amp; $zip, $extdir = '' )
{
    if ( is_dir($dir) )
    if ( $rs = opendir($dir) )
    {
        while ( ($file = readdir($rs)) !== false )
        {
            if( $file != '.' &amp;&amp; $file != '..' )
            {
                if( is_dir( $dir . $file ) )
                {
                    $zip-&gt;addFile($dir.$file,$extdir.$file);
                    myCreateArchive($dir.$file.'/' , $zip, $extdir.$file.'/');

                }
                else
                {
                    $zip-&gt;addFile($dir."/".$file,$extdir.$file);
                }
            }
        }
        closedir($rs);
    }
    return true;
}

# Prepare variables
if ( !isset($_GET['download']) )
    exit('no download');
$download = $_GET['download'];

$this_dir_path = dirname(__FILE__);
$this_dir_path = realpath($this_dir_path);

$parent_dir_path = $this_dir_path.'/../';
$parent_dir_path = realpath($parent_dir_path);

$dir_path = $this_dir_path.'/'.$download;
$dir_path = realpath($dir_path);

if ( $this_dir_path &amp;&amp; $parent_dir_path &amp;&amp; $dir_path )
{    /* Ok, variables are set we can continue*/    }
else {
    exit('something went wrong...');
}

if ( substr($dir_path, 0, strlen($parent_dir_path)) === $parent_dir_path )
{    /* good */    }
else
    exit('stop hacking '."[$dir_path][$parent_dir_path]");

$file_path = $this_dir_path.'/'.$download.'.zip';

# Remove old file
if ( is_file($file_path) )
    unlink($file_path);

# Create Zip
$zip = new ZipArchive();
if ( $zip-&gt;open($file_path, ZIPARCHIVE::CREATE) !== TRUE )
        exit("cannot open &lt;$filename&gt;\n");

# Add file to Zip
myCreateArchive($dir_path, $zip);

$zip-&gt;close();

# Download
echo "file_path:$file_path&lt;br&gt;\n";
myDownloadFile($file_path, 'archive/zip');
die;
</code>
</pre>
</div>
</div>
</div>
<p>You can try you script with the following url:<br />
http://youwebsite.com/download.php?download=test to download the content of your &#8220;test&#8221; directory for example.<br />
If it&#8217;s work, you can test your .htaccess file with the url</p>
<p>http://youwebsite.com/test.zip</p>
<p>Now you can do a cute index page like this:</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 20em">
<pre>
<code>
&lt;html&gt;
&lt;header&gt;
&lt;link rel="stylesheet" type="text/css" href="/theme.css"/&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/&gt;
&lt;title&gt;Crapules&lt;/title&gt;
&lt;/header&gt;
&lt;body&gt;
&lt;div id="gsHeader"&gt;
&lt;span class="gsHeader"&gt;
&lt;a href="http://www.crapules.com" border="0"&gt;&lt;img src="/images/crapules.jpg"  alt="Crapules.com logo"/&gt;&lt;/a&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;/span&gt;
&lt;/div&gt;

&lt;div id="gsNavBar" class="gcBorder1"&gt;
&lt;div class="gbBreadCrumb"&gt;
&lt;div class="block-core-BreadCrumb"&gt;

&lt;span class="BreadCrumb-1"&gt;
Crapules.com Listing Access
&lt;/span&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;b&gt;&lt;font color="red"&gt;Please be patient if you try to DL a ZIP file. It's took take more than 40 secondes &lt;/font&gt;&lt;/b&gt;
&lt;br&gt;&lt;br&gt;
&lt;?

$myDirectory = opendir(".");
while($entryName = readdir($myDirectory)) {
        $dirArray[] = $entryName;
}
closedir($myDirectory);
$indexCount     = count($dirArray);

// sort case unsensitive
usort($dirArray, "strcasecmp" );

// print
print("&lt;TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks&gt;\n");
print("&lt;TR&gt;&lt;TH&gt;Filename&lt;/TH&gt;&lt;th&gt;Download&lt;/th&gt;&lt;th&gt;Filetype&lt;/th&gt;&lt;th&gt;Filesize&lt;/th&gt;&lt;/TR&gt;\n");
for($index=0; $index &lt; $indexCount; $index++) {
        $extension = array_pop(explode(".", $dirArray[$index]));
        if (substr("$dirArray[$index]", 0, 1) != "."){ // don't list hidden files
                if ($extension != "php") {
                        print("&lt;TR&gt;&lt;TD&gt;&lt;a href=\"$dirArray[$index]\"&gt;$dirArray[$index]&lt;/a&gt;&lt;/td&gt;");
                        print("&lt;td&gt;&lt;a href=\"$dirArray[$index].zip\"&gt;DL .zip&lt;/a&gt;&lt;/td&gt;");
                        print("&lt;td&gt;");
                        print(filetype($dirArray[$index]));
                        print("&lt;/td&gt;");
                        print("&lt;td&gt;");
                        print(filesize($dirArray[$index]));
                        print("&lt;/td&gt;");
                        print("&lt;/TR&gt;\n");
                }
        }
}
print("&lt;/TABLE&gt;\n");
?&gt;
&lt;div id="gsFooter"&gt;Logo designed by &lt;a href="http://www.k-leidoscope.com"&gt;[A]ura&lt;/a&gt;. &amp;copy;2004-2008 &lt;a href="http://www.crapules.com"&gt;Crapules.com&lt;/a&gt;. All Rights Reserved.&lt;/div&gt;
&lt;script src="http://www.google-analytics.com/urchin.js" type="text/javascript"&gt;
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
_uacct = "UA-3653212-1";
urchinTracker();
&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;
</code>
</pre>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2008/03/05/directory-listing-and-zip-on-the-fly-directory-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Force (W)SUS to update</title>
		<link>http://www2.crapules.com/wordpress/2007/02/13/force-wsus-or-sus-to-update/</link>
		<comments>http://www2.crapules.com/wordpress/2007/02/13/force-wsus-or-sus-to-update/#comments</comments>
		<pubDate>Tue, 13 Feb 2007 11:48:38 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.crapules.com/wordpress/2007/02/13/force-wsus-or-sus-to-update/</guid>
		<description><![CDATA[Below a batch to force WSUS , windows update to update automaticaly. @echo off Echo This batch file will Force the Update Detection from the AU client: Echo 1. Stops the Automatic Updates Service (wuauserv) Echo 2. Deletes the LastWaitTimeout registry key (if it exists) Echo 3. Deletes the DetectionStartTime registry key (if it exists) [...]]]></description>
			<content:encoded><![CDATA[<p>Below a batch to force WSUS , windows update to update automaticaly.</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 20em">
<pre>
<code>
@echo off
Echo This batch file will Force the Update Detection from the AU client:
Echo 1. Stops the Automatic Updates Service (wuauserv)
Echo 2. Deletes the LastWaitTimeout registry key (if it exists)
Echo 3. Deletes the DetectionStartTime registry key (if it exists)
Echo 4. Deletes the NextDetectionTime registry key (if it exists)
Echo 5. Restart the Automatic Updates Service (wuauserv)
Echo 6. Force the detection
Pause
@echo on
net stop wuauserv
REG DELETE "HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v LastWaitTimeout /f
REG DELETE "HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v DetectionStartTime /f
Reg Delete "HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v NextDetectionTime /f
net start wuauserv
wuauclt /detectnow
@echo off
Echo This AU client will now check for the Updates on the Local WSUS Server.
Pause
</code>
</pre>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2007/02/13/force-wsus-or-sus-to-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>resize, add border&amp;watermark</title>
		<link>http://www2.crapules.com/wordpress/2006/12/17/script-to-massive-resize-add-a-border-and-add-a-watermark/</link>
		<comments>http://www2.crapules.com/wordpress/2006/12/17/script-to-massive-resize-add-a-border-and-add-a-watermark/#comments</comments>
		<pubDate>Sun, 17 Dec 2006 17:19:10 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Vrac]]></category>

		<guid isPermaLink="false">http://www.crapules.com/wordpress/2006/12/17/script-to-massive-resize-add-a-border-and-add-a-watermark/</guid>
		<description><![CDATA[Hello, Imagemagick is a very powerfull program to modify picture with a simple comand line. For example, we can write a script to automatically resize, add a border and watermark to many picture in the same directory. #/bin/sh for img in `ls *.jpg` do convert $img -resize 20% rez_$img convert -bordercolor "#000000" -border 2x2 -bordercolor [...]]]></description>
			<content:encoded><![CDATA[<p>Hello,</p>
<p>Imagemagick is a very powerfull program to modify picture with a simple comand line.<br />
For example, we can write a script to automatically resize, add a border and watermark to many picture in the same directory.</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 20em">
<pre>
<code>
#/bin/sh
for img in `ls *.jpg`
do
convert $img -resize 20% rez_$img
convert -bordercolor "#000000" -border 2x2 -bordercolor "#FFFFFF" -border 4x4 -bordercolor "#000000" -border 2x2 rez_$img border_$img
convert border_$img -font /usr/share/fonts/default/ghostscript/bchri.pfa -fill white -pointsize 16 -draw "gravity southeast text 10,7 '(c) Vargas Emmanuel http://www\
.crapules.com'" final_$img
/bin/rm -f rez_$img
/bin/rm -f border_$img
done
</code>
</pre>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2006/12/17/script-to-massive-resize-add-a-border-and-add-a-watermark/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RIP Linux Server</title>
		<link>http://www2.crapules.com/wordpress/2006/09/25/rip-linux-server/</link>
		<comments>http://www2.crapules.com/wordpress/2006/09/25/rip-linux-server/#comments</comments>
		<pubDate>Mon, 25 Sep 2006 16:03:09 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Vrac]]></category>

		<guid isPermaLink="false">http://88.191.11.118/wordpress/2006/09/25/rip-linux-server/</guid>
		<description><![CDATA[First Time I need to definitively shutdown a Production Linux Server. RIP.]]></description>
			<content:encoded><![CDATA[<p>First Time I need to definitively shutdown a Production Linux Server.</p>
<p>RIP.</p>
<p><img id="image20" src="http://88.191.11.118/wordpress/wp-content/uploads/2006/09/cro_rip.JPG" alt="cro_RIP" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2006/09/25/rip-linux-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solaris tips</title>
		<link>http://www2.crapules.com/wordpress/2006/09/07/solaris-tips/</link>
		<comments>http://www2.crapules.com/wordpress/2006/09/07/solaris-tips/#comments</comments>
		<pubDate>Thu, 07 Sep 2006 10:19:09 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Solaris]]></category>

		<guid isPermaLink="false">http://88.191.11.118/wordpress/2006/09/07/solaris-tips/</guid>
		<description><![CDATA[Solaris tips recursively Search keywords find . -type f -print &#124; xargs grep chaine_a_chercher Reboot shutdown -i 6 -g 2 -y "bye" List the files in current directory sorted by size ls -l &#124; grep ^- &#124; sort -nr Delete blank lines in a file ? cat sample.txt &#124; grep -v '^$' &#62; new_sample.txt Display [...]]]></description>
			<content:encoded><![CDATA[<p>Solaris tips</p>
<p><span id="more-19"></span><br />
recursively Search keywords</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 4em">
<pre><code>
find . -type f -print | xargs grep chaine_a_chercher
</code></pre>
</div>
</div>
</div>
<p>Reboot</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 4em">
<pre><code>
shutdown -i 6 -g 2 -y "bye"
</code></pre>
</div>
</div>
</div>
<p>List the files in current directory sorted by size</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 4em">
<pre><code>
ls -l | grep ^- | sort -nr 
</code></pre>
</div>
</div>
</div>
<p>Delete blank lines in a file ?</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 4em">
<pre><code>
cat sample.txt | grep -v '^$' &gt; new_sample.txt
</code></pre>
</div>
</div>
</div>
<p>Display the Disk Usage of file sizes under each directory in currentDirectory ?</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 6em">
<pre><code>
du -k * | sort –nr 
or 
du –k . | sort -nr
</code></pre>
</div>
</div>
</div>
<p>Set the Display automatically for the current new user ?</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 4em">
<pre><code>
export DISPLAY=`eval 'who am i | cut -d"(" -f2 | cut -d")" -f1?`
</code></pre>
</div>
</div>
</div>
<p>List some Hot Keys for bash shell ?</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 10em">
<pre><code>
Ctrl+l – Clears the Screen. 
Ctrl+r – Does a search in previously given commands in shell.
Ctrl+u - Clears the typing before the hotkey. 
Ctrl+a – Places cursor at the beginning of the command at shell. 
Ctrl+e – Places cursor at the end of the command at shell. 
Ctrl+d – Kills the shell. 
Ctrl+z – Places the currently running process into background.
</code></pre>
</div>
</div>
</div>
<p>How do you find out drive statistics ?</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 4em">
<pre><code>
iostat -E
</code></pre>
</div>
</div>
</div>
<p>Display top ten largest files/directories ?</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 4em">
<pre><code>
du -sk * | sort -nr | head
</code></pre>
</div>
</div>
</div>
<p>How much space is used for users in kilobytes ?</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 4em">
<pre><code>
quot -af
</code></pre>
</div>
</div>
</div>
<p>Display Ethernet Address arp table ?</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 4em">
<pre><code>
arp -a
</code></pre>
</div>
</div>
</div>
<p>Display the no.of active established connections to localhost ?</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 4em">
<pre><code>
netstat -a | grep EST 
</code></pre>
</div>
</div>
</div>
<p>Display the state of interfaces used for TCP/IP traffice ?</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 4em">
<pre><code>
netstat -i
</code></pre>
</div>
</div>
</div>
<p>Show the working directory of a process ?</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 4em">
<pre><code>
pwdx &lt;pid&gt; 
</code></pre>
</div>
</div>
</div>
<p>Display the processes current open files ?</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 4em">
<pre><code>
pfiles &lt;pid&gt;
</code></pre>
</div>
</div>
</div>
<p>Alternative for top command ?</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 4em">
<pre><code>
prstat -a
</code></pre>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2006/09/07/solaris-tips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VIM shortcuts</title>
		<link>http://www2.crapules.com/wordpress/2006/09/07/vim-shortcuts/</link>
		<comments>http://www2.crapules.com/wordpress/2006/09/07/vim-shortcuts/#comments</comments>
		<pubDate>Thu, 07 Sep 2006 09:58:20 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Solaris]]></category>

		<guid isPermaLink="false">http://88.191.11.118/wordpress/2006/09/07/vim-shortcuts/</guid>
		<description><![CDATA[Some tips and shortcuts for VIM Search and replace: :%s/toto/tata/g "k" up "h" left "l" right (lowercase L) "j" down "D" Delete to the end of the line from the current cursor position. "dd" delete whole line "x" delete character under cursor "ZZ" exit and save ":quit!" quit without saving]]></description>
			<content:encoded><![CDATA[<p>Some tips and shortcuts for VIM<br />
<span id="more-17"></span></p>
<h3>Search and replace:</h3>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 20em">
<pre>
<code>
:%s/toto/tata/g

"k" up
"h" left
"l" right (lowercase L)
"j" down
"D" Delete to the end of the line from the current cursor position.
"dd" delete whole line
"x" delete character under cursor
"ZZ" exit and save
":quit!" quit without saving

</code>
</pre>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2006/09/07/vim-shortcuts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Force autoshare on Windows</title>
		<link>http://www2.crapules.com/wordpress/2006/09/07/force-autoshare-on-windows/</link>
		<comments>http://www2.crapules.com/wordpress/2006/09/07/force-autoshare-on-windows/#comments</comments>
		<pubDate>Thu, 07 Sep 2006 08:27:05 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://88.191.11.118/wordpress/2006/09/07/force-autoshare-on-windows/</guid>
		<description><![CDATA[Change this key to 1 and reboot Hive: HKEY_LOCAL_MACHINE Key: SYSTEM\CurrentControlSet\Services\LanManServer\Parameters Name: AutoShareServer Data Type: REG_DWORD Value: 0]]></description>
			<content:encoded><![CDATA[<p>Change this key to 1 and reboot</p>
<p>Hive: HKEY_LOCAL_MACHINE<br />
Key: SYSTEM\CurrentControlSet\Services\LanManServer\Parameters<br />
Name: AutoShareServer<br />
Data Type: REG_DWORD<br />
Value: 0</p>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2006/09/07/force-autoshare-on-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Port Knocking Configuration</title>
		<link>http://www2.crapules.com/wordpress/2006/09/03/port-knocking-configuration/</link>
		<comments>http://www2.crapules.com/wordpress/2006/09/03/port-knocking-configuration/#comments</comments>
		<pubDate>Sun, 03 Sep 2006 02:09:50 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://88.191.11.118/wordpress/2006/09/03/port-knocking-configuration/</guid>
		<description><![CDATA[This articles describe how to configure a port knocking. We will use Knockd Cet articles décrit la mise en place d&#8217;un port knocking. Nous utiliserons Knockd Port knocking is a method of &#8220;message transmission across closed ports.&#8221; It works like this: initially a firewall blocks all ports on the server. The client issues a series [...]]]></description>
			<content:encoded><![CDATA[<p>This articles describe how to configure a port knocking. We will use <a href="http://www.zeroflux.org/cgi-bin/cvstrac.cgi/knock/wiki">Knockd</a><br />
<em>Cet articles décrit la mise en place d&#8217;un port knocking. Nous utiliserons <a href="http://www.zeroflux.org/cgi-bin/cvstrac.cgi/knock/wiki">Knockd</a></em><br />
<span id="more-15"></span><br />
Port knocking is a method of &#8220;message transmission across closed ports.&#8221; It works like this: initially a firewall blocks all ports on the server. The client issues a series of connection requests (knocks) to different ports; these are, of course, dropped since the ports are blocked. However, there is a daemon that monitors the log files for connection requests, and the sequence of requests serves as an encrypted code. If the code makes sense to the daemon, it enables SSH or another service (for a particular IP address and on a particular port encoded by the knock sequence).<br />
<em>Le port knocking est une forme d&#8217;authentification réseau. Le Port Knocking fonctionne actuellement en suivant constamment les fichiers de log du firewall afin d&#8217;en extraire les tentatives de connexions sur les ports concernés. Si une séquence est reconnue, alors les commandes correspondantes seront exécutées, notamment des modifications &#8220;à chaud&#8221; des règles du firewall, mais aussi le lancement ou l&#8217;arrêt d&#8217;un service ou l&#8217;éxecution d&#8217;une commande quelconque. En interne, le serveur garde une liste des ports sur lesquels ont été tentés des connexions en fonction de l&#8217;adresse IP de l&#8217;émetteur. A chaque tentative de connexion sur un port surveillé par Port Knocking, le port est ajouté à la liste des ports pour cette adresse IP. Si la nouvelle liste contiens une séquence, les commandes de la séquence sont exécutées.</em></p>
<p>First step juste download and install knockd sources<br />
<em>Télécharger les sources de knockd et l&#8217;installer</em><br />
<a href="http://www.invoca.ch/pub/packages/knock/">Knockd Sources</a></p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 4em">
<pre>
<code>
[root@pussycat ~]# wget http://www.invoca.ch/pub/packages/knock/knock-0.5-3.src.rpm
[root@pussycat ~]# rpm -Uvh knock-0.5-3.src.rpm
</code>
</pre>
</div>
</div>
</div>
<p>Just compil knockd-server</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 5em">
<pre>
<code>
[root@pussycat ~]# [root@pussycat ~]# rpmbuild -bb /usr/src/redhat/SPECS/knock.spec
....
[root@pussycat ~]# rpm -Uvh /usr/src/redhat/RPMS/i386/knock-server-0.5-3.i386.rpm
</code>
</pre>
</div>
</div>
</div>
<p>It&#8217;s important to understand more your sequence is complex and more is complex a brute force attack.<br />
Just need to setup the <strong>/etc/knockd.conf</strong></p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 20em">
<pre>
<code>
[root@pussycat ~]# more /etc/knockd.conf
[options]
        logfile = /var/log/knockd.log
        pidfile = /var/run/knockd.pid

[openWEBMIN]
        sequence      = 10001:tcp,9007:udp,10512:tcp,4078:udp
        seq_timeout   = 90
        tcpflags      = syn
        start_command = /sbin/iptables -A INPUT -s %IP% -p tcp --dport 9935 -j ACCEPT

[closeWEBMIN]
        sequence      = 10001:tcp,9007:udp,10512:tcp,4079:udp
        seq_timeout   = 90
        tcpflags      = syn
        start_command = /sbin/iptables -D INPUT -s %IP% -p tcp --dport 9935 -j ACCEPT

[opencloseSSH]
        sequence      = 11001:tcp,10007:udp,10512:tcp,4078:udp
        seq_timeout   = 90
        tcpflags      = syn
        start_command = /sbin/iptables -A INPUT -s %IP% -p tcp --dport 22 -j ACCEPT
        cmd_timeout   = 10
        stop_command  = /sbin/iptables -D INPUT -s %IP% -p tcp --dport 22 -j ACCEPT
[root@pussycat ~]#
</code>
</pre>
</div>
</div>
</div>
<p><strong>sequence:</strong> Sequence will be enable the command defined in the <strong>start_command</strong><br />
<strong>seq_timeout:</strong> Timeout (in sec) for termintated the squence<br />
<strong>start_command:</strong> Command will be executed if the sequence is COMPLETED<br />
<strong>cmd_timeout:</strong> Is a &#8220;stop_command&#8221; is defined, it&#8217;s the timeout between start_command and stop_command<br />
<strong>stop_command:</strong> Command executede at the end of the cmd_timeout</p>
<p>In this example if a user try to telnet on the port 10001:tcp,9007:udp,10512:tcp,4078:udp knockd will allow port 9935 which is the webmin port.<br />
User could close this port with the sequence 10001:tcp,9007:udp,10512:tcp,4079:udp<br />
If a sequence 11001:tcp,10007:udp,10512:tcp,4078:udp is detected knockd open port 22 during 10secondes.<br />
Well check if you have defined this in your iptables configuration:</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 3em">
<pre>
<code>
-A tcp_packets -p TCP -s 0/0 --dport 22 -j allowed -m state --state ESTABLISHED
</code></pre>
</div>
</div>
</div>
<p>This rule let&#8217;s open port 22 when a connection is etablished.<br />
It&#8217;s very important if you don&#8217;t want SSH doesn&#8217;t close in use after 10 secondes!<br />
You can find an IPTables example here :<br />
<a href="http://www.crapules.com/wordpress/2006/09/03/firewall-setup-with-a-frontend-server/">http://www.crapules.com/wordpress/2006/09/03/firewall-setup-with-a-frontend-server/</a></p>
<p>So if you want to open ssh port for exemple please use the port knocking client (windows or linux!).<br />
You can find it <a href="http://www.zeroflux.org/proj/knock/files/knock-cygwin.zip">here</a> for example.<br />
If you have only tcp port in you sequence you can use a simple telnet too.</p>
<p>Please let me know if you have any question.</p>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2006/09/03/port-knocking-configuration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setup a server in FW</title>
		<link>http://www2.crapules.com/wordpress/2006/09/03/firewall-setup-with-a-frontend-server/</link>
		<comments>http://www2.crapules.com/wordpress/2006/09/03/firewall-setup-with-a-frontend-server/#comments</comments>
		<pubDate>Sun, 03 Sep 2006 01:33:39 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://88.191.11.118/wordpress/2006/09/03/firewall-setup-with-a-frontend-server/</guid>
		<description><![CDATA[This firewall script is very interesting with a web/ftp server directly connected to Internet. We are in the &#8220;easiest&#8221; IPTables mode without nat or mangle. Please comment if you have any suggestion! Here is my/etc/sysconfig/iptables (Don&#8217;t forget to replace &#8220;VOTRE_IP_PUBLIQUE&#8221; by your outgoing ip address) # Mangle and NAT doesn't matter *mangle :FORWARD ACCEPT [0:0] [...]]]></description>
			<content:encoded><![CDATA[<p>This firewall script is very interesting with a web/ftp server directly connected to Internet.<br />
We are in the &#8220;easiest&#8221; IPTables mode without nat or mangle.<br />
Please comment if you have any suggestion!<br />
<span id="more-14"></span><br />
Here is my<strong>/etc/sysconfig/iptables</strong> (Don&#8217;t forget to replace &#8220;VOTRE_IP_PUBLIQUE&#8221; by your outgoing ip address)</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 22em">
<pre>
<code>
# Mangle and NAT doesn't matter
*mangle
:FORWARD ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
# Completed
*nat
:OUTPUT ACCEPT [0:0]
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
# Completed

#Defaut policies
*filter
:FORWARD DROP [0:0]
:INPUT DROP [0:0]

# Create separate chains for ICMP, TCP and UDP to traverse
:allowed - [0:0]
:tcp_packets - [0:0]
:OUTPUT DROP [0:0]
:udp_packets - [0:0]
:icmp_packets - [0:0]
:bad_tcp_packets - [0:0]
:SPOOFED - [0:0]
:test_manu - [0:0]

# We rejected bad tcp packets
-A bad_tcp_packets -p tcp -m state --tcp-flags SYN,ACK SYN,ACK --state NEW -j REJECT --reject-with tcp-reset
-A bad_tcp_packets -p tcp -m state --state NEW -j LOG  ! --syn --log-prefix "New not syn:"
-A bad_tcp_packets -p tcp -m state --state NEW -j DROP  ! --syn

# allowed chain
-A allowed -p TCP -j ACCEPT  --syn
-A allowed -p TCP -m state --state ESTABLISHED,RELATED -j ACCEPT
-A allowed -p TCP -j DROP

#TCP Rules:
#We allowed some tcp port (web, ftp)
#BE CARREFUL : SSH port is not allowed here
-A tcp_packets -p TCP -s 0/0 --dport auth -j allowed
-A tcp_packets -p TCP -s 0/0 --dport 80 -j allowed
-A tcp_packets -p TCP -s 0/0 --dport 21 -j allowed
-A tcp_packets -p TCP -s 0/0 --dport 25 -j allowed
-A tcp_packets -p TCP -s 0/0 --dport 60000:60200 -j allowed

#We don't close open session. Especially for PortKnocking
-A tcp_packets -p TCP -s 0/0 --dport 9912 -j allowed -m state --state ESTABLISHED --comment "Pour Webmin"
-A tcp_packets -p TCP -s 0/0 --dport 14213 -j allowed -m state --state ESTABLISHED --comment "Pour ssh"

#ICMP request are allowed
-A icmp_packets -p ICMP -s 0/0 --icmp-type 8 -j ACCEPT
-A icmp_packets -p ICMP -s 0/0 --icmp-type 11 -j ACCEPT

#Bad tcp packets refused
-A INPUT -p tcp -j bad_tcp_packets

#Allow local request
-A INPUT -p ALL -s 127.0.0.1 -i lo -j ACCEPT
-A INPUT -p ALL -s VOTRE_IP_PUBLIQUE -i lo -j ACCEPT

#Rules for the Internet Request
-A INPUT -p ALL -m state -d VOTRE_IP_PUBLIQUE --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p TCP -i eth0 -j tcp_packets
-A INPUT -p UDP -i eth0 -j udp_packets
-A INPUT -p ICMP -i eth0 -j icmp_packets

#We log umatched packets
-A INPUT -m limit --limit 3/minute --limit-burst 3 -j LOG  --log-level DEBUG --log-prefix "IPT INPUT packet died: "
-A FORWARD -p tcp -j bad_tcp_packets
-A FORWARD -m limit --limit 3/minute --limit-burst 3 -j LOG  --log-level DEBUG --log-prefix "IPT FORWARD packet died: "

# Flood  protection
-A FORWARD -p tcp --syn -m limit --limit 1/second -j ACCEPT
-A FORWARD -p udp -m limit --limit 1/second -j ACCEPT

#Rules pour determiner les ip autorisees a sortir
-A OUTPUT -p tcp -j bad_tcp_packets
-A OUTPUT -p ALL -s 127.0.0.1 -j ACCEPT
-A OUTPUT -p ALL -s VOTRE_IP_PUBLIQUE -j ACCEPT

#We log umatched packets
-A OUTPUT -m limit --limit 3/minute --limit-burst 3 -j LOG  --log-level DEBUG --log-prefix "IPT OUTPUT packet died: "

# Spoof protection
#-A SPOOFED -s 127.0.0.0/8 -j DROP
-A SPOOFED -s 169.254.0.0/12 -j DROP
-A SPOOFED -s 172.16.0.0/12 -j DROP
-A SPOOFED -s 192.168.0.0/16 -j DROP
-A SPOOFED -s 10.0.0.0/8 -j DROP
-A INPUT -j SPOOFED

COMMIT
</code>
</pre>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2006/09/03/firewall-setup-with-a-frontend-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Configuration Firewall avec serveur en frontend</title>
		<link>http://www2.crapules.com/wordpress/2006/09/03/configuration-firewall-avec-serveur-en-frontend/</link>
		<comments>http://www2.crapules.com/wordpress/2006/09/03/configuration-firewall-avec-serveur-en-frontend/#comments</comments>
		<pubDate>Sun, 03 Sep 2006 00:57:13 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://88.191.11.118/wordpress/2006/09/03/configuration-firewall-avec-serveur-en-frontend/</guid>
		<description><![CDATA[Dans mon cas, la dedibox est directement relié au net avec une IP publique. On est dans le cas le plus &#8220;simple&#8221; ou IPTables joue uniquement un rôle de Firewall Voici donc mon fichier /etc/sysconfig/iptables (n&#8217;oubliez pas de remplacer VOTRE_IP_PUBLIQUE, par &#8230; votre IP publique! Je n&#8217;ai pas trouvé comment créer des aliases avec cette [...]]]></description>
			<content:encoded><![CDATA[<p>Dans mon cas, la dedibox est directement relié au net avec une IP publique.<br />
On est dans le cas le plus &#8220;simple&#8221; ou IPTables joue uniquement un rôle de Firewall<br />
<span id="more-13"></span><br />
Voici donc mon fichier <strong>/etc/sysconfig/iptables</strong> (n&#8217;oubliez pas de remplacer VOTRE_IP_PUBLIQUE, par &#8230; votre IP publique! Je n&#8217;ai pas trouvé comment créer des aliases avec cette version d&#8217;IPTables)</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 22em">
<pre>
<code>
# On ne tient pas compte de mangle et nat, nous nous concentrons ici sur le filter uniquement
*mangle
:FORWARD ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
# Completed
*nat
:OUTPUT ACCEPT [0:0]
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
# Completed

#Defaut policies
*filter
:FORWARD DROP [0:0]
:INPUT DROP [0:0]

# Create separate chains for ICMP, TCP and UDP to traverse
:allowed - [0:0]
:tcp_packets - [0:0]
:OUTPUT DROP [0:0]
:udp_packets - [0:0]
:icmp_packets - [0:0]
:bad_tcp_packets - [0:0]
:SPOOFED - [0:0]
:test_manu - [0:0]

# on rejette les packets considérés comme mal formés (possibilité d'attaque ou de scan port)
-A bad_tcp_packets -p tcp -m state --tcp-flags SYN,ACK SYN,ACK --state NEW -j REJECT --reject-with tcp-reset
-A bad_tcp_packets -p tcp -m state --state NEW -j LOG  ! --syn --log-prefix "New not syn:"
-A bad_tcp_packets -p tcp -m state --state NEW -j DROP  ! --syn

# allowed chain
-A allowed -p TCP -j ACCEPT  --syn
-A allowed -p TCP -m state --state ESTABLISHED,RELATED -j ACCEPT
-A allowed -p TCP -j DROP

#TCP Rules:
#On Ouvre certains ports (web, ftp/passive, auth)
#Attention, le port SSH n'est pas ouvert ici, ne vous coupez pas la main!
-A tcp_packets -p TCP -s 0/0 --dport auth -j allowed
-A tcp_packets -p TCP -s 0/0 --dport 80 -j allowed
-A tcp_packets -p TCP -s 0/0 --dport 21 -j allowed
-A tcp_packets -p TCP -s 0/0 --dport 25 -j allowed
-A tcp_packets -p TCP -s 0/0 --dport 60000:60200 -j allowed

#On demande a ce que des qu une session est etablit, celle ci reste ouverte et ne soit pas coupe
#Ceci est particulierement utile dans le cas du portknocking par exemple ou l on referme le port 
#SSH apres X secondes.
-A tcp_packets -p TCP -s 0/0 --dport 9912 -j allowed -m state --state ESTABLISHED --comment "Pour Webmin"
-A tcp_packets -p TCP -s 0/0 --dport 14213 -j allowed -m state --state ESTABLISHED --comment "Pour ssh"

#On autorise les requetes ICMP (ping...)
-A icmp_packets -p ICMP -s 0/0 --icmp-type 8 -j ACCEPT
-A icmp_packets -p ICMP -s 0/0 --icmp-type 11 -j ACCEPT

#On rejette les Bad TCP packets .
-A INPUT -p tcp -j bad_tcp_packets

#On autorise les requetes venant de localhost (tiens d ailleurs cette regle ne peut elle pas poser de pb 
#en cas de tentative d intrusion par spoof?)
-A INPUT -p ALL -s 127.0.0.1 -i lo -j ACCEPT
-A INPUT -p ALL -s VOTRE_IP_PUBLIQUE -i lo -j ACCEPT

#Regles pour les packets venant d'internet
-A INPUT -p ALL -m state -d VOTRE_IP_PUBLIQUE --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p TCP -i eth0 -j tcp_packets
-A INPUT -p UDP -i eth0 -j udp_packets
-A INPUT -p ICMP -i eth0 -j icmp_packets

#On log les packets qui ne matchent avec aucune regles
-A INPUT -m limit --limit 3/minute --limit-burst 3 -j LOG  --log-level DEBUG --log-prefix "IPT INPUT packet died: "
-A FORWARD -p tcp -j bad_tcp_packets
-A FORWARD -m limit --limit 3/minute --limit-burst 3 -j LOG  --log-level DEBUG --log-prefix "IPT FORWARD packet died: "

# Flood  protection
-A FORWARD -p tcp --syn -m limit --limit 1/second -j ACCEPT
-A FORWARD -p udp -m limit --limit 1/second -j ACCEPT

#Rules pour determiner les ip autorisees a sortir
-A OUTPUT -p tcp -j bad_tcp_packets
-A OUTPUT -p ALL -s 127.0.0.1 -j ACCEPT
-A OUTPUT -p ALL -s VOTRE_IP_PUBLIQUE -j ACCEPT

#On log si ca matche pas
-A OUTPUT -m limit --limit 3/minute --limit-burst 3 -j LOG  --log-level DEBUG --log-prefix "IPT OUTPUT packet died: "

# Protection contre le spoofing
#-A SPOOFED -s 127.0.0.0/8 -j DROP
-A SPOOFED -s 169.254.0.0/12 -j DROP
-A SPOOFED -s 172.16.0.0/12 -j DROP
-A SPOOFED -s 192.168.0.0/16 -j DROP
-A SPOOFED -s 10.0.0.0/8 -j DROP
-A INPUT -j SPOOFED

COMMIT
</code>
</pre>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2006/09/03/configuration-firewall-avec-serveur-en-frontend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remplacer les espaces par des underscores</title>
		<link>http://www2.crapules.com/wordpress/2006/09/03/remplacer-les-espaces-par-des-underscores/</link>
		<comments>http://www2.crapules.com/wordpress/2006/09/03/remplacer-les-espaces-par-des-underscores/#comments</comments>
		<pubDate>Sun, 03 Sep 2006 00:28:02 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Solaris]]></category>

		<guid isPermaLink="false">http://88.191.11.118/wordpress/2006/09/03/remplacer-les-espaces-par-des-underscores/</guid>
		<description><![CDATA[Petit script trouvé sur Space Replace 1.0.1 qui permet de remplacer tous les espaces d&#8217;un répertoire ainsi que son contenu par des undescores. Par exemple, intricate &#8211; in pectra devient intricate_-_in_pectra Script to replace all space in file and directory with an undescore. Script found Here Il suffit de copier le contenu du script ci [...]]]></description>
			<content:encoded><![CDATA[<p>Petit script trouvé sur <a href="http://www.novell.com/coolsolutions/tools/15601.html">Space Replace 1.0.1</a> qui permet de remplacer tous les espaces d&#8217;un répertoire ainsi que son contenu par des undescores.<br />
Par exemple,  <strong>intricate &#8211; in pectra</strong> devient <strong> intricate_-_in_pectra</strong><br />
Script to replace all space in file and directory with an undescore. Script found <a href="http://www.novell.com/coolsolutions/tools/15601.html">Here</a></p>
<p><span id="more-12"></span></p>
<p>Il suffit de copier le contenu du script ci dessous dans un fichier dans votre <strong>/usr/local/lib</strong>. Vous pouvez également télécharger le script ainsi qu&#8217;un script d&#8217;installation <a href="http://www.crapules.com/files/spacereplace-1.0.1.tar.gz">ici</a></p>
<p>Just copy this file in you <strong>/usr/local/lib</strong> for example.<br />
You can also Download this script with an installation script <a href="http://www.crapules.com/files/spacereplace-1.0.1.tar.gz">Here</a></p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 22em">
<pre>
<code>
#!/bin/bash
# spacereplace v1.0.1 by Richard van Kampen - july 2005
function helpme {
echo ""
echo "Help for spacereplace"
echo ""
echo "spacereplace version 1.0.1 - written by Richard van Kampen"
echo "Tool to substitute spaces in file and directory names with underscores."
echo ""
echo "Usage: spacereplace [option] [PATH]"
echo ""
echo "List of options:"
echo ""
echo "-h or --help : show help."
echo "-r : recursive. Also commit changes to all sub-directories."
echo ""
echo "You have to specify the path to the directory you want to process. Not specifying a path will just display help"
echo ""
echo "Example: 'spacereplace -r /home/richard/video' changes all spaces to underscores in /home/richard/mp3 and all directories below /home/richard/mp3."
echo ""
exit
}

for arg in "$@" # grab command line options
do
if [ "$arg" != "-r" ] &amp;&amp; [ "$arg" != "-h" ]; then
dir="$arg"
orgdir="$dir"
sub=" and sub-directories"
fi
case "$arg" in
-h | --help ) help=1 ;; # help option true.
-r ) recursive=1 ;; # recursive is true
esac
done

if [ "$dir" == "" ];then
helpme
fi
if [ ! -d "$dir" ]; then
echo "Directory $dir does not exist. Please try again with full path"
exit
fi

if [ "$help" = "1" ]; then # do this if -h option is used
helpme
fi

function delspaces {
strips=1;
teller=1; # iterate through 'contentgrab' array
cd $dir;
# rename @ because we need it. Do it 5 times
until [ $strips = "5" ];do
rename @ - *
let strips+=1
done
for i in $(ls | sed 's/\n//g' | sed 's/\ /@/g'); do
i=${i//@/ }
contentgrab[$teller]=$i
replacespace=${contentgrab[$teller]// /_}
if [ "${contentgrab[$teller]}" != "$replacespace" ] &amp;&amp; [ ! -f "$replacespace" ] &amp;&amp; [ ! -d "$replacespace" ]; then
mv -- "${contentgrab[$teller]}" "$replacespace"
fi
let teller+=1;
done
}
</code>
</pre>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2006/09/03/remplacer-les-espaces-par-des-underscores/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Emacs backup files in ONE directory</title>
		<link>http://www2.crapules.com/wordpress/2006/08/20/test/</link>
		<comments>http://www2.crapules.com/wordpress/2006/08/20/test/#comments</comments>
		<pubDate>Sun, 20 Aug 2006 21:53:18 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://88.191.11.118/wordpress/2006/08/20/test/</guid>
		<description><![CDATA[Backup directory pour avoir tous les fichiers de backup dans un seul répertoire plutôt que d&#8217;en avoir partout; move your emacs backup files in only one directory ;; Backup directory pour avoir tous les fichiers de backup dans un seul ;; répertoire plutôt que d'en avoir partout; ;; ;; move your emacs backup files in [...]]]></description>
			<content:encoded><![CDATA[<p>Backup directory pour avoir tous les fichiers de backup dans un seul<br />
répertoire plutôt que d&#8217;en avoir partout;</p>
<p>move your emacs backup files in only one directory</p>
<div class="codebox">
<div class="incqbox">
<div class="scrollbox" style="height: 9em">
<pre>
<code>
;; Backup directory pour avoir tous les fichiers de backup dans un seul
;; répertoire plutôt que d'en avoir partout;
;; 
;; move your emacs backup files in only one directory
(defun make-backup-file-name (file)
   (concat "~/backup/" (file-name-nondirectory file) "~"))
</code>
</pre>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2006/08/20/test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mirroring script</title>
		<link>http://www2.crapules.com/wordpress/2006/08/18/mirroring-script/</link>
		<comments>http://www2.crapules.com/wordpress/2006/08/18/mirroring-script/#comments</comments>
		<pubDate>Fri, 18 Aug 2006 07:20:24 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://88.191.11.118/wordpress/2006/08/18/mirroring-script/</guid>
		<description><![CDATA[I have made a little script to mirroring some ftp (apache for exemple). This script is based on the anonftprsync debian script. just copy this in /usr/sbin/anonftprsyncapache: Code: #! /bin/sh set -e # This script originates from http://www.debian.org/mirror/anonftpsync # modified by Martin Zobel-Helas &#60;zobel@debian.org&#62;, 2005-01-16 # these modifications are published under the terms of the [...]]]></description>
			<content:encoded><![CDATA[<p>I have made a little script to mirroring some ftp (apache for exemple).<br />
This script is based on the anonftprsync debian script.<br />
just copy this in <strong>/usr/sbin/anonftprsyncapache</strong>:</p>
<p><span id="more-10"></span></p>
<div class="codebox">
<div class="incqbox">
<h4>Code:</h4>
<div class="scrollbox" style="height: 20em">
<pre>
#! /bin/sh
set -e

# This script originates from http://www.debian.org/mirror/anonftpsync
# modified by Martin Zobel-Helas &lt;zobel@debian.org&gt;, 2005-01-16
#       these modifications are published under the terms of the GNU GPL
# Note: You MUST have rsync 2.0.16-1 or newer, which is available in slink
# and all newer Debian releases, or at http://rsync.samba.org/
#
# script modified by emmanuel vargas &lt;emmanuel.vargas@gmail.com&gt;

# TO is the destination for the base of the mirror directory
TO=/var/ftp/pub/mirror/apache

# RSYNC_HOST is the site you have chosen from the mirrors file.
RSYNC_HOST=rsync.apache.org

# RSYNC_DIR is the directory given in the "Packages over rsync:" line of
# the mirrors file for the site you have chosen to mirror.
RSYNC_DIR=apache-dist

# LOGDIR is the directory where the logs will be written to
LOGDIR=/var/log/

# MAILTO is the address to send logfiles to;
# if it is not defined, no mail will be sent
# (optional)

MAILTO=emmanuel.vargas@gmail.com

# There should be no need to edit anything below this point, unless there
# are problems.

#-----------------------------------------------------------------------------#

# Check for some environment variables
if [ -z $TO ] || [ -z $RSYNC_HOST ] || [ -z $RSYNC_DIR ] || [ -z $LOGDIR ]; then
        echo "One of the following variables seems to be empty:"
        echo "TO, RSYNC_HOST, RSYNC_DIR or LOGDIR"
        exit 2
fi

if ! [ -d ${TO}/project/trace/ ]; then
        # we are running mirror script for the first time
        mkdir -p ${TO}/project/trace
fi

# Note: on some non-Debian systems, hostname doesn't accept -f option.
# If that's the case on your system, make sure hostname prints the full
# hostname, and remove the -f option. If there's no hostname command,
# explicitly replace `hostname -f` with the hostname.
HOSTNAME=`hostname -f`

LOCK="${TO}/Archive-Update-in-Progress-${HOSTNAME}"
# Logfile
LOGFILE=$LOGDIR/apache-mirror.log

# Get in the right directory and set the umask to be group writable
#
cd $HOME
umask 002

# Check to see if another sync is in progress
if lockfile -! -l 43200 -r 0 "$LOCK"; then
  echo ${HOSTNAME} is unable to start rsync, lock file exists
  exit 1
fi
# Note: on some non-Debian systems, trap doesn't accept "exit" as signal
# specification. If that's the case on your system, try using "0".
trap "rm -f $LOCK &gt; /dev/null 2&gt;&#038;1" exit

set +e

result=0;

if [ 0 = $result ]; then
        # Now sync the remaining stuff
    rsync -rtlzv --delete $RSYNC_HOST::$RSYNC_DIR $TO &gt;&gt; $LOGFILE 2&gt;&#038;1

else
        echo "ERROR: Help, something weird happened" | tee -a $LOGFILE
        echo "mirroring /pool exited with exitcode" $result | tee -a $LOGFILE
fi
if ! [ -z $MAILTO ]; then
        mail -s "Apache archive synced" $MAILTO &lt; $LOGFILE
fi

/bin/rm $LOGFILE
</pre>
</div>
</div>
</div>
<p>and add this in your <strong>/etc/crontab</strong>:</p>
<div class="codebox">
<div class="incqbox">
<h4>Code:</h4>
<div class="scrollbox" style="height: 4em">
<pre>
#rsync for apache ftp
0 1,13 * * * /usr/sbin/anonftpsyncapache &gt; /dev/null
</pre>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2006/08/18/mirroring-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Monitoring Proftpd</title>
		<link>http://www2.crapules.com/wordpress/2006/08/17/monitoring-proftpd/</link>
		<comments>http://www2.crapules.com/wordpress/2006/08/17/monitoring-proftpd/#comments</comments>
		<pubDate>Thu, 17 Aug 2006 13:24:05 +0000</pubDate>
		<dc:creator>Manu</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://88.191.11.118/wordpress/2006/08/17/monitoring-proftpd/</guid>
		<description><![CDATA[ProFTPD + MySQL Authentication + E-Mail Monitor Log analysis My major problem with proftpd is the real time monitoring of log analysis. I will try to describe on this post the current solution I have build on my proftpd server. Prerequisites: Proftpd + mysql Perl + Perl-MIME-Lite + Perl-MailsTools + Perl-DBI and Perl-DBD-mysql ProFTPD + [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li><a href="#email">ProFTPD + MySQL Authentication + E-Mail Monitor</a></li>
<li><a href="#anal">Log analysis</a></li>
</ul>
<p>My major problem with proftpd is the real time monitoring of log analysis.</p>
<p>I will try to describe on this post the current solution I have build on my proftpd server.</p>
<p>Prerequisites:</p>
<ul>
<li>Proftpd + mysql</li>
<li>
</li>
<li>Perl + Perl-MIME-Lite + Perl-MailsTools + Perl-DBI and Perl-DBD-mysql</li>
</ul>
<p><span id="more-9"></span></p>
<h3><a name="email">ProFTPD + MySQL Authentication + E-Mail Monitor</a></h3>
<p>First step is to sending an alert by email when a user update or connect to the ftp<br />
This howto become from this great tutorial:<br />
<a href="http://www.khoosys.net/single.htm?ipg=1798">ProFTPD + MySQL Authentication + E-Mail Monitor Howto</a></p>
<p>The idea is to make a crontab script which check every X minutes that the field &#8220;modified&#8221; or &#8220;accessed&#8221; has been updated.</p>
<p>Logon to MySQL and issue the following command:</p>
<div class="codebox">
<div class="incqbox">
<h4>Code:</h4>
<div class="scrollbox" style="height: 8em">
<pre>
CREATE TABLE ftpusermonitor (
  id int(10) unsigned NOT NULL,
  userid varchar(32) NOT NULL default '',
  accessed datetime NOT NULL default '0000-00-00 00:00:00',
  modified datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (id),
  UNIQUE KEY userid (userid)
) TYPE=MyISAM;
</pre>
</div>
</div>
</div>
<p>You need to add this row to the ftpusermonitor table whenever you add a new ftp user :</p>
<div class="codebox">
<div class="incqbox">
<h4>Code:</h4>
<div class="scrollbox" style="height: 3em">
<pre>
INSERT INTO ftpusermonitor (id, userid) SELECT id, userid FROM ftpuser WHERE userid='myuser';
</pre>
</div>
</div>
</div>
<p>Now just copy this script on you ftp server:</p>
<div class="codebox">
<div class="incqbox">
<h4>Code:</h4>
<div class="scrollbox" style="height: 25em">
<pre>
#! /usr/bin/perl

# ftpmon.pl
# Monitor updates to FTP directories
# Author: Stefano Radice &lt;stefano@despammed.com&gt;

use strict;
use DBI;
use MIME::Lite;

my $server = 'localhost';
my $db = 'ftp';
my $dblogin = 'root';
my $dbpwd = 'password';
my $ftpalert = 'emmanuel.vargas@gmail.com';
#my $dbquery ="SELECT a.id, a.userid, a.modified FROM ftpuser a INNER JOIN ftpusermonitor b ON a.id = b.id WHERE a.modified &gt; b.modified";
my $dbquery ="SELECT a.id, a.userid, a.accessed FROM ftpuser a INNER JOIN ftpusermonitor b ON a.id = b.id WHERE a.accessed &gt; b.accessed";

my $dbh = DBI-&gt;connect("dbi:mysql:$db:$server", $dblogin, $dbpwd);
my $sth = $dbh-&gt;prepare($dbquery);
$sth-&gt;execute();

my @dbrow;

while(@dbrow=$sth-&gt;fetchrow_array()) {
    my $subject='FTP Update: ' . $dbrow[1];
    my $body=("The user -".$dbrow[1]. "- has acceded his FTP home.");
    send_mail($ftpalert,
              'FTPSERVER@ftp.crapules.com',
              $subject,
              $body);
    my $dbupd="UPDATE ftpusermonitor SET accessed='". $dbrow[2] . "' WHERE id=" . $dbrow[0];
#       my $dbupd=
#          "UPDATE ftpusermonitor SET modified='". $dbrow[2] . "' WHERE id=" . $dbrow[0];
    $dbh-&gt;do($dbupd);
}

$sth-&gt;finish( );

sub send_mail {
    print "Evoie d'un email\n";
    my($to, $from, $subject, $body)=@_;

    my $msg = new MIME::Lite
        From    =&gt;$from,
        To      =&gt;$to,
        Subject =&gt;$subject,
        Type    =&gt;'TEXT',
        Data    =&gt;$body;
    $msg -&gt; send;

}
</pre>
</div>
</div>
</div>
<p>Make this script executable:</p>
<div class="codebox">
<div class="incqbox">
<h4>Code:</h4>
<div class="scrollbox" style="height: 3em">
<pre>
# chmod 700 ftpmon.pl
</pre>
</div>
</div>
</div>
<p>and add this script in you crontab file:</p>
<div class="codebox">
<div class="incqbox">
<h4>Code:</h4>
<div class="scrollbox" style="height: 5em">
<pre>
# ftpmonitoring
*/5 * * * * /usr/sbin/ftpmoni.pl
</pre>
</div>
</div>
</div>
<h3><a name="anal">Logs Analysis</a></h3>
<p>First step is webalizer installation:</p>
<div class="codebox">
<div class="incqbox">
<h4>Code:</h4>
<div class="scrollbox" style="height: 2em">
<pre>
[root@pussycat plugins]# yum install webalizer
</pre>
</div>
</div>
</div>
<p>now add in your <strong>/etc/proftpd.conf</strong>:<br />
<em>In the general config:</em></p>
<div class="codebox">
<div class="incqbox">
<h4>Code:</h4>
<div class="scrollbox" style="height: 2em">
<pre>
TransferLog none     # WARNING: TransferLog directive might need to be placed inside a virtual host context if you use them.
</pre>
</div>
</div>
</div>
<p>In the &lt;Anonymous&gt;:</p>
<div class="codebox">
<div class="incqbox">
<h4>Code:</h4>
<div class="scrollbox" style="height: 2em">
<pre>
  TransferLog                 /var/log/proftpd/xferlog.legacy
</pre>
</div>
</div>
</div>
<p>Now edit your <strong>/etc/webalizer.conf</strong>:</p>
<div class="codebox">
<div class="incqbox">
<h4>Code:</h4>
<div class="scrollbox" style="height: 20em">
<pre>
<code>
LogFile        /var/log/proftpd/xferlog.legacy
LogType	ftp
OutputDir      /var/www/html/admin/webalizer
HistoryName	/var/lib/webalizer/webalizer.hist
Incremental	yes
IncrementalName	/var/lib/webalizer/webalizer.current
HostName       pussycat
PageType	htm*
PageType	cgi
PageType        php
PageType        shtml
DNSCache	/var/lib/webalizer/dns_cache.db


DNSChildren	10
Quiet	   yes

FoldSeqErr	yes
HideURL		*.gif
HideURL		*.GIF
HideURL		*.jpg
HideURL		*.JPG
HideURL		*.png
HideURL		*.PNG
HideURL		*.ra

SearchEngine	yahoo.com	p=
SearchEngine	altavista.com	q=
SearchEngine	google.com	q=
SearchEngine	eureka.com	q=
SearchEngine	lycos.com	query=
SearchEngine	hotbot.com	MT=
SearchEngine	msn.com		MT=
SearchEngine	infoseek.com	qt=
SearchEngine	webcrawler	searchText=
SearchEngine	excite		search=
SearchEngine	netscape.com	search=
SearchEngine	mamma.com	query=
SearchEngine	alltheweb.com	query=
SearchEngine	northernlight.com  qr=
# End of configuration file...  Have a nice day!
</code>
</pre>
</div>
</div>
</div>
<p>In your crontab file:</p>
<div class="codebox">
<div class="incqbox">
<h4>Code:</h4>
<div class="scrollbox" style="height: 4em">
<pre>
<code>
# webalizer for proftpd
10 3 * * * root /usr/bin/webalizer &gt; /dev/null
</code>
</pre>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www2.crapules.com/wordpress/2006/08/17/monitoring-proftpd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

