<?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>Univers Libre</title>
	<atom:link href="http://univers-libre.net/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://univers-libre.net</link>
	<description></description>
	<lastBuildDate>Thu, 26 Jan 2012 00:05:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Passer root sans terminal</title>
		<link>http://univers-libre.net/index.php/2012/01/passer-root-sans-terminal/</link>
		<comments>http://univers-libre.net/index.php/2012/01/passer-root-sans-terminal/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 00:05:40 +0000</pubDate>
		<dc:creator>billux</dc:creator>
				<category><![CDATA[Administration & Configuration]]></category>
		<category><![CDATA[GNU-Linux et Logiciels Libres]]></category>
		<category><![CDATA[Trucs & Astuces]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[planet-evolix]]></category>
		<category><![CDATA[planet-libre]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[sudo]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://univers-libre.net/?p=755</guid>
		<description><![CDATA[Dans certains rares cas, on peut vouloir exécuter des commandes en tant que root sans avoir la possibilité d&#8217;allouer un terminal sur la machine en question. Pour ceux qui aiment bien lire la fin en premier, je mets la fin au début  : echo &#34;mypassword&#34; &#124;sudo -S id Pour illustrer le problème, prenons un cas [...]]]></description>
			<content:encoded><![CDATA[<p>Dans certains rares cas, on peut vouloir exécuter des commandes en tant que root sans avoir la possibilité d&#8217;allouer un terminal sur la machine en question.</p>
<p>Pour ceux qui aiment bien lire la fin en premier, je mets la fin au début <img src='http://univers-libre.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;mypassword&quot;</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #660033;">-S</span> <span style="color: #c20cb9; font-weight: bold;">id</span></pre></div></div>

<p>Pour illustrer le problème, prenons un cas concret qui m&#8217;est arrivé.<br />
Un serveur s&#8217;est soudainement mis dans un état bizarre, à savoir que tout marchait, les processus déjà en cours continuaient de s&#8217;exécuter, d&#8217;autres processus pouvaient se créer, mais certaines choses ne marchaient pas, notamment l&#8217;allocation de pseudo-terminaux (les <i>/dev/pts/*</i>) ; si je tente une connexion SSH au serveur, le serveur répond bien, l&#8217;authentification se fait, et au moment d&#8217;avoir mon prompt, la connexion se freeze.<br />
Après divers tests, je m&#8217;aperçois qu&#8217;en passant directement une commande à ssh, ça marche :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh</span> serveur-foireux <span style="color: #c20cb9; font-weight: bold;">dmesg</span></pre></div></div>

<p>La différence vient du fait que dans le deuxième cas, ssh n&#8217;ouvre pas de pseudo-terminal sur le serveur distant, puisqu&#8217;il se contente de récupérer directement stderr et stdout.<br />
On peut faire en sorte de se connecter sans allouer de terminal sur le serveur avec l&#8217;option <i>-T</i> de la commande ssh :</p>
<blockquote><p>     -T      Disable pseudo-tty allocation.</p></blockquote>
<p>On a ainsi un shell qui s&#8217;exécute sur la machine, et on récupère la sortie brute de stderr et stdout (pas de prompt, d&#8217;édition de la commande en cours, etc…). Pareil pour stdin, ce qui fait que les commandes sudo ou su retournent une erreur, étant donné qu&#8217;elles font une manipulation spécifique sur stdin (pas d&#8217;echo pour la saisie du mot de passe). De ce fait, on est un peu coincé pour passer root.</p>
<p>Il existe une solution (que j&#8217;ai bien sûr trouvé après avoir brutalement redémarrer le serveur), une simple option à sudo qui permet de lire le mot de passe depuis stdin. Et là, pas besoin d&#8217;exécuter la commande dans un terminal donc !</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;mypassword&quot;</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #660033;">-S</span> <span style="color: #c20cb9; font-weight: bold;">id</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #c20cb9; font-weight: bold;">sudo</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> password <span style="color: #000000; font-weight: bold;">for</span> rdessort: <span style="color: #007800;">uid</span>=<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>root<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">gid</span>=<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>root<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">groupes</span>=<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>root<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Et comme cela affiche votre mot de passe en clair sur l&#8217;écran, voici un petit script pour améliorer la chose :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Enter password: &quot;</span>
<span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #660033;">-s</span> <span style="color: #c20cb9; font-weight: bold;">passwd</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">ssh</span> serveur-foireux <span style="color: #ff0000;">&quot;echo <span style="color: #007800;">$passwd</span> |sudo -S id&quot;</span></pre></td></tr></table></div>

<p>Une autre application probablement beaucoup plus courante pourrait être de pouvoir scripter des commandes nécessitant d&#8217;être root sur le serveur. Notamment exécuter la même commande sur plusieurs dizaines de serveurs d&#8217;affilée.</p>
]]></content:encoded>
			<wfw:commentRss>http://univers-libre.net/index.php/2012/01/passer-root-sans-terminal/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>autoconfiguration IPv6 et forwarding</title>
		<link>http://univers-libre.net/index.php/2011/06/autoconfiguration-ipv6-et-forwarding/</link>
		<comments>http://univers-libre.net/index.php/2011/06/autoconfiguration-ipv6-et-forwarding/#comments</comments>
		<pubDate>Fri, 10 Jun 2011 21:09:03 +0000</pubDate>
		<dc:creator>billux</dc:creator>
				<category><![CDATA[Administration & Configuration]]></category>
		<category><![CDATA[Configuration d'un home serveur]]></category>
		<category><![CDATA[autoconfiguration]]></category>
		<category><![CDATA[forwarding]]></category>
		<category><![CDATA[IPv6]]></category>
		<category><![CDATA[planet-evolix]]></category>
		<category><![CDATA[planet-libre]]></category>
		<category><![CDATA[stateless]]></category>

		<guid isPermaLink="false">http://univers-libre.net/?p=741</guid>
		<description><![CDATA[Ayant enfin activé l&#8217;IPv6 sur mon serveur (IPv6 day oblige) ces derniers jours, je me suis heurté à un problème lié au forwarding lorsque l’hôte et en mode autoconfiguration. L’hôte en question fait tourner des environnements virtuels à l&#8217;aide d&#8217;OpenVZ, ce qui m&#8217;oblige donc à rajouter ceci dans mon /etc/sysctl.d/openvz.conf pour qu&#8217;ils puissent avoir une [...]]]></description>
			<content:encoded><![CDATA[<p>Ayant enfin activé l&#8217;IPv6 sur mon serveur (<a href="http://www.worldipv6day.org/">IPv6 day</a> oblige) ces derniers jours, je me suis heurté à un problème lié au forwarding lorsque l’hôte et en mode <a href="http://en.wikipedia.org/wiki/IPv6#Stateless_address_autoconfiguration_.28SLAAC.29">autoconfiguration</a>.</p>
<p>L’hôte en question fait tourner des environnements virtuels à l&#8217;aide d&#8217;OpenVZ, ce qui m&#8217;oblige donc à rajouter ceci dans mon <i>/etc/sysctl.d/openvz.conf</i> pour qu&#8217;ils puissent avoir une chance de sortir sur Internet :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="" style="font-family:monospace;">net.ipv6.conf.all.forwarding=<span style="">1</span></pre></td></tr></table></div>

<p>Cependant cela entraine la désactivation de l&#8217;autoconfiguration « stateless » de l&#8217;hôte, c&#8217;est à dire qui n&#8217;est plus capable de prendre une IP automatiquement, ni de positionner sa route par défaut.<br />
Je ne rentrerai pas dans les détails de pourquoi c&#8217;est comme ça, n&#8217;ayant pas trouvé d&#8217;explications sur le sujet, mais je suppose que le noyau doit ainsi transférer tous les paquets <a href="http://en.wikipedia.org/wiki/Neighbor_Discovery_Protocol">NDP</a> sur sa seconde interface, même s&#8217;il ne devrait pas car ces paquets ne sont pas censés traverser les routeurs. Bref si quelqu&#8217;un a une explication, qu&#8217;il n&#8217;hésite pas !</p>
<p>Une fois qu&#8217;on sait ça, rien de compliqué (le plus dur en fait est de se rendre compte que le forwarding désactive l&#8217;autoconfiguration de l’hôte).  On peut configurer l&#8217;interface de manière statique dans <i>/etc/network/interfaces</i> (pour Debian et dérivés) :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="" style="font-family:monospace;">iface eth0 inet6 static
    address 2a01:e35:2e31:da50:1e6f:65ff:fe54:5c96
    netmask <span style="">64</span>
    up route -A inet6 add default gw fe80::<span style="">224</span>:d4ff:feb4:f9b6 dev eth0 metric <span style="">1</span>
    down route -A inet6 del default gw fe80::<span style="">224</span>:d4ff:feb4:f9b6 dev eth0 metric <span style="">1</span></pre></td></tr></table></div>

<p><em>Source de l&#8217;image : <a href="http://www.potaroo.net/presentations/2008-11-17-ipv6-failure.pdf">http://www.potaroo.net/presentations/2008-11-17-ipv6-failure.pdf</a> (<a href="http://www.potaroo.net">http://www.potaroo.net</a>)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://univers-libre.net/index.php/2011/06/autoconfiguration-ipv6-et-forwarding/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Lighttpd et encodage de fichiers texte</title>
		<link>http://univers-libre.net/index.php/2011/05/lighttpd-et-encodage-de-fichiers-texte/</link>
		<comments>http://univers-libre.net/index.php/2011/05/lighttpd-et-encodage-de-fichiers-texte/#comments</comments>
		<pubDate>Fri, 27 May 2011 21:32:58 +0000</pubDate>
		<dc:creator>billux</dc:creator>
				<category><![CDATA[Administration & Configuration]]></category>
		<category><![CDATA[Configuration d'un home serveur]]></category>
		<category><![CDATA[AddDefaultCharset]]></category>
		<category><![CDATA[charset]]></category>
		<category><![CDATA[encodage]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[planet-evolix]]></category>
		<category><![CDATA[planet-libre]]></category>
		<category><![CDATA[utf8]]></category>

		<guid isPermaLink="false">http://univers-libre.net/?p=733</guid>
		<description><![CDATA[Voici une petite astuce pour résoudre le problème d&#8217;encodage des fichiers servis par Lighttpd, dans le cas où les fichiers en questions sont en UTF-8. En guise de rappel, Lighttpd est un serveur web simple, léger mais puissant par rapport à Apache. Voir ici pour plus d&#8217;info. Par défaut l&#8217;encodage des fichiers n&#8217;est pas précisé [...]]]></description>
			<content:encoded><![CDATA[<p>Voici une petite astuce pour résoudre le problème d&#8217;encodage des fichiers servis par Lighttpd, dans le cas où les fichiers en questions sont en UTF-8.<br />
En guise de rappel, Lighttpd est un serveur web simple, léger mais puissant par rapport à Apache. <a href="http://www.lighttpd.net/">Voir ici</a> pour plus d&#8217;info.</p>
<p>Par défaut l&#8217;encodage des fichiers n&#8217;est pas précisé dans le champ « Content-Type », comme le montre une requête HTTP HEAD :<br />
<pre><pre>$ HEAD http://univers-libre.net/plop.txt
200 OK
Connection: close
Date: Fri, 27 May 2011 20:23:14 GMT
Accept-Ranges: bytes
ETag: &quot;1885714849&quot;
Server: lighttpd/1.4.28
Content-Length: 7767
Content-Type: text/plain
Last-Modified: Sun, 02 May 2010 09:34:31 GMT
Client-Date: Fri, 27 May 2011 20:20:53 GMT
Client-Peer: 192.168.0.60:80
Client-Response-Num: 1</pre></pre></p>
<p>Dans la majeure partie des cas, on s&#8217;en fou grave car l&#8217;encodage est précisé dans la balise HTML <meta>, et le client interprète donc bien le texte comme étant de l&#8217;UTF-8 (ou ce que vous voulez). Oui mais justement, lorsqu&#8217;on veut que Lighttpd serve de bêtes fichiers texte, nous n&#8217;avons plus cette balise pour nous aider. Il faut donc forcer le champ Content-Type pour rajouter charset=utf8 à la fin.</p>
<p>Avec Apache, cela se fait en rajoutant la directive AddDefaultCharset. Sous Lighty, il faut redéfinir le type MIME en question, de cette manière :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bnf" style="font-family:monospace;">mimetype.assign  +<span style="color: #006600; font-weight: bold;">=</span> <span style="">&#40;</span> <span style="color: #a00;">&quot;.txt&quot;</span>  <span style="color: #006600; font-weight: bold;">=</span><span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #a00;">&quot;text/plain; charset=utf8&quot;</span> <span style="">&#41;</span></pre></td></tr></table></div>

<p>Attention, petite particularité sous Debian (ce n&#8217;est peut-être pas spécifique à Debian non plus), les types MIME sont générés par un script perl /usr/share/lighttpd/create-mime.assign.pl, appelé dans la conf de lighttpd. Il faut donc bien faire attention à rajouter la ligne de conf ci-dessus *après* cette ligne :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bnf" style="font-family:monospace;">include_shell <span style="color: #a00;">&quot;/usr/share/lighttpd/create-mime.assign.pl&quot;</span></pre></td></tr></table></div>

<p></meta></p>
]]></content:encoded>
			<wfw:commentRss>http://univers-libre.net/index.php/2011/05/lighttpd-et-encodage-de-fichiers-texte/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Page de status de php-fpm et Lighttpd</title>
		<link>http://univers-libre.net/index.php/2011/04/page-de-status-de-php-fpm-et-lighttpd/</link>
		<comments>http://univers-libre.net/index.php/2011/04/page-de-status-de-php-fpm-et-lighttpd/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 19:22:18 +0000</pubDate>
		<dc:creator>billux</dc:creator>
				<category><![CDATA[Administration & Configuration]]></category>
		<category><![CDATA[fpm]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[planet-evolix]]></category>
		<category><![CDATA[planet-libre]]></category>
		<category><![CDATA[status]]></category>

		<guid isPermaLink="false">http://univers-libre.net/?p=723</guid>
		<description><![CDATA[Récemment, j&#8217;ai mis en place php5-fpm en remplacement de fastcgi sur mon Lighttpd. Je rencontrais des problèmes de lenteurs de manière aléatoire lors de l&#8217;appel à un process PHP (même pour exécuter un echo &#34;foo&#34;) que je n&#8217;ai pas trop réussis à débuguer. Mais bref, là n&#8217;est pas le sujet. J&#8217;ai entendu beaucoup de retours [...]]]></description>
			<content:encoded><![CDATA[<p>Récemment, j&#8217;ai mis en place <a href="http://php-fpm.org/">php5-fpm</a> en remplacement de fastcgi sur mon <a href="http://www.lighttpd.net/">Lighttpd</a>. Je rencontrais des problèmes de lenteurs de manière aléatoire lors de l&#8217;appel à un process PHP (même pour exécuter un <pre>echo &quot;foo&quot;</pre>) que je n&#8217;ai pas trop réussis à débuguer.</p>
<p>Mais bref, là n&#8217;est pas le sujet. J&#8217;ai entendu beaucoup de retours positifs sur php-fpm, ce qui m&#8217;a convaincu de le le mettre en place.</p>
<p>Je n&#8217;ai pas encore eu trop l&#8217;occasion de regarder en détail la conf, celle par défaut marche sans soucis. Je vais donc pour l&#8217;instant juste vous faire part d&#8217;un petit détail lié à la page de status de php-fpm et Lighttpd (mais qui doit probablement impacter d&#8217;autres serveurs web).<br />
En fait, par défaut elle ne marche pas (erreur 404). Dans la conf, il est dit :</p>
<blockquote><p>; Note: The value must start with a leading slash (/). The value can be<br />
;       anything, but it may not be a good idea to use the .php extension or it<br />
;       may conflict with a real PHP file.</p></blockquote>
<p>Soit, mais rien est dit quant à la configuration du serveur web devant.<br />
J&#8217;ai mis un petit moment à comprendre, donc je vous donne l&#8217;astuce pour éviter de se prendre la tête.</p>
<p>Voici le petit bout de conf à rajouter dans Lighty :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="bnf" style="font-family:monospace;">        fastcgi.server +<span style="color: #006600; font-weight: bold;">=</span> <span style="">&#40;</span><span style="">&#40;</span>
                <span style="color: #a00;">&quot;/status&quot;</span> <span style="color: #006600; font-weight: bold;">=</span><span style="color: #000066; font-weight: bold;">&gt;</span> <span style="">&#40;</span>
                        <span style="color: #a00;">&quot;host&quot;</span> <span style="color: #006600; font-weight: bold;">=</span><span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #a00;">&quot;127.0.0.1&quot;</span>,
                        <span style="color: #a00;">&quot;port&quot;</span> <span style="color: #006600; font-weight: bold;">=</span><span style="color: #000066; font-weight: bold;">&gt;</span> <span style="">9000</span>,
                        <span style="color: #a00;">&quot;check-local&quot;</span> <span style="color: #006600; font-weight: bold;">=</span><span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #a00;">&quot;disable&quot;</span>
               <span style="">&#41;</span>
        <span style="">&#41;</span><span style="">&#41;</span></pre></td></tr></table></div>

<p>Et une petite explication sur le problème (qui est en fait tout à fait logique) :<br />
Par défaut le serveur web ne peut pas savoir que php-fpm fournit la page /status. Pour lui, si pas de fichier nommé status, il s’arrête là en renvoyant une 404. Il faut donc forcer Lighttpd à passer cette URL à php-fpm (comme si c&#8217;était un .php), et sans vérifier si le fichier existe bien sur le système de fichier.</p>
]]></content:encoded>
			<wfw:commentRss>http://univers-libre.net/index.php/2011/04/page-de-status-de-php-fpm-et-lighttpd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lister les paquets Debian installés en fonction de leur taille</title>
		<link>http://univers-libre.net/index.php/2011/01/lister-les-paquets-debian-installes-en-fonction-de-leur-taille/</link>
		<comments>http://univers-libre.net/index.php/2011/01/lister-les-paquets-debian-installes-en-fonction-de-leur-taille/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 19:23:22 +0000</pubDate>
		<dc:creator>billux</dc:creator>
				<category><![CDATA[GNU-Linux et Logiciels Libres]]></category>
		<category><![CDATA[Trucs & Astuces]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[paquet]]></category>
		<category><![CDATA[planet-evolix]]></category>
		<category><![CDATA[planet-libre]]></category>
		<category><![CDATA[taille]]></category>

		<guid isPermaLink="false">http://univers-libre.net/?p=704</guid>
		<description><![CDATA[Comme ça doit bien arriver un jour ou l&#8217;autre, je me suis retrouvé avec un / quasi plein sur une Debian. Après les classiques aptitude clean, suppression des vieux noyaux, etc… il faut bien s&#8217;attaquer au répertoire qui prend la plupart de la place, c&#8217;est à dire /usr. Comme j&#8217;ai l&#8217;habitude d&#8217;installer et peu de [...]]]></description>
			<content:encoded><![CDATA[<p>Comme ça doit bien arriver un jour ou l&#8217;autre, je me suis retrouvé avec un <i>/</i> quasi plein sur une Debian. Après les classiques <i>aptitude clean</i>, suppression des vieux noyaux, etc… il faut bien s&#8217;attaquer au répertoire qui prend la plupart de la place, c&#8217;est à dire <i>/usr</i>.</p>
<p>Comme j&#8217;ai l&#8217;habitude d&#8217;installer et peu de tout et de n&#8217;importe quoi pour découvrir, et de ne surtout rien désinstaller, je me retrouve vite avec une quantité de paquets inutiles. Pour m&#8217;aider à nettoyer tout ce bazar, j&#8217;ai fais un mini script qui affiche de manière triée la liste des paquets Debian avec leur taille.<br />
Le voici :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">dpkg</span> <span style="color: #660033;">--get-selections</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-f1</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> package
<span style="color: #000000; font-weight: bold;">do</span>
	<span style="color: #c20cb9; font-weight: bold;">dpkg</span> <span style="color: #660033;">-p</span> <span style="color: #007800;">$package</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-ne</span> <span style="color: #ff0000;">&quot;print <span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\$</span>1: <span style="color: #007800;">$package</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\&quot;</span> if /^Installed-Size: (.*)$/&quot;</span>
<span style="color: #000000; font-weight: bold;">done</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-rn</span></pre></td></tr></table></div>

<p>Et voici le résultat (la taille est en ko bien sûr) :<br />
<pre><pre>romain@heimdall:~$ bash package-size.sh |head
84496: mysql-server-5.0
78328: linux-image-2.6.26-2-amd64
33904: apcupsd-doc
31780: erlang-nox
22812: vim-runtime
21440: linux-headers-2.6.26-2-common
19364: mysql-client-5.0
18880: smbclient
18304: perl
15934: libgtk2.0-common</pre></pre></p>
<p><pre><pre>romain@heimdall:~$ bash package-size.sh |wc -l
1432</pre></pre></p>
]]></content:encoded>
			<wfw:commentRss>http://univers-libre.net/index.php/2011/01/lister-les-paquets-debian-installes-en-fonction-de-leur-taille/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Utiliser AWStats sans CGI</title>
		<link>http://univers-libre.net/index.php/2011/01/utiliser-awstats-sans-cgi/</link>
		<comments>http://univers-libre.net/index.php/2011/01/utiliser-awstats-sans-cgi/#comments</comments>
		<pubDate>Sun, 09 Jan 2011 14:13:56 +0000</pubDate>
		<dc:creator>billux</dc:creator>
				<category><![CDATA[GNU-Linux et Logiciels Libres]]></category>
		<category><![CDATA[Trucs & Astuces]]></category>
		<category><![CDATA[awstats]]></category>
		<category><![CDATA[cgi]]></category>
		<category><![CDATA[planet-evolix]]></category>
		<category><![CDATA[planet-libre]]></category>

		<guid isPermaLink="false">http://univers-libre.net/?p=696</guid>
		<description><![CDATA[AWStats est un générateur de statistiques, le plus souvent utilisé pour générer des stats sur des serveurs web (il peut aussi être utilisé pour des serveurs mail, ftp…). C&#8217;est une appli en Perl, qui peut donc être appelé par le serveur web via CGI pour générer les pages HTML. Sur Apache ou Lighttpd ça marche [...]]]></description>
			<content:encoded><![CDATA[<p>AWStats est un générateur de statistiques, le plus souvent utilisé pour générer des stats sur des serveurs web (il peut aussi être utilisé pour des serveurs mail, ftp…). C&#8217;est une appli en Perl, qui peut donc être appelé par le serveur web via CGI pour générer les pages HTML.</p>
<p>Sur Apache ou Lighttpd ça marche sans problème, mais sur un serveur web qui ne supporte pas CGI (NginX par exemple, à moins de passer par des hacks assez tordus) ça ne marche plus.</p>
<p>La solution est donc de dire à AWStats de générer les page HTML automatiquement après chaque mise à jour de sa base de données. Voici la procédure :</p>
<ul>
<li>Créez tout d&#8217;abord le répertoire qui contiendra les pages HTML, avec les bons droits :

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>awstats<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">chown</span> www-data:www-data <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>awstats<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

</li>
<li>Modifiez ensuite le fichier <i>/etc/cron.d/awstats</i> pour appelez le script <i>awstats_buildstaticpages.pl</i> au lieu de <i>awstats.pl</i> :

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-x</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>doc<span style="color: #000000; font-weight: bold;">/</span>awstats<span style="color: #000000; font-weight: bold;">/</span>examples<span style="color: #000000; font-weight: bold;">/</span>awstats_buildstaticpages.pl \
<span style="color: #660033;">-a</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>awstats<span style="color: #000000; font-weight: bold;">/</span>awstats.yoursite.conf <span style="color: #660033;">-a</span> <span style="color: #660033;">-r</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>yoursite.access.log <span style="color: #7a0874; font-weight: bold;">&#93;</span> \
<span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>doc<span style="color: #000000; font-weight: bold;">/</span>awstats<span style="color: #000000; font-weight: bold;">/</span>examples<span style="color: #000000; font-weight: bold;">/</span>awstats_buildstaticpages.pl <span style="color: #660033;">-update</span> \
<span style="color: #660033;">-config</span>=yoursite <span style="color: #660033;">-dir</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>awstats <span style="color: #660033;">-awstatsprog</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>cgi-bin<span style="color: #000000; font-weight: bold;">/</span>awstats.pl <span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null</pre></td></tr></table></div>

<p>À adapter bien sûr avec les bons noms de fichiers de conf et de log.</li>
<li>N&#8217;oubliez pas d&#8217;ajouter un alias dans la conf de votre serveur web pour les icônes. Sous NginX, ça donne ça :

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="" style="font-family:monospace;">  location /awstats-icon/ <span class="br0">&#123;</span>
        alias /usr/share/awstats/icon/;
    <span class="br0">&#125;</span></pre></td></tr></table></div>

</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://univers-libre.net/index.php/2011/01/utiliser-awstats-sans-cgi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Utiliser la fonction PHP imagerotate() sous Debian</title>
		<link>http://univers-libre.net/index.php/2010/12/utiliser-la-fonction-php-imagerotate-sous-debian/</link>
		<comments>http://univers-libre.net/index.php/2010/12/utiliser-la-fonction-php-imagerotate-sous-debian/#comments</comments>
		<pubDate>Sat, 18 Dec 2010 17:42:28 +0000</pubDate>
		<dc:creator>billux</dc:creator>
				<category><![CDATA[Trucs & Astuces]]></category>
		<category><![CDATA[gd]]></category>
		<category><![CDATA[imagerotate]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[planet-evolix]]></category>
		<category><![CDATA[planet-libre]]></category>

		<guid isPermaLink="false">http://univers-libre.net/?p=685</guid>
		<description><![CDATA[imagerotate est une fonction PHP qui, comme son nom l&#8217;indique, permet de tourner une image selon un angle. Cependant elle n&#8217;est disponible que si PHP a été compilé avec la version embarqué de la bibliothèque GD. Sous Debian ce n&#8217;est pas le cas, car cette version est difficilement maintenable au niveau sécurité (cf le bug [...]]]></description>
			<content:encoded><![CDATA[<p>imagerotate est une fonction PHP qui, comme son nom l&#8217;indique, permet de tourner une image selon un angle. Cependant elle n&#8217;est disponible que si PHP a été compilé avec la version embarqué de la bibliothèque GD.</p>
<p>Sous Debian ce n&#8217;est pas le cas, car cette version est difficilement maintenable au niveau sécurité (cf le <a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=321237">bug report Debian</a>)</p>
<p>Pour contourner le problème, en cherchant un peu sur le net (<a href="http://www.mattiouz.com/blog/2010/01/28/recompiling-php5-to-get-imagerotate-and-other-functions-on-debian">ici pa exemple</a>), beaucoup de monde recompile PHP avec la version embarqué de GD.  Ce n&#8217;est à mon avis pas la meilleure solution au niveau &laquo;&nbsp;maintenabilité&nbsp;&raquo;.</p>
<p>Voici donc 2 autres possibilités :</p>
<h2>Utiliser les dépôts dotdeb</h2>
<p>Les <a href="http://www.dotdeb.org/">dépôts dotdeb</a> contiennent des versions plus récentes et/ou modifiés de paquets Debian pour serveurs LAMP. Le paquet php5 présent dans dotdeb est justement compilé avec la version embarqué de la bibliothèque.</p>
<h2>Réécrire la fonction imagerotate()</h2>
<p>Si vous n&#8217;avez besoin que de cette fonction et que vous n&#8217;avez pas envi d&#8217;utiliser la version embarqué de GD, il est tout à fait envisageable de réécrire la fonction en question :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'imagerotate'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #990000;">imagerotate</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$source_image</span><span style="color: #339933;">,</span> <span style="color: #000088;">$angle</span><span style="color: #339933;">,</span> <span style="color: #000088;">$bgd_color</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$angle</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">360</span><span style="color: #339933;">-</span><span style="color: #000088;">$angle</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// GD rotates CCW, imagick rotates CW</span>
      <span style="color: #000088;">$temp_src</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/tmp/temp_src_'</span><span style="color: #339933;">.</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">10000</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">99999</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'.jpg'</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$temp_dst</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/tmp/temp_dst_'</span><span style="color: #339933;">.</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">10000</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">99999</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'.jpg'</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">imagejpeg</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_image</span><span style="color: #339933;">,</span><span style="color: #000088;">$temp_src</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
       <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #000088;">$imagick</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Imagick<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$imagick</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">readImage</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$temp_src</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$imagick</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rotateImage</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ImagickPixel<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bgd_color</span>?<span style="color: #000088;">$bgd_color</span><span style="color: #339933;">:</span><span style="color: #0000ff;">'black'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$angle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$imagick</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">writeImage</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$temp_dst</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #666666; font-style: italic;">//trigger_error( 'imagerotate(): could not write to ' . $file1 . ', original image returned', E_USER_WARNING );</span>
      <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatefromjpeg</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$temp_dst</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #990000;">unlink</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$temp_dst</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #990000;">unlink</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$temp_src</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">return</span> <span style="color: #000088;">$result</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://univers-libre.net/index.php/2010/12/utiliser-la-fonction-php-imagerotate-sous-debian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bloguez vos articles WordPress depuis Vim</title>
		<link>http://univers-libre.net/index.php/2010/10/bloguez-vos-articles-wordpress-depuis-vim/</link>
		<comments>http://univers-libre.net/index.php/2010/10/bloguez-vos-articles-wordpress-depuis-vim/#comments</comments>
		<pubDate>Sat, 30 Oct 2010 17:22:02 +0000</pubDate>
		<dc:creator>billux</dc:creator>
				<category><![CDATA[GNU-Linux et Logiciels Libres]]></category>
		<category><![CDATA[Trucs & Astuces]]></category>
		<category><![CDATA[blogit]]></category>
		<category><![CDATA[planet-evolix]]></category>
		<category><![CDATA[planet-libre]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://univers-libre.net/?p=514</guid>
		<description><![CDATA[BlogIt est un plugin Vim écrit en python, qui permet, via le protocole xmlrpc, d&#8217;interagir avec votre WordPress. Les avantages sont bien sûr de pouvoir bénéficier de toutes les commandes Vim lors de l&#8217;écriture d&#8217;un article, avec la coloration html par exemple, mais aussi de pouvoir préparer son article hors-ligne et de le commiter plus [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://symlink.me/projects/blogit/">BlogIt</a> est un plugin Vim écrit en python, qui permet, via le protocole xmlrpc, d&#8217;interagir avec votre WordPress. Les avantages sont bien sûr de pouvoir bénéficier de toutes les commandes Vim lors de l&#8217;écriture d&#8217;un article, avec la coloration html par exemple, mais aussi de pouvoir préparer son article hors-ligne et de le commiter plus tard.</p>
<h2>Fonctionnalités</h2>
<ul>
<li>Création/édition/suppression/listage des articles et pages ;</li>
<li>Prévisualisation hors-ligne de l&#8217;article dans un navigateur ;</li>
<li>Publication/retrait d&#8217;un article ;</li>
<li>En-tête de l&#8217;article (un peu comme pour les mails) permettant de définir le titre, les tags et catégories…</li>
<li>Des hooks blogit_format et blogit_unformat, appelés respectivement juste avant un commit et juste après un edit, permettant de formater/déformater le texte avec des langages comme markdown, textile, reStructuredText… à l&#8217;aide de <a href="http://johnmacfarlane.net/pandoc/">pandoc</a>.
</li>
</ul>
<h2>Installation</h2>
<p>Je reprend un peu la procédure du <a href="http://symlink.me/projects/blogit/wiki">wiki</a>, mais traduite en français ici.</p>
<p>Tout d&#8217;abord, il vous faut un Vim compilé avec le support de python (rarement le cas par défaut) :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #660033;">--version</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">grep</span> python</pre></div></div>

<p>Sous ArchLinux, il faut installer le paquet gvim, et sous Debian et dérivées, il s&#8217;agit du paquet vim-python (qui installera vim-gtk).</p>
<p>Vous pouvez ensuite <a href="http://symlink.me/projects/blogit/files">récupérer l&#8217;archive</a> et la décompresser dans votre ~/.vim/.</p>
<p>Il faut maintenant créer le fichier ~/.vim/passwords.vim qui contiendra les informations de connexion à votre blog :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="" style="font-family:monospace;">let blogit_username='Your blog user name'
let blogit_password='Your blog password. Not the API-key.'
let blogit_url='https://example.com/xmlrpc.php'</pre></td></tr></table></div>

<p>Au passage, un chmod 600 sur ce fichier ne sera pas de trop…</p>
<h2>Utilisation</h2>
<p>Le script s&#8217;appelle via :Blogit. Un :Blogit help vous renverra la liste des commandes possibles :<br />
<pre><pre>Available commands:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp; :Blogit ls [blog]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; list all posts
&nbsp;&nbsp; :Blogit new [blog]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;create a new post
&nbsp;&nbsp; :Blogit this [blog]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; make this a blog post
&nbsp;&nbsp; :Blogit edit {id} [blog]&nbsp;&nbsp;edit a post
&nbsp;&nbsp; :Blogit page {id} [blog]&nbsp;&nbsp;edit a page
&nbsp;&nbsp; :Blogit commit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;save article
&nbsp;&nbsp; :Blogit push&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;publish article
&nbsp;&nbsp; :Blogit unpush&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unpublish article (save as draft)
&nbsp;&nbsp; :Blogit rm {id}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; remove a post
&nbsp;&nbsp; :Blogit tags&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;update and list tags and categories
&nbsp;&nbsp; :Blogit preview&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; preview article in browser
&nbsp;&nbsp; :Blogit help&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;display this notice</pre></pre></p>
<p>Je ne détaille pas plus, les commandes sont assez explicite selon moi.</p>
<h2>Bonus</h2>
<p>Vous voudriez surement rajouter des options automatiquement lors de l&#8217;édition des articles<br />
(par exemple set spell pour la correction orthographique). Dans ce cas, il faut les<br />
définir dans la méthode python init_vim_buffer() de la classe BlogPost du<br />
plugin (attention à le faire dans la bonne classe, il y en a plusieurs), comme ceci :</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">vim.<span style="color: black;">command</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'setlocal spell tw=80'</span><span style="color: black;">&#41;</span></pre></div></div>

</p>
<p>De même, il peut être sympa d&#8217;affecter une touche à la commande :Blogit commit, à l&#8217;aide de map :</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">vim.<span style="color: black;">command</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'map &lt;f9&gt; :Blogit commit &lt;CR&gt;'</span><span style="color: black;">&#41;</span></pre></div></div>

</p>
<p><a href="http://univers-libre.net/wp-content/uploads/2010/10/2010-10-30-191207_1272x749_scrot.png"><img src="http://univers-libre.net/wp-content/uploads/2010/10/2010-10-30-191207_1272x749_scrot-500x325.png" alt="screenshot blogit vim" title="2010-10-30-191207_1272x749_scrot" width="500" height="325" class="alignright size-large wp-image-678" /></a></p>
<p><i>Article fièrement écrit avec Vim <img src='http://univers-libre.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</i></p>
]]></content:encoded>
			<wfw:commentRss>http://univers-libre.net/index.php/2010/10/bloguez-vos-articles-wordpress-depuis-vim/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Semi marathon de Provence Lubéron</title>
		<link>http://univers-libre.net/index.php/2010/10/semi-marathon-de-provence-luberon/</link>
		<comments>http://univers-libre.net/index.php/2010/10/semi-marathon-de-provence-luberon/#comments</comments>
		<pubDate>Sun, 10 Oct 2010 18:23:40 +0000</pubDate>
		<dc:creator>billux</dc:creator>
				<category><![CDATA[Divers]]></category>
		<category><![CDATA[2010]]></category>
		<category><![CDATA[lubéron]]></category>
		<category><![CDATA[marathon]]></category>
		<category><![CDATA[pertuis]]></category>

		<guid isPermaLink="false">http://univers-libre.net/?p=635</guid>
		<description><![CDATA[Pour changer d&#8217;informatique… Dimanche 3 octobre, j&#8217;ai couru mon premier semi marathon, accompagné de 2 collègues. Pour une première fois, j&#8217;en suis plutôt content, j&#8217;ai finis en 2h12 les 21,1 km. J&#8217;ai été classé 736ème sur 988, mais le milieu de peloton (le 494ème) a mis 2h pile, ce qui laisse entendre qu&#8217;on était beaucoup [...]]]></description>
			<content:encoded><![CDATA[<p>Pour changer d&#8217;informatique…</p>
<p>Dimanche 3 octobre, j&#8217;ai couru mon premier semi marathon, accompagné de 2 collègues. Pour une première fois, j&#8217;en suis plutôt content, j&#8217;ai finis en 2h12 les 21,1 km. J&#8217;ai été classé 736<sup>ème</sup> sur 988, mais le milieu de peloton (le 494<sup>ème</sup>) a mis 2h pile, ce qui laisse entendre qu&#8217;on était beaucoup à arriver entre 2h et 2h15. </p>
<p>D&#8217;un point de vue parcours et organisation, c&#8217;était superbe. Le circuit partait de Pertuis pour rejoindre la Tour d&#8217;Aigues en passant par l&#8217;étang de la Bonde. Il y avait très peu de portion dans la ville, la majorité du circuit suivait une route en pleine campagne ou un chemin de terre au milieu des vignes, sans compter le tour du très joli étang de la Bonde. À l&#8217;arrivée, on avait de quoi boire et manger à volonté (en plus des ravitaillements le long du parcours), et une bouteille de vin du Lubéron offerte ! (les marathoniens en avaient droit à 2…). <a href="http://maps.google.fr/maps/ms?ie=UTF8&amp;hl=fr&amp;msa=0&amp;t=h&amp;msid=102496435422678581948.000450c414363063e5079&amp;ll=43.748777,5.495567&amp;spn=0.086803,0.145912&amp;z=12&amp;source=embed">Plan du parcours</a>.</p>
<p>L&#8217;ambiance était très orientée fête, entre les personnes qui courraient déguisées, le marché du terroir à l&#8217;arrivée, etc… c&#8217;était très bien organisé.</p>
<p>D&#8217;un point de vue difficulté, j&#8217;ai senti la fatigue venir vers le 14<sup>ème</sup> km (je cours rarement plus de cette distance là en tant normal), et à partir du 17<sup>ème</sup> km, je ne pensais plus qu&#8217;à l&#8217;arrivée.</p>
<p>Les derniers 100 mètre était très dur, malgré le public et la fanfare, dans le sens où je savais que l&#8217;arrivée était toute proche, mais je ne la voyais toujours pas.</p>
<p>Mais malgré la difficulté, je n&#8217;ai jamais pris autant de plaisir à courir. Le fait de courir pour un but précis surtout (atteindre l&#8217;arrivée), mais aussi d&#8217;être entouré d&#8217;un tas d&#8217;autres gens qui courraient également dans le même but et avec un grand nombre de spectateurs était super motivant. Ça n&#8217;avait rien à voir avec courir le soir, seul ou avec des collègues.</p>
<p>Bref, après tout ça, je peux dire sans hésitation que ce ne sera pas mon dernier !</p>
<p>Pour finir, quelques photos :</p>

<a href='http://univers-libre.net/index.php/2010/10/semi-marathon-de-provence-luberon/depart/' title='depart'><img width="150" height="112" src="http://univers-libre.net/wp-content/uploads/2010/10/depart-150x112.jpg" class="attachment-thumbnail" alt="depart" title="depart" /></a>
<a href='http://univers-libre.net/index.php/2010/10/semi-marathon-de-provence-luberon/samsung-2/' title='SAMSUNG'><img width="150" height="112" src="http://univers-libre.net/wp-content/uploads/2010/10/2010-10-03-09.45.15-150x112.jpg" class="attachment-thumbnail" alt="SAMSUNG" title="SAMSUNG" /></a>
<a href='http://univers-libre.net/index.php/2010/10/semi-marathon-de-provence-luberon/samsung/' title='SAMSUNG'><img width="150" height="112" src="http://univers-libre.net/wp-content/uploads/2010/10/2010-10-03-09.44.47-150x112.jpg" class="attachment-thumbnail" alt="SAMSUNG" title="SAMSUNG" /></a>
<a href='http://univers-libre.net/index.php/2010/10/semi-marathon-de-provence-luberon/samsung-3/' title='SAMSUNG'><img width="150" height="112" src="http://univers-libre.net/wp-content/uploads/2010/10/2010-10-03-10.00.50-150x112.jpg" class="attachment-thumbnail" alt="SAMSUNG" title="SAMSUNG" /></a>
<a href='http://univers-libre.net/index.php/2010/10/semi-marathon-de-provence-luberon/samsung-4/' title='SAMSUNG'><img width="150" height="112" src="http://univers-libre.net/wp-content/uploads/2010/10/2010-10-03-10.08.50-150x112.jpg" class="attachment-thumbnail" alt="SAMSUNG" title="SAMSUNG" /></a>
<a href='http://univers-libre.net/index.php/2010/10/semi-marathon-de-provence-luberon/moi-thomas/' title='moi-thomas'><img width="150" height="99" src="http://univers-libre.net/wp-content/uploads/2010/10/moi-thomas-150x99.jpg" class="attachment-thumbnail" alt="moi-thomas" title="moi-thomas" /></a>
<a href='http://univers-libre.net/index.php/2010/10/semi-marathon-de-provence-luberon/moi-2/' title='moi'><img width="99" height="150" src="http://univers-libre.net/wp-content/uploads/2010/10/moi-99x150.jpg" class="attachment-thumbnail" alt="moi" title="moi" /></a>
<a href='http://univers-libre.net/index.php/2010/10/semi-marathon-de-provence-luberon/samsung-5/' title='SAMSUNG'><img width="112" height="150" src="http://univers-libre.net/wp-content/uploads/2010/10/2010-10-03-12.17.49-112x150.jpg" class="attachment-thumbnail" alt="SAMSUNG" title="SAMSUNG" /></a>
<a href='http://univers-libre.net/index.php/2010/10/semi-marathon-de-provence-luberon/samsung-6/' title='SAMSUNG'><img width="150" height="112" src="http://univers-libre.net/wp-content/uploads/2010/10/2010-10-03-12.21.12-150x112.jpg" class="attachment-thumbnail" alt="SAMSUNG" title="SAMSUNG" /></a>
<a href='http://univers-libre.net/index.php/2010/10/semi-marathon-de-provence-luberon/samsung-7/' title='SAMSUNG'><img width="150" height="112" src="http://univers-libre.net/wp-content/uploads/2010/10/2010-10-03-12.51.25-150x112.jpg" class="attachment-thumbnail" alt="SAMSUNG" title="SAMSUNG" /></a>
<a href='http://univers-libre.net/index.php/2010/10/semi-marathon-de-provence-luberon/samsung-8/' title='SAMSUNG'><img width="112" height="150" src="http://univers-libre.net/wp-content/uploads/2010/10/2010-10-03-13.02.17-112x150.jpg" class="attachment-thumbnail" alt="SAMSUNG" title="SAMSUNG" /></a>

<p>Plus de photos <a href="http://www.flickr.com/photos/demarcq/sets/72157625085432192/?page=9">ici</a>, <a href="http://www.facebook.com/album.php?aid=40999&#038;id=117391971605556">là</a>, et encore <a href="http://www.jingoo.com/album/public.php?id_photographe=58550">là</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://univers-libre.net/index.php/2010/10/semi-marathon-de-provence-luberon/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>trier numériquement la sortie d’un du -h</title>
		<link>http://univers-libre.net/index.php/2010/09/trier-numeriquement-la-sortie-dun-du-h/</link>
		<comments>http://univers-libre.net/index.php/2010/09/trier-numeriquement-la-sortie-dun-du-h/#comments</comments>
		<pubDate>Sat, 11 Sep 2010 13:14:25 +0000</pubDate>
		<dc:creator>billux</dc:creator>
				<category><![CDATA[GNU-Linux et Logiciels Libres]]></category>
		<category><![CDATA[Trucs & Astuces]]></category>
		<category><![CDATA[du]]></category>
		<category><![CDATA[human readable]]></category>
		<category><![CDATA[planet-evolix]]></category>
		<category><![CDATA[planet-libre]]></category>
		<category><![CDATA[sort]]></category>
		<category><![CDATA[taille]]></category>
		<category><![CDATA[tri]]></category>

		<guid isPermaLink="false">http://univers-libre.net/?p=622</guid>
		<description><![CDATA[Afficher la taille que prend un répertoire ainsi que ses sous répertoires est une tache assez courante, du moins pour un administrateur système. Cela se fait simplement avec la commande : du -sh foo/* Ou bien, si on veut avoir aussi les sous sous répertoires : du -h --max-depth 2 foo/* L&#8217;option -h permettant d&#8217;avoir [...]]]></description>
			<content:encoded><![CDATA[<p>Afficher la taille que prend un répertoire ainsi que ses sous répertoires est une tache assez courante, du moins pour un administrateur système. Cela se fait simplement avec la commande :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #660033;">-sh</span> foo<span style="color: #000000; font-weight: bold;">/*</span></pre></div></div>

<p>Ou bien, si on veut avoir aussi les sous sous répertoires :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #660033;">-h</span> <span style="color: #660033;">--max-depth</span> <span style="color: #000000;">2</span> foo<span style="color: #000000; font-weight: bold;">/*</span></pre></div></div>

<p>L&#8217;option -h permettant d&#8217;avoir la taille exprimé en kilo, méga, giga, etc…</p>
<p>Là où les choses se compliquent, c&#8217;est lorsqu&#8217;on veut trier numériquement le résultat par ordre décroissant. Si on fait un :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #660033;">-sh</span> foo<span style="color: #000000; font-weight: bold;">/*</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-rn</span></pre></div></div>

<p>le tri sera faussé du fait de la présence des lettres qui suivent la taille.</p>
<p><em>D&#8217;où l&#8217;astuce du jour : comment trier numériquement la sortie d&#8217;un du tout en ayant la taille exprimé en &laquo;&nbsp;human readable&nbsp;&raquo; ?</em></p>
<p>Si vous avez le paquet coreutils en version ≥ 7.5, vous êtes sauvé, sort implémente l&#8217;option -h qui répond exactement au problème (merci à Roland pour sa <a href="http://univers-libre.net/index.php/2010/09/trier-numeriquement-la-sortie-dun-du-h/#comment-250">remarque</a>) :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #660033;">-sh</span> foo<span style="color: #000000; font-weight: bold;">/*</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-rh</span></pre></div></div>

</p>
<p>Dans le cas contraire (si vous êtes sur une Debian Lenny par exemple), c&#8217;est un peu moins simple.<br />
En cherchant un peu sur le net, il existe un tas d&#8217;astuces différentes utilisant perl ou awk. Voici celle que j&#8217;utilise, qui me semble la moins tordue (mais un peu quand même) :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #660033;">-s</span> foo<span style="color: #000000; font-weight: bold;">/*</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-rn</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-f2</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">'\n'</span> <span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #660033;">-sh</span></pre></div></div>

<p>Le principe est d&#8217;obtenir d&#8217;abord la liste des répertoires avec leur taille &laquo;&nbsp;brute&nbsp;&raquo;, de trier cette liste, puis de refaire un du (avec -h cette fois) sur chaque répertoire de la liste).<br />
Le fait d&#8217;exécuter 2 fois un du n&#8217;est pas super élégant point de performance, mais en pratique, comme le résultat du premier du est caché en mémoire, le second est très rapide.</p>
]]></content:encoded>
			<wfw:commentRss>http://univers-libre.net/index.php/2010/09/trier-numeriquement-la-sortie-dun-du-h/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using xcache (Requested URI is rejected)
Object Caching 1504/1704 objects using xcache

Served from: univers-libre.net @ 2012-02-05 07:34:46 -->
