<?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>Werk &#187; script</title>
	<atom:link href="http://werk.feub.net/tag/script/feed/" rel="self" type="application/rss+xml" />
	<link>http://werk.feub.net</link>
	<description>Pourquoi Werk? ^.^</description>
	<lastBuildDate>Tue, 06 Dec 2011 14:18:13 +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>Utiliser rTorrent</title>
		<link>http://werk.feub.net/2011/01/utiliser-rtorrent/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=utiliser-rtorrent</link>
		<comments>http://werk.feub.net/2011/01/utiliser-rtorrent/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 10:46:58 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[archlinux]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[rtorrent]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[torrent]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=43</guid>
		<description><![CDATA[Utilisation de rTorrent pour télécharger et partager vos fichiers]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://werk.feub.net/medias/2011/01/rtorrent_logo64.png" alt="" title="" class="floatleft" /><a title="rakshasa.no" target="_blank" href="http://libtorrent.rakshasa.no/">rTorrent</a> est un client bittorrent non graphique que j&#8217;utilise depuis plusieurs années pour sa simplicité, sa faible empreinte niveau ressources et ses possibilités de configuration poussées. Au début il peut dérouter, mais après un temps d&#8217;adaptation, on découvre toute sa souplesse et sa puissance. Il suffit simplement d&#8217;un accès <a title="Wikipedia : SSH" target="_blank" href="http://fr.wikipedia.org/wiki/SSH">SSH</a> pour pouvoir gérer ses téléchargements depuis n&#8217;importe où, très utile. Une particularité très intéressante de rTorrent est qu&#8217;il scrute le contenu d&#8217;un répertoire donné qui recevra les fichiers <em>.torrent</em>, ainsi dès qu&#8217;un nouveau torrent est ajouté dans celui-ci, le téléchargement débute automatiquement.
</p>
<p><span id="more-43"></span></p>
<h4>Installation et configuration</h4>
<p>
J&#8217;avais originellement écrit cet article pour Archlinux, donc pour cette distro, rTorrent est dans les dépôts, pacman l&#8217;installe donc sans soucis, ainsi que <a title="Wikipedia : screen" target="_blank" href="http://fr.wikipedia.org/wiki/Screen">screen</a> le multiplexeur de terminaux :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># pacman -S rtorrent screen</span></pre></div></div>

<p>
Pour du Fedora :
</p>
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum install rtorrent screen</span></pre></div></div>

<p>
Ensuite, il va falloir structurer les quelques répertoires nécessaires à son bon fonctionnement. J&#8217;ai ainsi crée quatre répertoires dans mon <em>home</em> sous <em>~/bt</em> : data, completed, watch et sessions, qui respectivement serviront à stocker les fichiers en cours de téléchargement, stocker les fichiers completement téléchargés, fournir un répertoire pour les fichiers <em>.torrent</em> que rtorrent scrutera régulièrement et un répertoire pour les sessions en cours :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># mkdir -p ~/bt/{data,sessions,watch,completed}</span></pre></div></div>

<p>
Il faut maintenant créer le fichier de configuration <em>~/.rtorrent.rc</em>, voici le mien :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Limite en upload et download</span>
upload_rate = <span style="color: #000000;">30</span>
download_rate = <span style="color: #000000;">6000</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Répertoire de destination des fichiers téléchargés et des sessions</span>
directory = <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>fabien<span style="color: #000000; font-weight: bold;">/</span>bt<span style="color: #000000; font-weight: bold;">/</span>data<span style="color: #000000; font-weight: bold;">/</span>
session = <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>fabien<span style="color: #000000; font-weight: bold;">/</span>bt<span style="color: #000000; font-weight: bold;">/</span>sessions
&nbsp;
<span style="color: #666666; font-style: italic;"># Ports utilisés et diverses options</span>
port_range = <span style="color: #000000;">6881</span>-<span style="color: #000000;">6999</span>
port_random = no
check_hash = <span style="color: #c20cb9; font-weight: bold;">yes</span>
max_memory_usage = <span style="color: #000000;">268435456</span>
encryption = allow_incoming,enable_retry,prefer_plaintext
&nbsp;
<span style="color: #666666; font-style: italic;"># Répertoire de dépôt des fichiers .torrent</span>
schedule = watch_directory,<span style="color: #000000;">15</span>,<span style="color: #000000;">15</span>,<span style="color: #007800;">load_start</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>fabien<span style="color: #000000; font-weight: bold;">/</span>bt<span style="color: #000000; font-weight: bold;">/</span>watch<span style="color: #000000; font-weight: bold;">/*</span>.torrent
schedule = tied_directory,<span style="color: #000000;">15</span>,<span style="color: #000000;">15</span>,<span style="color: #007800;">start_tied</span>=
schedule = untied_directory,<span style="color: #000000;">15</span>,<span style="color: #000000;">15</span>,<span style="color: #007800;">stop_untied</span>=
&nbsp;
<span style="color: #666666; font-style: italic;"># Répertoire où déplacer les fichiers lorsqu'ils sont complets</span>
system.method.set_key = event.download.finished,move_complete,<span style="color: #ff0000;">&quot;execute=mv, <span style="color: #000099; font-weight: bold;">\
</span>-u,<span style="color: #007800;">$d</span>.get_base_path=,/home/fabien/bt/completed ; <span style="color: #000099; font-weight: bold;">\
</span>d.set_directory=/home/fabien/bt/completed&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># On envoie un email pour prévenir qu'un fichier est téléchargé</span>
system.method.set_key = event.download.finished,notify_me, \
<span style="color: #ff0000;">&quot;execute=/home/fabien/bin/rtorrent_mail.sh,<span style="color: #007800;">$d</span>.get_name=&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Ferme le torrent lorsque l'espace disque est minimal</span>
schedule = low_diskspace,<span style="color: #000000;">5</span>,<span style="color: #000000;">60</span>,<span style="color: #007800;">close_low_diskspace</span>=100M
&nbsp;
<span style="color: #666666; font-style: italic;"># Ratio de 1:1 pour les fichiers inferieurs à 500Mo, sinon ratio de 2:1</span>
ratio.min.set=<span style="color: #000000;">100</span>
ratio.upload.set=200M
ratio.max.set=<span style="color: #000000;">200</span></pre></div></div>

<p>
Je passe sur son explication, c&#8217;est assez explicite. Pour plus d&#8217;informations, se reporter à la documentation du <a title="rakshasa.no" target="_blank" href="http://libtorrent.rakshasa.no/">site de rTorrent</a>.
</p>
<p>
Pour aider au lancement du programme, voici un script bash lançant rTorrent dans un screen :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #660033;">-dmS</span> rtorrent <span style="color: #c20cb9; font-weight: bold;">nice</span> <span style="color: #660033;">-n</span> <span style="color: #000000;">15</span> rtorrent</pre></div></div>

<p>
Ce deuxième script permet de visualiser le déroulement de rTorrent (en ré-attachant le screen) :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #c20cb9; font-weight: bold;">stty</span> stop undef
<span style="color: #c20cb9; font-weight: bold;">stty</span> start undef
<span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #660033;">-rd</span> bt</pre></div></div>

<p>
En ce qui me concerne, mes scripts sont sous <em>~/bin</em>, ne pas oublier de leur attribuer les droits en exécution :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> +x ~<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>btlaunch ~<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>btview</pre></div></div>

<p>
Et voici un script <a title="archlinux.fr" target="_blank" href="http://wiki.archlinux.fr/howto/comprendre/demarrage#rcconf_et_rcd">rc</a> qui permet de gérer rTorrent à la sauce Archlinux et de le démarrer en tant que <a title="Wikipedia : daemon" target="_blank" href="http://fr.wikipedia.org/wiki/Daemon">daemon</a> avec la machine, <em>rtorrent</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
. <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.conf
. <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.d<span style="color: #000000; font-weight: bold;">/</span>functions
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
start<span style="color: #7a0874; font-weight: bold;">&#41;</span>
stat_busy <span style="color: #ff0000;">&quot;Starting rtorrent&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">su</span> fabien <span style="color: #660033;">-c</span> <span style="color: #ff0000;">'screen -d -m -S bt rtorrent'</span> <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
stat_fail
<span style="color: #000000; font-weight: bold;">else</span>
add_daemon rtorrent
stat_done
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">;;</span>
stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
stat_busy <span style="color: #ff0000;">&quot;Stopping rtorrent&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">killall</span> <span style="color: #660033;">-w</span> <span style="color: #660033;">-s</span> <span style="color: #000000;">2</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>rtorrent <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
stat_fail
<span style="color: #000000; font-weight: bold;">else</span>
rm_daemon rtorrent
stat_done
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">;;</span>
restart<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">$0</span> stop
<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">1</span>
<span style="color: #007800;">$0</span> start
<span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;usage: $0 {start|stop|restart}&quot;</span>
<span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>

<p>
Et enfin le petit bash d&#8217;envoi de l&#8217;email en fin de téléchargement, <em>rtorrent_mail.sh</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(date)</span> : $1 - Download completed.&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;[rtorrent] - Download completed : $1&quot;</span> mon<span style="color: #000000; font-weight: bold;">@</span>adresse.net</pre></div></div>

<h4>Lancement et utilisation</h4>
<p>
Voilà, c’est terminé, il ne reste plus qu’à lancer le daemon et accessoirement de visualiser l’état avec les scripts :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ ~<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>btlaunch.sh
$ ~<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>btview.sh</pre></div></div>

<p>
Lancement/arrêt/re-démarrage avec la commande rc :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># /etc/rc.d/rtorrent start</span>
<span style="color: #666666; font-style: italic;"># /etc/rc.d/rtorrent stop</span>
<span style="color: #666666; font-style: italic;"># /etc/rc.d/rtorrent restart</span></pre></div></div>

<p>
Mais pour voir l’évolution, il faut bien entendu ajouter des torrents, pour se faire, copier simplement les fichiers <em>.torrent</em> dans le répertoire <em>watch</em>. Et vous verrez les téléchargements débuter. Ensuite l&#8217;utilisation se fait par quelques commandes, en voici quelques unes :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">CTRL+d         Stoppe un torrent <span style="color: #7a0874; font-weight: bold;">&#40;</span>ou supprime un torrent arrêté<span style="color: #7a0874; font-weight: bold;">&#41;</span>
CTRL+q         Quitte rTorrent <span style="color: #7a0874; font-weight: bold;">&#40;</span>ferme le <span style="color: #c20cb9; font-weight: bold;">screen</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
CTRL+s         Démarre un torrent arrêté
CTRL+a puis d     Détache le <span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>rTorrent tourne toujours<span style="color: #7a0874; font-weight: bold;">&#41;</span>
a ou s ou d ou     Augmente l’upload de 1Kb<span style="color: #000000; font-weight: bold;">/</span>s ou 5Kb<span style="color: #000000; font-weight: bold;">/</span>s ou 50Kb<span style="color: #000000; font-weight: bold;">/</span>s
z ou x ou c     Réduit l’upload de 1Kb<span style="color: #000000; font-weight: bold;">/</span>s ou 5Kb<span style="color: #000000; font-weight: bold;">/</span>s ou 50Kb<span style="color: #000000; font-weight: bold;">/</span>s
A ou S ou D ou     Augmente le download de 1Kb<span style="color: #000000; font-weight: bold;">/</span>s ou 5Kb<span style="color: #000000; font-weight: bold;">/</span>s ou 50Kb<span style="color: #000000; font-weight: bold;">/</span>s
Z ou X ou C     Réduit le download de 1Kb<span style="color: #000000; font-weight: bold;">/</span>s ou 5Kb<span style="color: #000000; font-weight: bold;">/</span>s ou 50Kb<span style="color: #000000; font-weight: bold;">/</span>s</pre></div></div>

<p>​</p>
<p>
<em>Cet article fut publié pour la première fois le 18 février 2008.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2011/01/utiliser-rtorrent/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>script : vérifier que rTorrent est lancé</title>
		<link>http://werk.feub.net/2008/12/script-verifier-que-rtorrent-est-lance/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=script-verifier-que-rtorrent-est-lance</link>
		<comments>http://werk.feub.net/2008/12/script-verifier-que-rtorrent-est-lance/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 14:11:51 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[torrent]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=7</guid>
		<description><![CDATA[Bash check_rtorrent.sh]]></description>
			<content:encoded><![CDATA[<p>
Pour la gestion de mes torrents, j&#8217;utilise <a href="http://libtorrent.rakshasa.no/" title="rTorrent">rTorrent</a>, j&#8217;ai eu l&#8217;occasion d&#8217;en parler dans <a href="http://feub.net/werk/index.php/tic/commentaires/utiliser_rtorrent/" title="feub.net">ce billet</a> et <a href="http://feub.net/werk/index.php/tic/commentaires/rtorrent_deplacer_les_fichiers_telecharges/" title="feub.net">celui-ci</a>. Il s&#8217;agit d&#8217;un <a href="http://fr.wikipedia.org/wiki/Daemon" title="Wikipedia">daemon</a> très stable, mais pour des raisons X ou Y (genre redémarrage de la machine), j&#8217;oublie de le lancer. Pour palier à cela, j&#8217;ai écrit ce petit script qui vérifie que le programme est bien démarré, sinon il va tenter de le faire. Si tel est le cas, un email est envoyé pour signaler que rTorrent a été redémarré. Le tout est loggé.
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Fichier de log</span>
<span style="color: #007800;">LOGPATH</span>=<span style="color: #ff0000;">&quot;/home/fabien/bin/log/check_rtorrent.log&quot;</span>
<span style="color: #666666; font-style: italic;"># Email</span>
<span style="color: #007800;">EMAIL</span>=<span style="color: #ff0000;">&quot;fabien@feub.net&quot;</span>
<span style="color: #007800;">SUBJECT</span>=<span style="color: #ff0000;">&quot;[check] rTorrent&quot;</span>
<span style="color: #666666; font-style: italic;"># Si pas de fichier de log, on le crée</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$LOGPATH</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #007800;">$LOGPATH</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #ff0000;">&quot; : Vérification que rTorrent est lancé...&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOGPATH</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">pidof</span> rtorrent
<span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;en fonctionnement : OK&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOGPATH</span>
<span style="color: #000000; font-weight: bold;">else</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;non démarré...&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOGPATH</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;démarrage...&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOGPATH</span>
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>fabien<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>btlaunch.sh
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;en fonctionnement : OK&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOGPATH</span>
mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$SUBJECT</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$EMAIL</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #007800;">$LOGPATH</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<p>
<img src="http://feub.net/werk/images/uploads/icons/icon16-script.png" class="ico16" height="16" width="16"> <a href="http://feub.net/werk/images/uploads/200812/check_rtorrent.sh" title="Télécharger check_rtorrent.sh">Télécharger check_rtorrent.sh</a>
</p>
<p>
Pour automatiser cela, je l&#8217;ajoute dans mon crontab pour qu&#8217;il vérifie toutes les 5 minutes :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ crontab <span style="color: #660033;">-e</span>
<span style="color: #000000; font-weight: bold;">*/</span><span style="color: #000000;">5</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>fabien<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>check_rtorrent.sh</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2008/12/script-verifier-que-rtorrent-est-lance/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Montages automatiques : version AppleScript</title>
		<link>http://werk.feub.net/2008/09/montages-automatiques-version-applescript/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=montages-automatiques-version-applescript</link>
		<comments>http://werk.feub.net/2008/09/montages-automatiques-version-applescript/#comments</comments>
		<pubDate>Wed, 17 Sep 2008 14:13:28 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[nfs]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=19</guid>
		<description><![CDATA[Monter ses volumes distants au démarrage de la session]]></description>
			<content:encoded><![CDATA[<p>
Dans un <a href="http://feub.net/werk/index.php/feubv9/comments/montages_nfs_automatiques/" title="feub.net">article précédent</a>, il était question de monter des partages <a href="http://fr.wikipedia.org/wiki/Network_File_System" title="Wikipedia">NFS</a> automatiquement à l&#8217;aide de l&#8217;Utilitaire d&#8217;annuaire. Voici une méthode utilisant un script <a href="http://fr.wikipedia.org/wiki/AppleScript" title="Wikipedia">AppleScript</a> qui a le double avantage de monter les volumes sur le bureau (cela peut-être un désavantage suivant l&#8217;utilisation) et elle permet de monter d&#8217;autres types de partage, <a href="http://fr.wikipedia.org/wiki/Protocole_SMB" title="Wikipedia">Samba</a> par exemple.
</p>
<h4>Le script</h4>
<p>
Voici le script que j&#8217;utilise. J&#8217;ai toujours mes trois montages NFS et un SMB (pour un petit <a href="http://fr.wikipedia.org/wiki/Network_attached_storage" title="Wikipedia">NAS</a>) :
</p>

<div class="wp_syntax"><div class="code"><pre class="applescript" style="font-family:monospace;"><span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #0066ff;">run</span>
<span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Finder&quot;</span>
<span style="color: #ff0033; font-weight: bold;">try</span>
mount volume <span style="color: #009900;">&quot;nfs://edoras/home/fabien&quot;</span>
<span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #ff0033; font-weight: bold;">error</span>
<span style="color: #0066ff;">display dialog</span> <span style="color: #009900;">&quot;Erreur de montage NFS de /home/fabien&quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #000000;">&amp;</span> ¬
<span style="color: #009900;">&quot;Vérifier que le serveur est disponible.&quot;</span> <span style="color: #0066ff;">buttons</span>  default button <span style="color: #000000;">1</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span>
<span style="color: #ff0033; font-weight: bold;">try</span>
mount volume <span style="color: #009900;">&quot;nfs://edoras/data1&quot;</span>
<span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #ff0033; font-weight: bold;">error</span>
<span style="color: #0066ff;">display dialog</span> <span style="color: #009900;">&quot;Erreur de montage NFS de /data1&quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #000000;">&amp;</span> ¬
<span style="color: #009900;">&quot;Vérifier que le serveur est disponible.&quot;</span> <span style="color: #0066ff;">buttons</span>  default button <span style="color: #000000;">1</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span>
<span style="color: #ff0033; font-weight: bold;">try</span>
mount volume <span style="color: #009900;">&quot;nfs://edoras/backup&quot;</span>
<span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #ff0033; font-weight: bold;">error</span>
<span style="color: #0066ff;">display dialog</span> <span style="color: #009900;">&quot;Erreur de montage NFS de /backup&quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #000000;">&amp;</span> ¬
<span style="color: #009900;">&quot;Vérifier que le serveur est disponible.&quot;</span> <span style="color: #0066ff;">buttons</span>  default button <span style="color: #000000;">1</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span>
<span style="color: #ff0033; font-weight: bold;">try</span>
mount volume <span style="color: #009900;">&quot;smb://rohan&quot;</span>
<span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #ff0033; font-weight: bold;">error</span>
<span style="color: #0066ff;">display dialog</span> <span style="color: #009900;">&quot;Erreur de montage SMB de /rohan&quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #000000;">&amp;</span> ¬
<span style="color: #009900;">&quot;Vérifier que le NAS est disponible.&quot;</span> <span style="color: #0066ff;">buttons</span>  default button <span style="color: #000000;">1</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #0066ff;">run</span></pre></div></div>

<p><span id="more-19"></span></p>
<h4>Mise en oeuvre</h4>
<p>
Je dois avouer que c&#8217;est mon premier AppleScript, je suis loin de m&#8217;y connaître en la matière ;}<br />
Pour créer un script il faut naturellement utiliser l&#8217;<em>Editeur de scripts</em> d&#8217;<a href="http://www.apple.com/fr/" title="Apple">Apple</a> situé dans <em>Applications</em> puis <em>AppleScript</em>.
</p>
<p>
Le fonctionnement d&#8217;AppleScript est un peu déroutant au départ. Lors de la saisie du texte, celui-ci se colorise en pourpre (couleurs par défaut) et il est homogène, pas de réelle colorisation syntaxique donc. Ensuite, il faut <em>compiler</em> ce script &#8211; à l&#8217;aide du bouton du même nom), ce qui a pour effet de vérifier les éventuelles erreurs et de retourner un texte colorisé avec mis en forme pour une meilleure lisibilité. Ensuite, lors de l&#8217;édition du script, les nouvelles parties restent en pourpre sans mise en forme jusqu&#8217;à la prochaine compilation, ceci permettant de rapidement voir ce qui vient d&#8217;être nouvellement édité/ajouté.
</p>
<div class="image">
<img src="http://feub.net/werk/images/uploads/200809/AS-raw.png" width="451" height="374" class="photoTips" title="AppleScript brut :: Mac OS X" /><br />
Script brut
</div>
<div class="image">
<img src="http://feub.net/werk/images/uploads/200809/AS-compiled.png" width="451" height="374" class="photoTips" title="AppleScript compilé :: Mac OS X" /><br />
Script compilé
</div>
<div class="image">
<img src="http://feub.net/werk/images/uploads/200809/AS-compiled-edited.png" width="451" height="374" class="photoTips" title="AppleScript édité :: Mac OS X" /><br />
Script édité
</div>
<p>
Ensuite, vient l&#8217;enregistrement. Un AppleScript tel quel (extension .scpt) doit être invoqué au sein d&#8217;un programme, s&#8217;il est lancé par exemple depuis le <em>Finder</em>, il est simplement ouvert par l&#8217;<em>Editeur de script</em> :
</p>
<div class="image">
<img src="http://feub.net/werk/images/uploads/200809/AS-save-as-script.png" width="434" height="279" class="photoTips" title="Enregistrer comme script :: Mac OS X" /><br />
Enregistrement comme script
</div>
<p>
Attention à la case à cocher <em>Exécutable uniquement</em>, cela aura pour effet de compiler le script en un fichier exécutable seulement, il ne sera plus possible de l&#8217;éditer. Il faut être sur de son coup ou en garder une copie éditable.<br />
Pour le script de montage de volumes réseau, il faut qu&#8217;il soit autonome, que le script soit exécuté (et non édité) lorsqu&#8217;il est lancé. Il faut donc l&#8217;enregistrer comme application (extension .app) :
</p>
<div class="image">
<img src="http://feub.net/werk/images/uploads/200809/AS-save-as-app.png" width="434" height="279" class="photoTips" title="Enregistrer comme application :: Mac OS X" /><br />
Enregistrer comme application
</div>
<p>
Une fois le fichier application enregistré, le mettre dans un coin &#8211; personnellement mes scripts sont sous <em>bin/</em> dans mon home &#8211; et aller dans les <em>Préférences > Comptes</em>, cliquer sur le compte, puis onglet <em>Ouverture</em> et ajouter le script à l&#8217;ouverture de session.
</p>
<div class="image deport">
<img src="http://feub.net/werk/images/uploads/200809/AS-comptes.png" width="640" height="511" class="photoTips" title="Lancer le script à l'ouverture de session :: Mac OS X" /><br />
Lancer le script à l&#8217;ouverture de session
</div>
]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2008/09/montages-automatiques-version-applescript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>clavicogyre ver 1.5</title>
		<link>http://werk.feub.net/2008/08/clavicogyre-ver-1-5/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=clavicogyre-ver-1-5</link>
		<comments>http://werk.feub.net/2008/08/clavicogyre-ver-1-5/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 06:09:33 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[sauvegar]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=30</guid>
		<description><![CDATA[Amélioration de mon petit bash de sauvegarde]]></description>
			<content:encoded><![CDATA[<p>
Je publie le petit script de backup maison que j&#8217;utilise depuis plusieurs années. Simple, à base de <a href="http://fr.wikipedia.org/wiki/Rsync" title="Wikipedia">rsync</a> au travers d&#8217;<a href="http://fr.wikipedia.org/wiki/SSH" title="SSHWikipedia">SSH</a>, il propose un petit menu pour ne sauvegarder que certaines partie de votre home (Images, Documents, Musique, etc), et possède l&#8217;option &#8211;delete de rsync facultative :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#======================================================================</span>
<span style="color: #666666; font-style: italic;"># CLAVICOGYRE - Script de backup</span>
<span style="color: #666666; font-style: italic;">#======================================================================</span>
<span style="color: #666666; font-style: italic;"># by fabien a. [fabien@feub.net]</span>
<span style="color: #666666; font-style: italic;"># http://feub.net/</span>
<span style="color: #666666; font-style: italic;">#======================================================================</span>
<span style="color: #666666; font-style: italic;"># This program is free software; you can redistribute it and/or</span>
<span style="color: #666666; font-style: italic;"># modify it under the terms of the GNU General Public License</span>
<span style="color: #666666; font-style: italic;"># as published by the Free Software Foundation; either version 2</span>
<span style="color: #666666; font-style: italic;"># of the License, or (at your option) any later version.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># This program is distributed in the hope that it will be useful,</span>
<span style="color: #666666; font-style: italic;"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span style="color: #666666; font-style: italic;"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span style="color: #666666; font-style: italic;"># GNU General Public License for more details.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># You should have received a copy of the GNU General Public License</span>
<span style="color: #666666; font-style: italic;"># along with this program; if not, </span>
<span style="color: #666666; font-style: italic;">#  - write to the Free Software</span>
<span style="color: #666666; font-style: italic;">#		Foundation, Inc.,</span>
<span style="color: #666666; font-style: italic;">#		51 Franklin Street,</span>
<span style="color: #666666; font-style: italic;">#		Fifth Floor,</span>
<span style="color: #666666; font-style: italic;">#		Boston, MA  02110-1301</span>
<span style="color: #666666; font-style: italic;">#		USA.</span>
<span style="color: #666666; font-style: italic;">#		- See http://www.gnu.org/licenses/gpl.html</span>
<span style="color: #666666; font-style: italic;">#======================================================================</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Numero de version</span>
<span style="color: #007800;">VERSION</span>=<span style="color: #ff0000;">&quot;ver 1.5.02 (01/08/2008)&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Chemin vers le serveur</span>
<span style="color: #007800;">SSHPATH</span>=<span style="color: #ff0000;">&quot;utilisateur@serveur:&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Chemins</span>
<span style="color: #007800;">PHOTOS_SOURCE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOME</span>/lightroom/&quot;</span>
<span style="color: #007800;">PHOTOS_CIBLE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$SSHPATH</span>/home/fabien/Images/Photos&quot;</span>
<span style="color: #007800;">PICTURES_SOURCE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOME</span>/Pictures/&quot;</span>
<span style="color: #007800;">PICTURES_CIBLE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$SSHPATH</span>/home/fabien/Images&quot;</span>
<span style="color: #007800;">DOCS_SOURCE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOME</span>/Documents/&quot;</span>
<span style="color: #007800;">DOCS_CIBLE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$SSHPATH</span>/home/fabien/Documents&quot;</span>
<span style="color: #007800;">MUSIC_SOURCE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOME</span>/Music/iTunes/iTunes Music/&quot;</span>
<span style="color: #007800;">MUSIC_CIBLE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$SSHPATH</span>/backup/Musique&quot;</span>
<span style="color: #007800;">WWW_SOURCE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOME</span>/www/&quot;</span>
<span style="color: #007800;">WWW_CIBLE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$SSHPATH</span>/home/fabien/www&quot;</span>
<span style="color: #007800;">DEV_SOURCE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOME</span>/Dev/&quot;</span>
<span style="color: #007800;">DEV_CIBLE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$SSHPATH</span>/home/fabien/Dev&quot;</span>
<span style="color: #007800;">BIN_SOURCE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOME</span>/bin/&quot;</span>
<span style="color: #007800;">BIN_CIBLE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$SSHPATH</span>/home/fabien/Backup/bin&quot;</span>
<span style="color: #007800;">RESSOURCES_SOURCE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOME</span>/Resources/&quot;</span>
<span style="color: #007800;">RESSOURCES_CIBLE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$SSHPATH</span>/home/fabien/Resources&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Date d'execution du script</span>
<span style="color: #007800;">JOUR</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span>+<span style="color: #000000; font-weight: bold;">%</span>d<span style="color: #7a0874; font-weight: bold;">&#41;</span> 	<span style="color: #666666; font-style: italic;">## + %d permet d'extraire le jour</span>
<span style="color: #007800;">MOIS</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span>+<span style="color: #000000; font-weight: bold;">%</span>m<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #666666; font-style: italic;">## +%m permet d'extraire le mois</span>
<span style="color: #007800;">ANNEE</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span>+<span style="color: #000000; font-weight: bold;">%</span>Y<span style="color: #7a0874; font-weight: bold;">&#41;</span> 	<span style="color: #666666; font-style: italic;">## +%y permet d'extraire l'annee</span>
<span style="color: #007800;">HEURE</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span>+<span style="color: #000000; font-weight: bold;">%</span>H<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #666666; font-style: italic;">## +%H permet d'extraire l'heure</span>
<span style="color: #007800;">MINUTES</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span>+<span style="color: #000000; font-weight: bold;">%</span>M<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #666666; font-style: italic;">## +%M permet d'extraire les minutes</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Envoi du log par email</span>
<span style="color: #666666; font-style: italic;">#MAIL_DEST=&quot;adresse@email.net&quot;</span>
<span style="color: #666666; font-style: italic;">#MAIL_SUJET=&quot;[Backup] du $ANNEE-$MOIS-$JOUR a $HEUR:$MINUTES&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Rapport</span>
<span style="color: #007800;">RAPPORT</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOME</span>/Desktop/<span style="color: #007800;">$ANNEE</span><span style="color: #007800;">$MOIS</span><span style="color: #007800;">$JOUR</span>-clavicogyre-backup.log&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Les options sont :</span>
<span style="color: #666666; font-style: italic;"># v : verbose</span>
<span style="color: #666666; font-style: italic;"># r : rursif</span>
<span style="color: #666666; font-style: italic;"># u : update seulement</span>
<span style="color: #666666; font-style: italic;"># p : prerve les permissions</span>
<span style="color: #666666; font-style: italic;"># a : copie en tant qu'archive</span>
<span style="color: #666666; font-style: italic;"># t : prerve la date</span>
<span style="color: #666666; font-style: italic;"># --delete : supprime ce qui a ete supprime (copie stricte)</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Fonctions</span>
backup<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
&nbsp;
	<span style="color: #007800;">SOURCE</span>=<span style="color: #ff0000;">&quot;$1&quot;</span>
	<span style="color: #007800;">CIBLE</span>=<span style="color: #ff0000;">&quot;$2&quot;</span>
&nbsp;
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Backup <span style="color: #007800;">$SOURCE</span> ....&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$RAPPORT</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;----------------------------------&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$RAPPORT</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> Backup <span style="color: #c20cb9; font-weight: bold;">du</span> dossier <span style="color: #800000;">${1}</span> <span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #007800;">$JOUR</span><span style="color: #ff0000;">'/'</span><span style="color: #007800;">$MOIS</span> \
              a <span style="color: #007800;">$HEURE</span><span style="color: #ff0000;">'h'</span><span style="color: #007800;">$MINUTES</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$RAPPORT</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;----------------------------------&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$RAPPORT</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># Si option delete</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$3&quot;</span> = <span style="color: #ff0000;">&quot;DEL&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;L'option --delete est activee, etes-vous sur? (O/[n])&quot;</span>
		<span style="color: #c20cb9; font-weight: bold;">read</span> ACTDEL
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$ACTDEL</span>&quot;</span> = <span style="color: #ff0000;">&quot;O&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
		<span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #007800;">OPTDEL</span>=<span style="color: #ff0000;">&quot;--delete&quot;</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Option --delete ON&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$RAPPORT</span>
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #007800;">OPTDEL</span>=<span style="color: #ff0000;">&quot;&quot;</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Option --delete OFF&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$RAPPORT</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #007800;">OPTDEL</span>=<span style="color: #ff0000;">&quot;&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;option --delete OFF&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$RAPPORT</span>
	<span style="color: #000000; font-weight: bold;">fi</span>	
&nbsp;
	<span style="color: #666666; font-style: italic;"># rsync</span>
	rsync <span style="color: #660033;">-vrupatz</span> <span style="color: #660033;">--exclude-from</span>=<span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>rsync_exclude.txt \
               <span style="color: #007800;">$OPTDEL</span> <span style="color: #660033;">-e</span> <span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${SOURCE}</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${CIBLE}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tee</span> <span style="color: #660033;">-a</span> <span style="color: #007800;">$RAPPORT</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
&nbsp;
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$RAPPORT</span>
&nbsp;
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Fin du backup.&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Un fichier de log se trouve ici : &quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$RAPPORT</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;----------------------------------&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># On efface l'ecran</span>
<span style="color: #c20cb9; font-weight: bold;">clear</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;CLAVICOGYRE : SCRIPT DE BACKUP - <span style="color: #007800;">$VERSION</span>&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Demande du repertoire a sauvegarder</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;----------------------------------&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Repertoire a sauvegarder : &quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;=== 1) Photos (Lightroom)&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;=== 2) Pictures&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;=== 3) Documents&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;=== 4) Music&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;=== 5) www&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;=== 6) Dev&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;=== 7) bin&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;=== 8) Resources&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;----------------------------------------------&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;L'ajout de 'strict' ajoutera l'option --delete de rsync &quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;et effectuera ainsi une copie conforme.&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;ATTENTION : a utiliser avec parcimonie, les fichiers&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;supprimes seront supprimes sur la sauvergarde egalement.&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Exemple : 2 strict&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;fera une copie stricte du dossier Documents.&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;----------------------------------&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;---&gt; choix : &quot;</span>
<span style="color: #c20cb9; font-weight: bold;">read</span> REP
tput <span style="color: #c20cb9; font-weight: bold;">clear</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$REP</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>
	backup <span style="color: #007800;">$PHOTOS_SOURCE</span> <span style="color: #007800;">$PHOTOS_CIBLE</span><span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #ff0000;">&quot;1 strict&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>
	backup <span style="color: #007800;">$PHOTOS_SOURCE</span> <span style="color: #007800;">$PHOTOS_CIBLE</span> <span style="color: #ff0000;">&quot;DEL&quot;</span><span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>
	backup <span style="color: #007800;">$PICTURES_SOURCE</span> <span style="color: #007800;">$PICTURES_CIBLE</span><span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #ff0000;">&quot;2 strict&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>
	backup <span style="color: #007800;">$PICTURES_SOURCE</span> <span style="color: #007800;">$PICTURES_CIBLE</span> <span style="color: #ff0000;">&quot;DEL&quot;</span><span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>
	backup <span style="color: #007800;">$DOCS_SOURCE</span> <span style="color: #007800;">$DOCS_CIBLE</span><span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #ff0000;">&quot;3 strict&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>
	backup <span style="color: #007800;">$DOCS_SOURCE</span> <span style="color: #007800;">$DOCS_CIBLE</span> <span style="color: #ff0000;">&quot;DEL&quot;</span><span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>
	backup <span style="color: #007800;">$MUSIC_SOURCE</span> <span style="color: #007800;">$MUSIC_CIBLE</span><span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #ff0000;">&quot;4 strict&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>
	backup <span style="color: #007800;">$MUSIC_SOURCE</span> <span style="color: #007800;">$MUSIC_CIBLE</span> <span style="color: #ff0000;">&quot;DEL&quot;</span><span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>
	backup <span style="color: #007800;">$WWW_SOURCE</span> <span style="color: #007800;">$WWW_CIBLE</span><span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #ff0000;">&quot;5 strict&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>
	backup <span style="color: #007800;">$WWW_SOURCE</span> <span style="color: #007800;">$WWW_CIBLE</span> <span style="color: #ff0000;">&quot;DEL&quot;</span><span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #ff0000;">&quot;6&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>
	backup <span style="color: #007800;">$DEV_SOURCE</span> <span style="color: #007800;">$DEV_CIBLE</span><span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #ff0000;">&quot;6 strict&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>
	backup <span style="color: #007800;">$DEV_SOURCE</span> <span style="color: #007800;">$DEV_CIBLE</span> <span style="color: #ff0000;">&quot;DEL&quot;</span><span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #ff0000;">&quot;7&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>
	backup <span style="color: #007800;">$BIN_SOURCE</span> <span style="color: #007800;">$BIN_CIBLE</span><span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #ff0000;">&quot;7 strict&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>
	backup <span style="color: #007800;">$BIN_SOURCE</span> <span style="color: #007800;">$BIN_CIBLE</span> <span style="color: #ff0000;">&quot;DEL&quot;</span><span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #ff0000;">&quot;8&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>
	backup <span style="color: #007800;">$RESSOURCES_SOURCE</span> <span style="color: #007800;">$RESSOURCES_CIBLE</span><span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #ff0000;">&quot;8 strict&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>
	backup <span style="color: #007800;">$RESSOURCES_SOURCE</span> <span style="color: #007800;">$RESSOURCES_CIBLE</span> <span style="color: #ff0000;">&quot;DEL&quot;</span><span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Aucun choix valide. Termine.&quot;</span><span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Fin du script.&quot;</span></pre></div></div>

