<?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>Zuzur&#039;s corner</title>
	<atom:link href="http://arzur.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://arzur.net</link>
	<description>technology, the web, programming and a bit of this and that ...</description>
	<lastBuildDate>Thu, 29 Dec 2011 09:24:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Notebook: batch m4a to flac conversion using find/xargs/ffmpeg</title>
		<link>http://arzur.net/2011/12/29/notebook-batch-m4a-to-flac-conversion-using-findxargsffmpeg/</link>
		<comments>http://arzur.net/2011/12/29/notebook-batch-m4a-to-flac-conversion-using-findxargsffmpeg/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 09:24:32 +0000</pubDate>
		<dc:creator>erwan</dc:creator>
				<category><![CDATA[notebook]]></category>

		<guid isPermaLink="false">http://arzur.net/?p=212</guid>
		<description><![CDATA[If you have a large collection of files in a certain format and need to convert it to another, it can be quite tricky to do so and retain every tag information and all (i didn't find any tool that would allow me to do that, even the excellent xACT doesn't) So ... you will [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Farzur.net%2F2011%2F12%2F29%2Fnotebook-batch-m4a-to-flac-conversion-using-findxargsffmpeg%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Farzur.net%2F2011%2F12%2F29%2Fnotebook-batch-m4a-to-flac-conversion-using-findxargsffmpeg%2F&amp;source=zuzur&amp;style=compact&amp;service=bit.ly&amp;service_api=R_0f41ee6dc559533f38d25e8df96d20fd&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>If you have a large collection of files in a certain format and need to convert it to another, it can be quite tricky to do so and retain every tag information and all (i didn't find any tool that would allow me to do that, even the excellent xACT doesn't)</p>
<p>So ...</p>
<p>you will need to have ffmpeg installed. I just used <code>sudo port install ffmpeg</code> on my mac.</p>
<p>First you need to write a little shell script. I've called it toflac.sh. This script will perform the conversion :</p>
<p><code lang="shell">#!/bin/sh</p>
<p>ffmpeg -i "$1" -f flac "${1%.m4a}.flac"<br />
</code><br />
(change the extensions appropriately to fit your needs)</p>
<p>then call it using the following command line:</p>
<p><code lang="shell">find . -name *.m4a -print0 | xargs -0 -P 4 -n 1 ./toflac.sh </code></p>
<p>this runs 4 parallel ffmpeg processes to convert your files. Quite handy.</p>
]]></content:encoded>
			<wfw:commentRss>http://arzur.net/2011/12/29/notebook-batch-m4a-to-flac-conversion-using-findxargsffmpeg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calibre + mediapart FTW</title>
		<link>http://arzur.net/2011/05/22/calibre-mediapart-ftw/</link>
		<comments>http://arzur.net/2011/05/22/calibre-mediapart-ftw/#comments</comments>
		<pubDate>Sun, 22 May 2011 10:38:52 +0000</pubDate>
		<dc:creator>erwan</dc:creator>
				<category><![CDATA[notebook]]></category>
		<category><![CDATA[calibre]]></category>
		<category><![CDATA[mediapart]]></category>

		<guid isPermaLink="false">http://arzur.net/?p=206</guid>
		<description><![CDATA[Depuis quelques temps, la recette de calibre pour récupérer et convertir mediapart est cassée. On recevait une jolie trace python: Traceback (most recent call last): File "/Applications/calibre.app/Contents/Resources/Python/lib/python2.7/site.py", line 147, in main return run_entry_point() File "/Applications/calibre.app/Contents/Resources/Python/lib/python2.7/site.py", line 116, in run_entry_point return getattr(pmod, func)() File "site-packages/calibre/utils/ipc/worker.py", line 119, in main File "site-packages/calibre/gui2/convert/gui_conversion.py", line 25, in gui_convert File [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Farzur.net%2F2011%2F05%2F22%2Fcalibre-mediapart-ftw%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Farzur.net%2F2011%2F05%2F22%2Fcalibre-mediapart-ftw%2F&amp;source=zuzur&amp;style=compact&amp;service=bit.ly&amp;service_api=R_0f41ee6dc559533f38d25e8df96d20fd&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Depuis quelques temps, la recette de calibre pour récupérer et convertir mediapart est cassée. On recevait une jolie trace python:</p>
<pre>
Traceback (most recent call last):
  File "/Applications/calibre.app/Contents/Resources/Python/lib/python2.7/site.py", line 147, in main
    return run_entry_point()
  File "/Applications/calibre.app/Contents/Resources/Python/lib/python2.7/site.py", line 116, in run_entry_point
    return getattr(pmod, func)()
  File "site-packages/calibre/utils/ipc/worker.py", line 119, in main
  File "site-packages/calibre/gui2/convert/gui_conversion.py", line 25, in gui_convert
  File "site-packages/calibre/ebooks/conversion/plumber.py", line 920, in run
  File "site-packages/calibre/customize/conversion.py", line 204, in __call__
  File "site-packages/calibre/web/feeds/input.py", line 101, in convert
  File "site-packages/calibre/web/feeds/news.py", line 632, in __init__
  File "/var/folders/0z/0zkMgRtCGm8ofh4LX0jh0U+++TM/-Tmp-/calibre_0.8.0_tmp_IwF6Co/calibre_0.8.0_aTb7l5_recipes/recipe0.py", line 78, in get_browser
    br['name'] = self.username
  File "site-packages/mechanize/_form.py", line 2780, in __setitem__
  File "site-packages/mechanize/_form.py", line 3101, in find_control
  File "site-packages/mechanize/_form.py", line 3185, in _find_control
mechanize._form.ControlNotFoundError: no control matching name 'name'
</pre>
<p>Pour la corriger, il suffit de changer cette méthode de la recette qui récupère les news:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> get_browser<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        br = BasicNewsRecipe.<span style="color: black;">get_browser</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">self</span>.<span style="color: black;">username</span> <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">None</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: #008000;">self</span>.<span style="color: black;">password</span> <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">None</span>:
            br.<span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://www.mediapart.fr/'</span><span style="color: black;">&#41;</span>
            br.<span style="color: black;">select_form</span><span style="color: black;">&#40;</span>nr=<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
            br<span style="color: black;">&#91;</span><span style="color: #483d8b;">'name'</span><span style="color: black;">&#93;</span> = <span style="color: #008000;">self</span>.<span style="color: black;">username</span>
            br<span style="color: black;">&#91;</span><span style="color: #483d8b;">'pass'</span><span style="color: black;">&#93;</span> = <span style="color: #008000;">self</span>.<span style="color: black;">password</span>
            br.<span style="color: black;">submit</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> br</pre></div></div>

<p>et de remplacer</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">&nbsp;
            br.<span style="color: black;">select_form</span><span style="color: black;">&#40;</span>nr=<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span></pre></div></div>

<p>par</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">&nbsp;
            br.<span style="color: black;">select_form</span><span style="color: black;">&#40;</span>nr=<span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Je cherche comment adresser un élément form par son id avec mechanize (il a id='user-input-form' comme attribut), parce que c'est quand même royalement pénible de se baser sur le fait que la home page de mediapart présente son formulaire de login en premier (ou en deuxième dans ce cas particulier)</p>
<p>nb: ça fait 15 ans que j'ai écrit ma dernière ligne de python. Si si <img src='http://arzur.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://arzur.net/2011/05/22/calibre-mediapart-ftw/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>La consultation IPRED n&#8217;est pas entierement vaine ?</title>
		<link>http://arzur.net/2011/05/18/la-consultation-ipred-nest-pas-entierement-vaine/</link>
		<comments>http://arzur.net/2011/05/18/la-consultation-ipred-nest-pas-entierement-vaine/#comments</comments>
		<pubDate>Wed, 18 May 2011 09:54:05 +0000</pubDate>
		<dc:creator>erwan</dc:creator>
				<category><![CDATA[Non classé]]></category>

		<guid isPermaLink="false">http://arzur.net/?p=202</guid>
		<description><![CDATA[Dans la boîte aux lettres ce matin, en réponse à mon article sur la consultation IPRED Donc une consultation publique ne serait pas complétement vaine ? No way ... Madame, Monsieur, Un grand merci pour votre contribution au rapport de la Commission sur la directive 2004/48/CE relative au respect des droits de propriété intellectuelle. Vos [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Farzur.net%2F2011%2F05%2F18%2Fla-consultation-ipred-nest-pas-entierement-vaine%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Farzur.net%2F2011%2F05%2F18%2Fla-consultation-ipred-nest-pas-entierement-vaine%2F&amp;source=zuzur&amp;style=compact&amp;service=bit.ly&amp;service_api=R_0f41ee6dc559533f38d25e8df96d20fd&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Dans la boîte aux lettres ce matin, en réponse <a href="http://arzur.net/2011/03/22/ma-reponse-a-la-consultation-ipred/">à mon article sur la consultation IPRED</a></p>
<p>Donc une consultation publique ne serait pas complétement vaine ? </p>
<p>No way ...</p>
<blockquote><p>
Madame, Monsieur,</p>
<p>Un grand merci pour votre contribution au rapport de la Commission sur la directive 2004/48/CE relative au respect des droits de propriété intellectuelle. Vos observations ont bien été reçues et ont bien été prises en compte lors de l' évaluation globale de cette consultation publique.</p>
<p>Cordialement,</p>
<p>Commission Européenne<br />
DG Markt D.3<br />
Respect des droits de propriété intellectuelle
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://arzur.net/2011/05/18/la-consultation-ipred-nest-pas-entierement-vaine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Retour d&#8217;experience sur mon livre electronique</title>
		<link>http://arzur.net/2011/04/30/retour-dexperience-sur-mon-livre-electronique/</link>
		<comments>http://arzur.net/2011/04/30/retour-dexperience-sur-mon-livre-electronique/#comments</comments>
		<pubDate>Sat, 30 Apr 2011 10:08:24 +0000</pubDate>
		<dc:creator>erwan</dc:creator>
				<category><![CDATA[Non classé]]></category>
		<category><![CDATA[ebook]]></category>
		<category><![CDATA[piratage]]></category>

		<guid isPermaLink="false">http://arzur.net/?p=190</guid>
		<description><![CDATA[Il y a quelques mois je me suis offert un e-reader sony (PRS-650). Je voyage toutes les semaines ou presque en train et, constatant que j'avais toujours au minimum 4 livres dans mon sac, j'espérais pouvoir me décharger un peu. Après quelques mois d'utilisation j'ai un avis très partagé. Ce n'est pas à cause du [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Farzur.net%2F2011%2F04%2F30%2Fretour-dexperience-sur-mon-livre-electronique%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Farzur.net%2F2011%2F04%2F30%2Fretour-dexperience-sur-mon-livre-electronique%2F&amp;source=zuzur&amp;style=compact&amp;service=bit.ly&amp;service_api=R_0f41ee6dc559533f38d25e8df96d20fd&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Il y a quelques mois je me suis offert un e-reader sony (PRS-650). Je voyage toutes les semaines ou presque en train et, constatant que j'avais toujours au minimum 4 livres dans mon sac, j'espérais pouvoir me décharger un peu. Après quelques mois d'utilisation j'ai un avis très partagé.</p>
<p>Ce n'est pas à cause du lecteur, qui est très bien. L'e-ink est une technologie formidable. Cela consomme très peu d'énergie, une charge du livre me donne 3 ou 4 semaines sans recharge. Pour tout dire, je n'ai jamais réussi à aller au bout de la batterie sans brancher mon appareil - comme il ne dispose pas de wi-fi, pour mettre à jour le contenu, je dois le brancher à mon PC, ce que je fais régulièrement, donc je n'ai jamais eu aucun problème d'autonomie.</p>
<h3>Les formats</h3>
<p>Le format "natif" (en tout cas celui qui est le plus supportable pour ce lecteur) est le format E-PUB. Les fichiers E-PUB sont de simple fichiers XML qui contiennent quelques données de formatage (feuilles de styles, spécification des polices, etc) mais ne sont pas <strong>paginés</strong>.</p>
<p>Les formats qui présupposent la taille de la page à afficher (en particulier le PDF) ne sont pas du tout adaptés. On doit faire des contorsions assez incroyables pour obtenir un résultat lisible quand on essaye de lire un PDF. Par exemple, il faut passer la liseuse en mode paysage (toute l'ergonomie du dispositif est chamboulée dans ce mode) pour pouvoir afficher au maximum 1/3 de la page. Comme le lecteur n'est pas un foudre de guerre, le déplacement dans la page est au mieux insupportable. <strong>Je n'arrive pas à lire de PDF avec ma liseuse, bien qu'elle soit tamponnée Adobe Reader machin</strong>. Je suppose que chez sony, ils n'ont même pas essayé de finir un livre en PDF avec leur liseuse.</p>
<p>Un seul conseil: <strong>oubliez les PDF là-dessus</strong>. Les papiers interessants avec des graphiques ? oubliez. Les livres techniques en pdf ? oubliez, ou alors juste comme ça en référence (j'ai ma copie de "High Performance MySQL" dessus et il m'arrive de m'y référer, mais c'est proche du calvaire)</p>
<h3>Calibre</h3>
<p>Un outil indispensable avec ce genre d'appareil: <a title="Calibre" href="http://calibre-ebook.com/" target="_blank">calibre</a>. Ce logiciel permet d'organiser sa collection de livre, et <strong>surtout</strong>, de récupérer des flux de news, de les transformer en format E-PUB avant de les envoyer sur la liseuse. On peut ainsi avoir le monde, libé, mediapart (si on est abonné), sous la main quand on veut. Cela fonctionne merveilleusement bien, à part quelques problèmes (liens morts surtout) dus à la conversion et au scripts qui crawlent.</p>
<p>Calibre permet aussi de faire des conversion (au hasard, PDF vers EPUB), mais je n'ai jamais obtenu de résultat qui me satisfasse.</p>
<h3>Instapaper + Calibre FTW</h3>
<p>J'ai découvert récemment que I<a href="http://www.instapaper.com" target="_blank">nstapaper</a> fournissait un flux RSS des pages qu'on ajoutait à son compte ! comme calibre peut s'abonner à n'importe quel flux RSS et le convertir afin de le pousser sur la liseuse, c'est génial. Il suffit d'ajouter "une source personnalisée de news" et de la paramétrer avec l'adresse du flux de votre compte instapaper.</p>
<p>J'envoie souvent les longs articles sur lesquels je tombe (<a href="http://aws.amazon.com/message/65648/" target="_blank">le post-mortem du crash AWS</a> de la semaine dernière par exemple) et que je n'ai pas le temps de lire tout de suite, et dès que je connecte ma liseuse ils sont envoyés automatiquement.</p>
<h3>Le plus gros probleme du livre electronique: les editeurs et les auteurs</h3>
<p>On en vient au vrai problème du livre électronique, quel que soit le fabricant.</p>
<p>Quand on a un livre electronique, on le reçoit souvent avec beaucoup de contenu gratuit - quand j'ai acheté le mien, la carte SD était farcie de livres gratuits provenant de Feedbooks - au demeurant très bien faits - mais interessants uniquement si on est passionné de littérature publiée avant 1930. J'aime beaucoup Zola, Dostoievsky, Conan Doyle, Zadig et Voltaire (hin hin hin hin) mais ... bref.</p>
<p>Assez rapidement, on cherche à se procurer des nouveautés. Et là on déchante. A part chez les éditeurs spécialisés "informatique", l'offre de livres numériques est misérable, et je pèse mes mots.</p>
<p><strong>Premièrement</strong>, voyant le succès extraordinaire qu'ont obtenu les éditeur de musique en mettant des MTP (DRMs) sur tout leur contenu, les éditeurs (je pense surtout aux "gros") n'ont rien trouvé de mieux que de farcir les leurs avec des saloperies privatrices de droits qui les rendent complétement inutilisables. <a href="http://www.korben.info/fnac-supprimer-drm-ebook.html" target="_blank">Korben a très bien expliqué le problème</a>. On se retrouve avec un truc moins pratique qu'un livre en papier, avec lequel on peut faire moins qu'avec un livre en papier (préter, donner, etc ...), et qu'on paye plus cher en plus ??!! Je reprends le slogan de Korben. <strong>Allez tous vous faire fnoutre !</strong></p>
<p><strong>Deuxièmement</strong>, l'offre est anémique. On pourrait imaginer qu'aujourd'hui la plupart des livres sont créés sur un ordinateur, qu'au long de toute la chaîne d'édition, un format numérique est utilisé, et qu'il semblerait facile d'en tirer un E-PUB à un moment et de le mettre à disposition des gens - comme moi - qui voudraient les acheter - en avant-première ? plus cher que les autres qui l'auront après ? peut-être même qu'ils pourraient participer à la relecture ? participer à la création avec leur auteur préféré ? des trucs de malades, pour lesquels ils seraient certainement prêts à payer un peu plus que les autres.</p>
<p>Ben non. Même pas. Petite expérience, faites une recherche de votre auteur préféré (en ce moment je suis très polars "nordique", Nesbö, Indriansson, ... l'expérience est assez amusante sur fnac et amazon)</p>
<p><strong>Troisièmement</strong>. Le prix. A notre époque, vendre le livre numérique au même prix qu'un roman broché c'est complétement débile ! au prix d'un format poche, ça serait peut-être interessant, mais quand même ! quelques centimes sous le prix du fromat broché ?! <strong>arrêtez de nous prendre pour des moules</strong> !</p>
<p>Le résultat, c'est que je n'ai pas acheté un seul livre numérique en bientôt 6 mois, que je me contente de m'en servir pour lire des articles glanés sur le web. Je continue à acheter des livres en papier et à me péter le dos. Ayant entendu les éditeurs et les auteurs discuter du livre numérique dans "Place de la toile" sur France Culture il y a quelques temps, avec des ministres comme Frédéric Mitterrand qui sont complètement à l'ouest, j'ai très peu d'espoir que quoi que ce soit se passe. Avec une telle capacité d'innovation, on n'est pas rendus.</p>
<p>Les gens iront au plus pratique, "pirateront" les livres et bien entendu les auteurs et les éditeurs en pâtiront. Evidemment, on blamera le méchant Internet, les "pirates",  les moteurs de recherche qui les indexeront, on fera des lois pour "sauver le livre", mais au fond, ce sera une nouvelle histoire de moines copistes qui se battent contre l'imprimerie.</p>
<p>Pour l'instant, à cause de tous ces gros cons, je déconseille vivement d'acheter une liseuse, mais je serai parmi les premiers abonnés du spotify pour livres electroniques qui va forcément voir le jour bientôt ! je l'attends avec la même impatience que celle que j'éprouve à l'idée de pouvoir me servir normalement du modem de mon téléphone 3G hyper moderne mais bridé par le truchement des opérateurs téléphonique ...</p>
]]></content:encoded>
			<wfw:commentRss>http://arzur.net/2011/04/30/retour-dexperience-sur-mon-livre-electronique/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Ma reponse a la consultation IPRED</title>
		<link>http://arzur.net/2011/03/22/ma-reponse-a-la-consultation-ipred/</link>
		<comments>http://arzur.net/2011/03/22/ma-reponse-a-la-consultation-ipred/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 12:41:46 +0000</pubDate>
		<dc:creator>erwan</dc:creator>
				<category><![CDATA[Non classé]]></category>

		<guid isPermaLink="false">http://arzur.net/?p=186</guid>
		<description><![CDATA[Suite à cet article de la quadrature du net - http://www.laquadrature.net/node/4260, j'ai enfin pris le temps d'écrire ce texte qui me chatouillait depuis des mois pour essayer de contribuer à l'éradication pure et simple des lois comme l'HADOPI. Ca doit être truffé de bêtise, je ne suis pas sur que ça soit la forme qu'il [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Farzur.net%2F2011%2F03%2F22%2Fma-reponse-a-la-consultation-ipred%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Farzur.net%2F2011%2F03%2F22%2Fma-reponse-a-la-consultation-ipred%2F&amp;source=zuzur&amp;style=compact&amp;service=bit.ly&amp;service_api=R_0f41ee6dc559533f38d25e8df96d20fd&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Suite à cet article de la quadrature du net - <a href="http://www.laquadrature.net/node/4260">http://www.laquadrature.net/node/4260</a>, j'ai enfin pris le temps d'écrire ce texte qui me chatouillait depuis des mois pour essayer de contribuer à l'éradication pure et simple des lois comme l'HADOPI. Ca doit être truffé de bêtise, je ne suis pas sur que ça soit la forme qu'il faut donner à une "contribution" d'un citoyen, mais voilà, c'est envoyé <img src='http://arzur.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<blockquote><p>Bonjour, je suis un citoyen français, adepte de technologie, cinéphile<br />
et amoureux de lecture.</p>
<p>Je suis outré par l'attitude des détenteurs des droits d'exploitation<br />
des oeuvres, qui, sous couvert de protection des auteurs, exploitent<br />
de façon éhontée un catalogue vieillissant, tout en refusant d'adapter<br />
leur offre aux nouvelles technologies - et surtout à l'économie de<br />
l'abondance qu'elles ont créée. En effet, les modèles commerciaux<br />
qu'exploitent les maisons de disque et les studios sont basé sur<br />
l'économie de la rareté qui prévalait jusqu'au 20e siècle, et ne<br />
peuvent s'adapter à l'économie numérique !</p>
<p>Je comprends que ces industries soient sources d'emplois et que leur<br />
disparition pourraient avoir quelque effet négatif sur nos économies,<br />
mais pour protéger leur rente de situation, nos décideurs politiques<br />
sont en train de créer des usines à gaz qui auront des effets<br />
économiques catastrophiques en plus d'institutionnaliser l'espionnage<br />
des citoyens européens.</p>
<p>Toutes les lois récentes - en particulier la loi qui a instauré la<br />
HADOPI en France - existent uniquement pour protéger ces modèles<br />
économiques dépassés, en instaurant des taxes (taxe pour la copie<br />
privée sur les disques durs que j'utilise à des fins professionnelles<br />
et qui n'hébergeront jamais un seul bit de film, de musique ou de<br />
livre ?!) et des délits (des amendes sans aucune proportion avec le<br />
préjudice supposé et distribuées sans preuve ?!) qui consistent en une<br />
subvention par l'état de ces industries - carte "Musique jeune"<br />
subventionnée à 50% dont les bénéfices vont quasiment uniquement à<br />
Apple par l'intermédiaire de sa plate-forme iTunes.</p>
<p>A l'occasion de la promulgation de cette loi, j'ai vraiment eu honte<br />
de mon gouvernement et des différentes institutions que notre<br />
République avait créé pour éviter la promulgation de telles lois !</p>
<p>Toutes les études sérieuses sur le sujet montrent que le<br />
téléchargement "illégal" ne nuit pas aux artistes, et que les<br />
internautes les plus téléchargeurs sont aussi les plus gros clients<br />
des industries qui veulent les éradiquer. Je ne prendrais même pas la<br />
peine de vous donner les références.</p>
<p>Comment peut-on imaginer un seul instant qu'une guerre sans limite<br />
contre ses propres clients aura l'effet escompté ?! Le partage de la<br />
connaissance, la copie privée et l'échange non rémunéré ne devraient<br />
pas réprimés !! Pourquoi, quand j'achète un DVD, je devrais passer 10<br />
minutes à regarder des messages sans intérêt sur le fait que "copier,<br />
c'est voler", et la longue litanie des les peines encourues en cas de<br />
copie illégale alors qu'un fichier téléchargé illégalement ne contient<br />
pas ces avertissements ? Pourquoi, quand on a manqué un épisode d'une<br />
série qu'on a apprécié, il est plus facile de se le procurer en le<br />
téléchargeant qu'en essayant de passer par des plate-forme de VOD aux<br />
tarifs irréalistes et aux catalogues anémiques ? Pourquoi les<br />
détenteurs de droits n'y verraient pas un marché plutôt qu'une bande<br />
de voleurs !</p>
<p>Un nouveau marché et de nouvelles opportunités se font jour avec le<br />
livre numérique ? Non - les éditeurs et le gouvernement français font<br />
tout pour le tuer dans l'oeuf et réduire la disponibilité des oeuvres<br />
à la portion congrue. Quand on veut lire une nouveauté sur sa liseuse,<br />
on est obligé d'accepter des mesures de restrictions d'usage - MTP ou<br />
DRM - qui rendent les seuls désavantages des livres en papier - le<br />
poids et le volume bien insignifiants en comparaison.</p>
<p>Lors de ce débat sur l'IPRED, j'ose croire que la commission<br />
européenne et les députés que nous avons élus sauront se  démarquer de<br />
ces politiques installées après des tragi-comédies qui n'ont donné<br />
qu'une très piètre image de la démocratie - en tout cas en France !<br />
Les députés UMP qui votent aveuglement des lois dont on mettra des<br />
années à se débarrasser, et dont les effets nous plongeront<br />
immanquablement dans un marasme économique, car ne vous trompez pas -<br />
les autres pays sauront adapter leur droit à cette nouvelle économie<br />
que vous êtes en train de laisser partir.</p>
<p>Cordialement,<br />
<span style="color: #888888;"><br />
Erwan Arzur</span></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://arzur.net/2011/03/22/ma-reponse-a-la-consultation-ipred/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Notebook: MacBook &#8211; Battery calibation</title>
		<link>http://arzur.net/2010/10/31/notebook-powerbook-battery-calibation/</link>
		<comments>http://arzur.net/2010/10/31/notebook-powerbook-battery-calibation/#comments</comments>
		<pubDate>Sun, 31 Oct 2010 11:32:31 +0000</pubDate>
		<dc:creator>erwan</dc:creator>
				<category><![CDATA[apple]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[battery]]></category>

		<guid isPermaLink="false">http://arzur.net/?p=169</guid>
		<description><![CDATA[A few weeks ago, my apr'09 13" MacBook started behaving strangely. After a few minutes off the power cord, it would simply shutdown without warning (no display of the low battery warning message ... blam ! Black screen of death). The led battery indicators would show the battery to be at 80%, and if you [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Farzur.net%2F2010%2F10%2F31%2Fnotebook-powerbook-battery-calibation%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Farzur.net%2F2010%2F10%2F31%2Fnotebook-powerbook-battery-calibation%2F&amp;source=zuzur&amp;style=compact&amp;service=bit.ly&amp;service_api=R_0f41ee6dc559533f38d25e8df96d20fd&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>A few weeks ago, my apr'09 13" MacBook started behaving strangely. After a few minutes off the power cord, it would simply shutdown without warning (no display of the low battery warning message ... blam ! Black screen of death). The led battery indicators would show the battery to be at 80%, and if you started the laptop again, it would work for 5-10 minutes ... then blam ! </p>
<p>I've looked for solutions to this issue for a while, this behaviour didn't match apple's documents about battery calibration / PMU reset in their knowledge base, i've tried following every steps documented there (links provided below) to no avail.</p>
<p><a href="http://support.apple.com/kb/ht3964">resetting the SMC</a><br />
<a href="http://support.apple.com/kb/ht1379">resetting the PRAM and NVRAM</a></p>
<p>I finally managed to get back to a properly running mac after following those instructions (<a href="http://support.apple.com/kb/HT1490">Battery calibration</a>) to the letter.</p>
<p>When the system would shutdown improperly, i would just start it up again until next time, and did this for 2 hours (about 6 or 7 power off / power on cycles) until the battery was completely depleted. </p>
<p>Then, i performed a full charge, allowing the system to rest for a few hours while on battery, powered it on, removed the battery adapter with my fingers crossed ... and ... I got my macbook back ! <img src='http://arzur.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Woooot <img src='http://arzur.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://arzur.net/2010/10/31/notebook-powerbook-battery-calibation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>scripting with chef</title>
		<link>http://arzur.net/2010/10/31/scripting-with-chef/</link>
		<comments>http://arzur.net/2010/10/31/scripting-with-chef/#comments</comments>
		<pubDate>Sun, 31 Oct 2010 08:44:42 +0000</pubDate>
		<dc:creator>erwan</dc:creator>
				<category><![CDATA[chef]]></category>
		<category><![CDATA[Non classé]]></category>
		<category><![CDATA[notebook]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://arzur.net/?p=162</guid>
		<description><![CDATA[Chef is a very cool platform management solution. Once it is setup, you have a very clean solution to distribute server configurations across as many servers as you need, very cleanly (Ruby DSL) and quickly. A must on AWS. One thing that you can't find easily in Chef's documentation is how to use the chef [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Farzur.net%2F2010%2F10%2F31%2Fscripting-with-chef%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Farzur.net%2F2010%2F10%2F31%2Fscripting-with-chef%2F&amp;source=zuzur&amp;style=compact&amp;service=bit.ly&amp;service_api=R_0f41ee6dc559533f38d25e8df96d20fd&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://opscode.com/chef">Chef</a> is a very cool platform management solution. Once it is setup, you have a very clean solution to distribute server configurations across as many servers as you need, very cleanly (Ruby DSL) and quickly. A must on AWS.</p>
<p>One thing that you can't find easily in Chef's documentation is how to use the chef API to write scripts that would use the information chef is storing. </p>
<p>Imagine having a script that would run regularly (cron) and update your internal DNS zone with A records for each server it can find in your chef database.</p>
<p>I'm not sure I used the "right" approach. I just pasted some code i borrowed from knife (chef's command-line tool) and added it to my own script. I intend to find a cleaner approach later (mixins, inheritance, etc ...)</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'chef/application'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'chef/client'</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'mixlib/cli'</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> Client <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">Chef::Application</span>
  <span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#6666ff; font-weight:bold;">Mixlib::CLI</span>
&nbsp;
  banner <span style="color:#996600;">&quot;Usage: #{$0} (options)&quot;</span>
&nbsp;
  option <span style="color:#ff3333; font-weight:bold;">:config_file</span>, 
    <span style="color:#ff3333; font-weight:bold;">:short</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;-c CONFIG&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:long</span>  <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;--config CONFIG&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:description</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;The configuration file to use&quot;</span>
&nbsp;
  option <span style="color:#ff3333; font-weight:bold;">:log_level</span>, 
    <span style="color:#ff3333; font-weight:bold;">:short</span>        <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;-l LEVEL&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:long</span>         <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;--log_level LEVEL&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:description</span>  <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Set the log level (debug, info, warn, error, fatal)&quot;</span>,
    :<span style="color:#CC0066; font-weight:bold;">proc</span>         <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#CC0066; font-weight:bold;">lambda</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>l<span style="color:#006600; font-weight:bold;">|</span> l.<span style="color:#9900CC;">to_sym</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
  option <span style="color:#ff3333; font-weight:bold;">:log_location</span>,
    <span style="color:#ff3333; font-weight:bold;">:short</span>        <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;-L LOGLOCATION&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:long</span>         <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;--logfile LOGLOCATION&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:description</span>  <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Set the log file location, defaults to STDOUT&quot;</span>,
    :<span style="color:#CC0066; font-weight:bold;">proc</span>         <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">nil</span>
&nbsp;
  option <span style="color:#ff3333; font-weight:bold;">:editor</span>,
    <span style="color:#ff3333; font-weight:bold;">:short</span>        <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;-e EDITOR&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:long</span>         <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;--editor EDITOR&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:description</span>  <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Set the editor to use for interactive commands&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:default</span>      <span style="color:#006600; font-weight:bold;">=&gt;</span> ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'EDITOR'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
  option <span style="color:#ff3333; font-weight:bold;">:no_editor</span>,
    <span style="color:#ff3333; font-weight:bold;">:short</span>        <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;-n&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:long</span>         <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;--no-editor&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:description</span>  <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Do not open EDITOR, just accept the data as is&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:boolean</span>      <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>
&nbsp;
  option <span style="color:#ff3333; font-weight:bold;">:help</span>,
    <span style="color:#ff3333; font-weight:bold;">:short</span>        <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;-h&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:long</span>         <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;--help&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:description</span>  <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Show this message&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:on</span>           <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:tail</span>,
    <span style="color:#ff3333; font-weight:bold;">:boolean</span>      <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>
&nbsp;
  option <span style="color:#ff3333; font-weight:bold;">:node_name</span>,
    <span style="color:#ff3333; font-weight:bold;">:short</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;-u USER&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:long</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;--user USER&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:description</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;API Client Username&quot;</span>
&nbsp;
  option <span style="color:#ff3333; font-weight:bold;">:client_key</span>,
    <span style="color:#ff3333; font-weight:bold;">:short</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;-k KEY&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:long</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;--key KEY&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:description</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;API Client Key&quot;</span>
&nbsp;
  option <span style="color:#ff3333; font-weight:bold;">:chef_server_url</span>,
    <span style="color:#ff3333; font-weight:bold;">:short</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;-s URL&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:long</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;--server-url URL&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:description</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Chef Server URL&quot;</span>
&nbsp;
  option <span style="color:#ff3333; font-weight:bold;">:yes</span>,
    <span style="color:#ff3333; font-weight:bold;">:short</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;-y&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:long</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;--yes&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:description</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Say yes to all prompts for confirmation&quot;</span>
&nbsp;
  option <span style="color:#ff3333; font-weight:bold;">:defaults</span>,
    <span style="color:#ff3333; font-weight:bold;">:long</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;--defaults&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:description</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Accept default values for all questions&quot;</span>
&nbsp;
  option <span style="color:#ff3333; font-weight:bold;">:print_after</span>,
    <span style="color:#ff3333; font-weight:bold;">:short</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;-p&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:long</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;--print-after&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:description</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Show the data after a destructive operation&quot;</span>
&nbsp;
  option :<span style="color:#CC0066; font-weight:bold;">format</span>,
    <span style="color:#ff3333; font-weight:bold;">:short</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;-F FORMAT&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:long</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;--format FORMAT&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:description</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Which format to use for output&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:default</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;json&quot;</span>
&nbsp;
  option <span style="color:#ff3333; font-weight:bold;">:version</span>,
    <span style="color:#ff3333; font-weight:bold;">:short</span>        <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;-v&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:long</span>         <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;--version&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:description</span>  <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Show chef version&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:boolean</span>      <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>,
    :<span style="color:#CC0066; font-weight:bold;">proc</span>         <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#CC0066; font-weight:bold;">lambda</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>v<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Chef: #{::Chef::VERSION}&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span>,
    :<span style="color:#CC0066; font-weight:bold;">exit</span>         <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">0</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> configure_chef
    <span style="color:#9966CC; font-weight:bold;">unless</span> config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:config_file</span><span style="color:#006600; font-weight:bold;">&#93;</span>
      full_path = <span style="color:#CC00FF; font-weight:bold;">Dir</span>.<span style="color:#9900CC;">pwd</span>.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>::SEPARATOR<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#006600; font-weight:bold;">&#40;</span>full_path.<span style="color:#9900CC;">length</span> <span style="color:#006600; font-weight:bold;">-</span> <span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">downto</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>i<span style="color:#006600; font-weight:bold;">|</span>
        config_file_to_check = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span> full_path<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span>..<span style="color:#9900CC;">i</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#996600;">&quot;.chef&quot;</span>, <span style="color:#996600;">&quot;client.rb&quot;</span> <span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">flatten</span><span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">exists</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>config_file_to_check<span style="color:#006600; font-weight:bold;">&#41;</span>
          config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:config_file</span><span style="color:#006600; font-weight:bold;">&#93;</span> = config_file_to_check 
          <span style="color:#9966CC; font-weight:bold;">break</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
      <span style="color:#008000; font-style:italic;"># If we haven't set a config yet and $HOME is set, and the home</span>
      <span style="color:#008000; font-style:italic;"># knife.rb exists, use it:</span>
      <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>!config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:config_file</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'HOME'</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">exist</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'HOME'</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#996600;">'.chef'</span>, <span style="color:#996600;">'client.rb'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
        config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:config_file</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'HOME'</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#996600;">'.chef'</span>, <span style="color:#996600;">'client.rb'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#008000; font-style:italic;"># Don't try to load a knife.rb if it doesn't exist.</span>
    <span style="color:#9966CC; font-weight:bold;">if</span> config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:config_file</span><span style="color:#006600; font-weight:bold;">&#93;</span>
      <span style="color:#6666ff; font-weight:bold;">Chef::Config</span>.<span style="color:#9900CC;">from_file</span><span style="color:#006600; font-weight:bold;">&#40;</span>config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:config_file</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">else</span>
      <span style="color:#008000; font-style:italic;"># ...but do log a message if no config was found.</span>
      <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">msg</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;No knife configuration file found&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#6666ff; font-weight:bold;">Chef::Config</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:log_level</span><span style="color:#006600; font-weight:bold;">&#93;</span> = config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:log_level</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">if</span> config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:log_level</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    <span style="color:#6666ff; font-weight:bold;">Chef::Config</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:log_location</span><span style="color:#006600; font-weight:bold;">&#93;</span> = config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:log_location</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">if</span> config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:log_location</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    <span style="color:#6666ff; font-weight:bold;">Chef::Config</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:node_name</span><span style="color:#006600; font-weight:bold;">&#93;</span> = config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:node_name</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">if</span> config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:node_name</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    <span style="color:#6666ff; font-weight:bold;">Chef::Config</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:client_key</span><span style="color:#006600; font-weight:bold;">&#93;</span> = config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:client_key</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">if</span> config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:client_key</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    <span style="color:#6666ff; font-weight:bold;">Chef::Config</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:chef_server_url</span><span style="color:#006600; font-weight:bold;">&#93;</span> = config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:chef_server_url</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">if</span> config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:chef_server_url</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    <span style="color:#6666ff; font-weight:bold;">Mixlib::Log::Formatter</span>.<span style="color:#9900CC;">show_time</span> = <span style="color:#0000FF; font-weight:bold;">false</span>
    <span style="color:#6666ff; font-weight:bold;">Chef::Log</span>.<span style="color:#9900CC;">init</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#6666ff; font-weight:bold;">Chef::Config</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:log_location</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#6666ff; font-weight:bold;">Chef::Log</span>.<span style="color:#9900CC;">level</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#6666ff; font-weight:bold;">Chef::Config</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:log_level</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
    <span style="color:#6666ff; font-weight:bold;">Chef::Log</span>.<span style="color:#9900CC;">debug</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Using configuration from #{config[:config_file]}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#6666ff; font-weight:bold;">Chef::Config</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:node_name</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#0000FF; font-weight:bold;">nil</span>?
      <span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#CC00FF; font-weight:bold;">ArgumentError</span>, <span style="color:#996600;">&quot;No user specified, pass via -u or specifiy 'node_name' in #{config[:config_file] ? config[:config_file] : &quot;</span>~<span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#9900CC;">chef</span><span style="color:#006600; font-weight:bold;">/</span>knife.<span style="color:#9900CC;">rb</span><span style="color:#996600;">&quot;}&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> parse_options<span style="color:#006600; font-weight:bold;">&#40;</span>args=<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> 
    <span style="color:#9966CC; font-weight:bold;">super</span>
    config    
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> run<span style="color:#006600; font-weight:bold;">&#40;</span>args<span style="color:#006600; font-weight:bold;">&#41;</span>
    parse_options<span style="color:#006600; font-weight:bold;">&#40;</span>args<span style="color:#006600; font-weight:bold;">&#41;</span>
    configure_chef
    <span style="color:#6666ff; font-weight:bold;">Chef::Search::Query</span>.<span style="color:#9900CC;">new</span>.<span style="color:#9900CC;">search</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:node</span>,<span style="color:#996600;">&quot;*:*&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>n<span style="color:#006600; font-weight:bold;">|</span>
       <span style="color:#008000; font-style:italic;">## iterate on every node. You have access to every information</span>
       <span style="color:#008000; font-style:italic;">## chef and ohai could collect from the nodes</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
Client.<span style="color:#9900CC;">new</span>.<span style="color:#9900CC;">run</span></pre></div></div>

<p>The command line options for your script are the same as knife's. And it works flawlessly.</p>
]]></content:encoded>
			<wfw:commentRss>http://arzur.net/2010/10/31/scripting-with-chef/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>notebook: running a unix command for a given amount of time</title>
		<link>http://arzur.net/2010/10/12/notebook-running-a-unix-command-for-a-given-amount-of-time/</link>
		<comments>http://arzur.net/2010/10/12/notebook-running-a-unix-command-for-a-given-amount-of-time/#comments</comments>
		<pubDate>Tue, 12 Oct 2010 15:01:21 +0000</pubDate>
		<dc:creator>erwan</dc:creator>
				<category><![CDATA[notebook]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://arzur.net/?p=156</guid>
		<description><![CDATA[Sometimes, you need to run a command (capture, etc ...) for a given amount of time. Here's an example of a script capturing mysql traffic for half an hour : #!/bin/sh DATE=`date +%Y%m%d%H%M%S` tcpdump -i eth0 port 3306 -s 65535 -x -n -q -tttt &#62; capture-$DATE.out &#38; sleep 1800 kill $!]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Farzur.net%2F2010%2F10%2F12%2Fnotebook-running-a-unix-command-for-a-given-amount-of-time%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Farzur.net%2F2010%2F10%2F12%2Fnotebook-running-a-unix-command-for-a-given-amount-of-time%2F&amp;source=zuzur&amp;style=compact&amp;service=bit.ly&amp;service_api=R_0f41ee6dc559533f38d25e8df96d20fd&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Sometimes, you need to run a command (capture, etc ...) for a given amount of time. Here's an example of a script capturing mysql traffic for half an hour :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #007800;">DATE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>Y<span style="color: #000000; font-weight: bold;">%</span>m<span style="color: #000000; font-weight: bold;">%</span>d<span style="color: #000000; font-weight: bold;">%</span>H<span style="color: #000000; font-weight: bold;">%</span>M<span style="color: #000000; font-weight: bold;">%</span>S<span style="color: #000000; font-weight: bold;">`</span>
tcpdump <span style="color: #660033;">-i</span> eth0 port <span style="color: #000000;">3306</span>  <span style="color: #660033;">-s</span> <span style="color: #000000;">65535</span> <span style="color: #660033;">-x</span> <span style="color: #660033;">-n</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-tttt</span> <span style="color: #000000; font-weight: bold;">&gt;</span> capture-<span style="color: #007800;">$DATE</span>.out <span style="color: #000000; font-weight: bold;">&amp;</span>
<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">1800</span> 
<span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #007800;">$!</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://arzur.net/2010/10/12/notebook-running-a-unix-command-for-a-given-amount-of-time/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>notebook: nagios / ndo2db on centOS 5.5 64 bits</title>
		<link>http://arzur.net/2010/10/10/notebook-nagios-ndo2db-on-centos-5-5-64-bits/</link>
		<comments>http://arzur.net/2010/10/10/notebook-nagios-ndo2db-on-centos-5-5-64-bits/#comments</comments>
		<pubDate>Sun, 10 Oct 2010 13:07:55 +0000</pubDate>
		<dc:creator>erwan</dc:creator>
				<category><![CDATA[notebook]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[nagios linux sysadmin]]></category>

		<guid isPermaLink="false">http://arzur.net/?p=151</guid>
		<description><![CDATA[Trying to setup nagios 3.1 with ndo2db on a 64bits platform, ndo2bd may not work properly and crash over and over. The symptoms are: [1286679019] ndomod: Still unable to connect to data sink. 7575 items lost, 5000 queued items to flush. in the nagios log file and /var/log/messages containing reports of ndo2db segfaults ... Oct [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Farzur.net%2F2010%2F10%2F10%2Fnotebook-nagios-ndo2db-on-centos-5-5-64-bits%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Farzur.net%2F2010%2F10%2F10%2Fnotebook-nagios-ndo2db-on-centos-5-5-64-bits%2F&amp;source=zuzur&amp;style=compact&amp;service=bit.ly&amp;service_api=R_0f41ee6dc559533f38d25e8df96d20fd&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Trying to setup nagios 3.1 with ndo2db on a 64bits platform, ndo2bd may not work properly and crash over and over.</p>
<p>The symptoms are:</p>
<pre>
[1286679019] ndomod: Still unable to connect to data sink.  7575 items lost, 5000 queued items to flush.
</pre>
<p>in the nagios log file<br />
and <code>/var/log/messages</code> containing reports of ndo2db segfaults ...</p>
<pre>
Oct 10 12:52:26 ip-10-112-41-174 kernel: ndo2db[15666]: segfault at 00007fff8701cff8 rip 00002aaaabf2d211 rsp 00007fff8701d000 error 6
</pre>
<p>Apparently, this comes from <code>ndo2db</code> being improperly linked to a 32bits version of the mysql client lib.</p>
<p>You need to configure ndo2db like this :</p>
<pre>
./configure --prefix=/opt/nagios --enable-mysql --disable-pgsql --with-ndo2db-user=nagios --with-ndo2db-group=nagios --with-mysql-lib=/usr/lib/mysql
</pre>
<p>then you can go on and install ndo2db as documented, nagios will happily log events into you supervision database</p>
]]></content:encoded>
			<wfw:commentRss>http://arzur.net/2010/10/10/notebook-nagios-ndo2db-on-centos-5-5-64-bits/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Some fun with groovy and AWS Identity And Access Management</title>
		<link>http://arzur.net/2010/10/04/some-fun-with-groovy-and-aws-identity-and-access-management/</link>
		<comments>http://arzur.net/2010/10/04/some-fun-with-groovy-and-aws-identity-and-access-management/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 17:40:33 +0000</pubDate>
		<dc:creator>erwan</dc:creator>
				<category><![CDATA[aws]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[groovy aws development]]></category>

		<guid isPermaLink="false">http://arzur.net/?p=136</guid>
		<description><![CDATA[I'm currently playing with the all new AWS identity and access management, and wanted to share some groovy magic to play with users and groups ...
]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Farzur.net%2F2010%2F10%2F04%2Fsome-fun-with-groovy-and-aws-identity-and-access-management%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Farzur.net%2F2010%2F10%2F04%2Fsome-fun-with-groovy-and-aws-identity-and-access-management%2F&amp;source=zuzur&amp;style=compact&amp;service=bit.ly&amp;service_api=R_0f41ee6dc559533f38d25e8df96d20fd&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I'm currently playing with the all new AWS identity and access management, and wanted to share some groovy magic to play with users and groups ...</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;">@Grapes<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span>
  @Grab<span style="color: #66cc66;">&#40;</span>group<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'com.amazonaws'</span>, module<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'aws-java-sdk'</span>, version<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'1.0.11'</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">com.amazonaws.auth.BasicAWSCredentials</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">com.amazonaws.services.identitymanagement.AmazonIdentityManagementClient</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">com.amazonaws.services.identitymanagement.model.*</span>
&nbsp;
AWS_ACCESS_KEY<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'MY AWESOME KEY'</span>
AWS_SECRET_KEY<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'MY EVEN MORE AWESOME KEY'</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">def</span> cred <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> BasicAWSCredentials<span style="color: #66cc66;">&#40;</span>AWS_ACCESS_KEY,AWS_SECRET_KEY<span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">def</span> ami <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AmazonIdentityManagementClient<span style="color: #66cc66;">&#40;</span>cred<span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Group 'Administrators' ?&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">def</span> admins <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">null</span>
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span>
 admins <span style="color: #66cc66;">=</span> ami.<span style="color: #006600;">getGroup</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> GetGroupRequest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">withGroupName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Administrators'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">?</span>.<span style="color: #006600;">group</span>
<span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span>NoSuchEntityException e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Didn't find group 'Administrators' : creating it ...&quot;</span>
  admins <span style="color: #66cc66;">=</span> ami.<span style="color: #006600;">createGroup</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> CreateGroupRequest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">withGroupName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Administrators'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">group</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #993399;">println</span> admins
&nbsp;
<span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;User 'erwan' ?&quot;</span>
<span style="color: #000000; font-weight: bold;">def</span> erwan <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">null</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span>
  erwan <span style="color: #66cc66;">=</span> ami.<span style="color: #006600;">getUser</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> GetUserRequest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">withUserName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'erwan'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">?</span>.<span style="color: #006600;">user</span>
<span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span>NoSuchEntityException e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Didn't find user 'erwan' : creating it ...&quot;</span>
  erwan <span style="color: #66cc66;">=</span> ami.<span style="color: #006600;">createUser</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> CreateUserRequest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">withUserName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'erwan'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">user</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #993399;">println</span> erwan
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>erwan<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Listing erwan's groups ...&quot;</span>
  java.<span style="color: #006600;">util</span>.<span style="color: #aaaadd; font-weight: bold;">List</span> groups <span style="color: #66cc66;">=</span> ami.<span style="color: #006600;">listGroupsForUser</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ListGroupsForUserRequest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">withUserName</span><span style="color: #66cc66;">&#40;</span>erwan.<span style="color: #006600;">userName</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getGroups</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #663399;">collect</span> <span style="color: #66cc66;">&#123;</span>
    it.<span style="color: #006600;">groupName</span>
  <span style="color: #66cc66;">&#125;</span>
  <span style="color: #993399;">println</span> groups
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>groups.<span style="color: #CC0099;">contains</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Administrators'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Adding user 'erwan' to 'Administrators'&quot;</span>
    ami.<span style="color: #006600;">addUserToGroup</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> AddUserToGroupRequest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">withUserName</span><span style="color: #66cc66;">&#40;</span>erwan.<span style="color: #006600;">userName</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">withGroupName</span><span style="color: #66cc66;">&#40;</span>admins.<span style="color: #006600;">groupName</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#125;</span>
  <span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;done !&quot;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Even with some groove in it, java is still way too verbose to my taste, but i guess, i'll have to live with it ...<br />
And this is the output of the awesome script:</p>
<pre>
Group 'Administrators' ?
4 oct. 2010 19:05:50 com.amazonaws.http.HttpClient execute
INFO: Sending Request: POST https://iam.amazonaws.com / Parameters: (Action: GetGroup, GroupName: Administrators, SignatureMethod: HmacSHA256, AWSAccessKeyId: MY AWESOME KEY, Version: 2010-05-08, SignatureVersion: 2, Timestamp: 2010-10-04T17:05:50.839Z, Signature: 3V3lEJzcqXXXXXXXXXXXXBeyMx9DzwFXA=, )
4 oct. 2010 19:05:51 com.amazonaws.http.HttpClient handleResponse
INFO: Received successful response: 200, AWS Request ID: a40b6fd5-cfd9-11df-8b03-8bc9f2ff0492
{Path: /, GroupName: Administrators, GroupId: AGPAJZSRVEMSLHZEOKMI6, Arn: arn:aws:iam::XXXXXXXXXXXXX:group/Administrators, }
User 'erwan' ?
4 oct. 2010 19:05:51 com.amazonaws.http.HttpClient execute
INFO: Sending Request: POST https://iam.amazonaws.com / Parameters: (Action: GetUser, SignatureMethod: HmacSHA256, UserName: erwan, AWSAccessKeyId: MY AWESOME KEY, Version: 2010-05-08, SignatureVersion: 2, Timestamp: 2010-10-04T17:05:51.222Z, Signature: XXXXXXXXXXXXXXXXXXXXXXXXXXXX, )
4 oct. 2010 19:05:51 com.amazonaws.http.HttpClient handleResponse
INFO: Received successful response: 200, AWS Request ID: a422f04a-cfd9-11df-b738-6709d34e9585
{Path: /, UserName: erwan, UserId: XXXXXXXXXXXXXXXXXXXXXXX, Arn: arn:aws:iam::XXXXXXXXXXXXXX:user/erwan, }
Listing erwan's groups ...
4 oct. 2010 19:05:51 com.amazonaws.http.HttpClient execute
INFO: Sending Request: POST https://iam.amazonaws.com / Parameters: (Action: ListGroupsForUser, SignatureMethod: HmacSHA256, UserName: erwan, AWSAccessKeyId: MY AWESOME KEY, Version: 2010-05-08, SignatureVersion: 2, Timestamp: 2010-10-04T17:05:51.388Z, Signature: XXXXXXXXXXXXXXXXXXXXXXXXXXXXX, )
4 oct. 2010 19:05:51 com.amazonaws.http.HttpClient handleResponse
INFO: Received successful response: 200, AWS Request ID: a43bf67d-cfd9-11df-a1ef-f7061c8dca90
[]
Adding user 'erwan' to 'Administrators'
4 oct. 2010 19:05:51 com.amazonaws.http.HttpClient execute
INFO: Sending Request: POST https://iam.amazonaws.com / Parameters: (Action: AddUserToGroup, GroupName: Administrators, SignatureMethod: HmacSHA256, UserName: erwan, AWSAccessKeyId: MY AWESOME KEY, Version: 2010-05-08, SignatureVersion: 2, Timestamp: 2010-10-04T17:05:51.569Z, Signature: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX )
4 oct. 2010 19:05:51 com.amazonaws.http.HttpClient handleResponse
INFO: Received successful response: 200, AWS Request ID: a457e216-cfd9-11df-a356-3d1e141e353d
done !
</pre>
<p>AWESOME !! \o/</p>
<p>Next, I'll make something useful out of it, like unix's adduser/addgroup script that will create individual developers and admins access keys, play with policies in order to restrict usage based on group appartenance, try to reduce groovy's startup time by preloading the interpreter, etc ...</p>
]]></content:encoded>
			<wfw:commentRss>http://arzur.net/2010/10/04/some-fun-with-groovy-and-aws-identity-and-access-management/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