<p>
<a href="http://werk.feub.net/medias/2008/08/clavicogyre.sh" title="Télécharger clavicogyre.sh">Télécharger clavicogyre.sh</a>
</p>
<p>
Note : les anti-slash \ ne sont pas à taper, ils indiquent que j&#8217;ai coupé les lignes pour que ça ne dépasse pas du cadre. Il s&#8217;agit d&#8217;une seule et même ligne.
</p>
<p>
Note 2 : Oui <a href="http://www.sebweb.org/goldorak/armes.htm" title="clavicogyre">clavicogyre</a> est une arme de <a href="http://fr.wikipedia.org/wiki/Goldorak" title="Wikipedia">Goldorak</a> ;}</p>
]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2008/08/clavicogyre-ver-1-5/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Réveiller son Mac à distance</title>
		<link>http://werk.feub.net/2008/07/reveiller-son-mac-a-distance/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=reveiller-son-mac-a-distance</link>
		<comments>http://werk.feub.net/2008/07/reveiller-son-mac-a-distance/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 20:10:17 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[wakeonlan]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=36</guid>
		<description><![CDATA[Utiliser la capacité Wake-on-lan de votre interface réseau]]></description>
			<content:encoded><![CDATA[<p>
Mon Mac se met en veille prolongée après un certain temps non utilisé. Pour des raisons diverses, j&#8217;aimerais pouvoir le réveiller à distance, par exemple lorsque je suis sur mon lieu de travail ou chez un ami via <a href="http://fr.wikipedia.org/wiki/Ssh" title="Wikipedia">SSH</a> pour récupérer un fichier, mais celui-ci ne se réveille pas lorsqu&#8217;il est endormi profondément le petit chenapan. Problème.
</p>
<p>
Les plus curieux connaîtront la case à cocher <i>Réactiver lors d&#8217;un accès administrateur via le réseau Ethernet</i> dans la partie <i>Economiseur d&#8217;énergie</i> des <i>Préférences Systèmes</i> :
</p>
<div class="image deport">
<img src="http://werk.feub.net/medias/2008/07/energy.png" alt="energy" width="640" height="446" /><br />
Préférences Système
</div>
<p>
Mais ceci n&#8217;est pas suffisant, la carte réseau à beau veiller, il faut lui donner le mot de passe magique pour lui faire réveiller le Mac. Voici comment implémenter cette fonction.<br />
A noter que ceci ne fonctionne pas uniquement sur un Mac, toute machine pouvant interpréter <a href="http://fr.wikipedia.org/wiki/Perl_(langage)" title="Wikipedia">PERL</a> le pourra : Linux, Unix, même Windows en y installant un interpréteur PERL.
</p>
<h4>wakeonlan par José Pedro Oliveira</h4>
<p>
La solution nous vient de <a href="http://gsd.di.uminho.pt/jpo/software/wakeonlan/" title="José Pedro Oliveira">José Pedro Oliveira</a> qui fournit un script PERL qui permet d&#8217;exploiter les fonctions WOL (Wake-on-lan) des interfaces réseaux (note : toutes les cartes ethernet ne sont pas WOL). Ce script, sobrement appelé <a href="http://gsd.di.uminho.pt/jpo/software/wakeonlan/downloads/wakeonlan-0.41.tar.gz" title="wakeonlan"><code>wakeonlan</code></a> est disponible en suivant ce lien : <a href="http://gsd.di.uminho.pt/jpo/software/wakeonlan/" title="José Pedro Oliveira">http://gsd.di.uminho.pt/jpo/software/wakeonlan/</a>. Le récupérer et le désarchiver.<br />
Il peut être utilisé tel quel à l&#8217;endroit où il a été désarchivé, mais pour plus de cohérence, plaçons-le &#8211; comme j&#8217;ai l&#8217;habitude de le faire &#8211; sous <i>~/bin</i> ou pour les puristes sous <i>/usr/local/bin</i>.<br />
Il ne reste plus qu&#8217;à utiliser la commande pour réveiller une machine distante, en renseignant son adresse IP et son identifiant MAC, de cette façon :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$  wakeonlan <span style="color: #660033;">-i</span> 192.168.1.1 xx:xx:xx:xx:xx:xx</pre></div></div>

<p>
La chaine <i>xx:xx:xx:xx:xx:xx</i> représente l&#8217;adresse MAC de l&#8217;interface distante, elle peut être trouvée avec la commande <code>ifconfig</code>. Cette commande retourne beaucoup d&#8217;informations, mais il suffit de chercher cette chaine composée de 6 octets et séparée par deux points (:).
</p>
<p>
Voici un exemple chez moi avec :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ wakeonlan <span style="color: #660033;">-i</span> 192.168.1.3 00:<span style="color: #000000;">14</span>:ca:b2:<span style="color: #000000;">33</span>:e2</pre></div></div>

<p>
En image :
</p>
<div class="image">
<img src="http://werk.feub.net/medias/2008/07/terminal-wakeonlan.png" alt="wakeonlan" width="521" height="181" /><br />
wakeonlan PERL script
</div>
<p>
Voilà!<br />
A noter que l&#8217;option <code>-i 192.168.1.3</code> n&#8217;est pas nécessaire sur un réseau local.</p>
]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2008/07/reveiller-son-mac-a-distance/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using apc (Feed is rejected)
Page Caching using apc
Object Caching 383/453 objects using memcached

Served from: werk.feub.net @ 2012-02-05 21:52:07 -->
