<?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>The Exploits of Plouj &#187; HOWTO</title>
	<atom:link href="http://www.plouj.com/blog/category/howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.plouj.com/blog</link>
	<description>A blog by Michael Ploujnikov</description>
	<lastBuildDate>Wed, 01 Sep 2010 17:05:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Google Earth trip video capture in GNU/Linux with Yukon/Seom</title>
		<link>http://www.plouj.com/blog/2009/07/15/google-earth-trip-video-capture-in-gnulinux-with-yukonseom/</link>
		<comments>http://www.plouj.com/blog/2009/07/15/google-earth-trip-video-capture-in-gnulinux-with-yukonseom/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 17:21:55 +0000</pubDate>
		<dc:creator>plouj</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[capture]]></category>
		<category><![CDATA[compile]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[googleearth]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[seom]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[yukon]]></category>

		<guid isPermaLink="false">http://www.plouj.com/blog/?p=385</guid>
		<description><![CDATA[This is documentation of how I used Yukon and Seom to video capture a Google Earth trip for a recent video project in Fedora 10. I used the official installation guide as a starting point. Compile the Seom library I choose to install both Seom and Yukon in a custom prefix /home/plouj/yukon, rather than the [...]]]></description>
			<content:encoded><![CDATA[<p>This is documentation of how I used <a href="https://devel.neopsis.com/projects/yukon/">Yukon and Seom</a> to video capture a <a href="http://earth.google.com/">Google Earth</a> <a href="http://earth.google.com/tour.html#v=4">trip</a> for a recent video project in <a href="http://fedoraproject.org/">Fedora</a> 10. I used the <a href="https://devel.neopsis.com/projects/yukon/wiki/HowTo/Install">official installation guide</a> as a starting point.</p>
<h2>Compile the Seom library</h2>
<p>I choose to install both Seom and Yukon in a custom prefix <em>/home/plouj/yukon</em>, rather than the system wide <em>/usr</em> or <em>/usr/local</em>.</p>
<pre>
$ svn co https://devel.neopsis.com/svn/seom/branches/packetized-stream seom
$ cd seom
$ ./configure --prefix=/home/plouj/yukon --arch="x86" --cflags="-W -Wall" &#038;&#038; \
make CC="gcc -m32" &#038;&#038; make install LIBDIR="lib"
</pre>
<p>Note that &#8220;&#8211;arch=&#8221;x86&#8243; and &#8220;-m32&#8243; are only necessary for me because my operating system is 64bit and I need 32bit versions of seom and yukon (to work with 32bit Google Earth).</p>
<h2>Compile and install Yukon</h2>
<pre>
$ svn co https://devel.neopsis.com/svn/yukon/branches/rewrite yukon
$ cd yukon
$ ./configure --prefix=/home/plouj/yukon/ --libdir="lib" --arch="x86" &#038;&#038; \
make CC="gcc -L/home/plouj/yukon/lib -I/home/plouj/yukon/include -m32" &#038;&#038; \
make install
</pre>
<h2>Install Google Earth for Linux</h2>
<p>Obviously get it here: <a href="http://earth.google.com/">http://earth.google.com/</a></p>
<h2>Modify the Google Earth startup script</h2>
<p>Since I chose <em>/home/plouj/bin/</em> as the &#8220;Binary path&#8221; for Google Earth I was editing <em>/home/plouj/bin/googleearth</em>. All I had to do was to add yukon/seom library and executable paths at the end of the script:</p>
<pre>
...
cd "${GOOGLEEARTH_DATA_PATH}/"
LD_LIBRARY_PATH=/home/plouj/yukon/lib/:$LD_LIBRARY_PATH \
PATH=/home/plouj/yukon/bin:$PATH exec yukon "./googleearth-bin" "$@"
</pre>
<p>instead of the original:</p>
<pre>
cd "${GOOGLEEARTH_DATA_PATH}/"
exec "./googleearth-bin" "$@"
</pre>
<h2>Capture</h2>
<p>Finally, the <a href="https://devel.neopsis.com/projects/yukon/wiki/HowTo/Capture">capture</a> process is well documented on the Yukon website.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.plouj.com/blog/2009/07/15/google-earth-trip-video-capture-in-gnulinux-with-yukonseom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HOWTO increase Blender&#8217;s memory cache limit for command line renders</title>
		<link>http://www.plouj.com/blog/2009/06/08/howto-increase-blenders-memory-cache-for-command-line-renders/</link>
		<comments>http://www.plouj.com/blog/2009/06/08/howto-increase-blenders-memory-cache-for-command-line-renders/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 03:23:37 +0000</pubDate>
		<dc:creator>plouj</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[blender]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[command-line]]></category>
		<category><![CDATA[commit]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[patch]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[render]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://www.plouj.com/blog/?p=308</guid>
		<description><![CDATA[Blender sequencer gives the ability to optimize rendering of repeated frames by keeping the first result in memory cache and re-using it. Depending on the project, it might be necessary to increase this limit beyond the default 32MB. If the limit is surpassed while rendering a single frame, Blender clears the cache before proceeding to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.blender.org/">Blender</a> sequencer gives the ability to optimize rendering of repeated frames by keeping the first result in memory cache and re-using it. Depending on the project, it might be necessary to increase this limit beyond the default 32MB. If the limit is surpassed while rendering a single frame, Blender clears the cache before proceeding to the next frame and the re-renders everything from scratch.</p>
<p>Increasing the cache limit is easy to do in the UI:<br />
<img class="alignnone size-full wp-image-315" title="blender-cache-limit" src="http://www.plouj.com/blog/wp-content/uploads/2009/06/blender-cache-limit.png" alt="blender-cache-limit"/><br />
This setting is stored in the user&#8217;s preference file (<em>~/.B.blend</em> on Linux systems) and, therefore, applies to all projects. However, rendering from the command line requires using the <a href="http://wiki.blender.org/index.php/Doc:Manual/Render/Command_Line_Options">-b argument</a>, which explicitly ignores the user&#8217;s preference file. Apart from editing and re-compiling the Blender source code, I found only one way to increase the memory cache limit.</p>
<p>The trick is to use a Python script, like below, to change the user preferences before rendering the scene:</p>
<pre>import sys
import bpy

def main():
	bpy.config.sequenceMemCacheLimit=4096

if __name__ == '__main__':
	main()</pre>
<p>Add the script to the command line like this:</p>
<pre>./bin/blender -b sample-static-text.blend -P render_settings.py -a</pre>
<p>Note that the order of arguments matters because first we need to load the scene (with <em>-b</em>), then change settings through Pythons (using the <em>-P</em> option) and finally render the animation (with <em>-a</em>). Also, you need at least version <strong>2.49a</strong> of Blender for this to work.</p>
<p>For reference, here&#8217;s is the the source file which hardcodes the 32MB limit:</p>
<p><a href="http://projects.blender.org/plugins/scmsvn/viewcvs.php/branches/blender2.5/blender/intern/memutil/intern/MEM_CacheLimiterC-Api.cpp?annotate=17433&#038;root=bf-blender">intern/memutil/intern/MEM_CacheLimiterC-Api.cpp:</a></p>
<pre>...
static intptr_t &#038; get_max()
{
        static intptr_t m = 32*1024*1024;
        return m;
}
...</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.plouj.com/blog/2009/06/08/howto-increase-blenders-memory-cache-for-command-line-renders/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenDNS in Fedora with corporate DHCP and DNS with NetworkManager</title>
		<link>http://www.plouj.com/blog/2009/04/20/opendns-in-fedora-with-corporate-dhcp-and-dns/</link>
		<comments>http://www.plouj.com/blog/2009/04/20/opendns-in-fedora-with-corporate-dhcp-and-dns/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 22:24:00 +0000</pubDate>
		<dc:creator>plouj</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[DHCP]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[nameserver]]></category>
		<category><![CDATA[networkmanager]]></category>
		<category><![CDATA[opendns]]></category>

		<guid isPermaLink="false">http://www.plouj.com/blog/?p=279</guid>
		<description><![CDATA[Here is how to configure a Fedora workstation to use OpenDNS nameservers in a network with corporate DNS and DHCP servers without loosing access to their services. This was done on a Fedora 9 machine with dnsmasq being the local DNS server. It should also work on newer Fedora versions and even other GNU/Linux distributions. [...]]]></description>
			<content:encoded><![CDATA[<p>Here is how to configure a Fedora workstation to use <a href="http://www.opendns.com/">OpenDNS</a> nameservers in a network with corporate DNS and DHCP servers without loosing access to their services.<br />
This was done on a Fedora 9 machine with <a href="http://www.thekelleys.org.uk/dnsmasq/doc.html">dnsmasq</a> being the local DNS server. It should also work on newer Fedora versions and even other GNU/Linux distributions.</p>
<p>The setup is actually very simple and unobtrusive. It is only necessary to properly configure a local DNS server and then force 127.0.0.1 to be used as the only nameserver instead of the corporate DNS servers.</p>
<p>First you need to configure dnsmasq as follows:</p>
<h2>/etc/dnsmasq.conf</h2>
<pre>
# don't use the /etc/resolv.conf file anymore
no-resolv

# OpenDNS nameservers:
server=208.67.222.222
server=208.67.220.220

# Force corporate nameservers for corporate.domain.com lookups
# OpenDNS wouldn't be able to answer such queries correctly
# adjust to suit your network
server=/corporate.domain.com/10.1.1.1
server=/corporate.domain.com/10.1.1.2

# only respond to queries from the local machine
listen-address=127.0.0.1
bind-interfaces

conf-dir=/etc/dnsmasq.d
</pre>
<p>Then you need to go into NetworkManager and set 127.0.0.1 as the DNS server to be used:<br />
<img src="http://www.plouj.com/blog/wp-content/uploads/2009/04/nm-localhost-dns-server.png" alt="nm-localhost-dns-server" title="nm-localhost-dns-server" width="439" height="522" class="alignnone size-full wp-image-423" /></p>
<p>This will result in the following important settings added to your network scripts:</p>
<pre>
DNS1=127.0.0.1
PEERDNS=no
</pre>
<p>I&#8217;ve noticed two minor problems with this setup:</p>
<ol>
<li>the corporate DNS server names are hardcoded in the configuration. Usually they are determined automatically by the DHCP client.</li>
<li>restarting the dnsmasq service sometimes shows this error:
<pre>dnsdomainname: Host name lookup failure</pre>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.plouj.com/blog/2009/04/20/opendns-in-fedora-with-corporate-dhcp-and-dns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HOWTO build DXX-Rebirth for Windows with MSYS/MinGW</title>
		<link>http://www.plouj.com/blog/2009/03/07/howto-build-dxx-rebirth-for-windows-with-msysmingw/</link>
		<comments>http://www.plouj.com/blog/2009/03/07/howto-build-dxx-rebirth-for-windows-with-msysmingw/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 00:07:32 +0000</pubDate>
		<dc:creator>plouj</dc:creator>
				<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[compile]]></category>
		<category><![CDATA[descent]]></category>
		<category><![CDATA[dxx-rebirth]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[mingw]]></category>
		<category><![CDATA[msys]]></category>
		<category><![CDATA[physfs]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[scons]]></category>
		<category><![CDATA[sdl]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[toolchain]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.plouj.com/blog/?p=243</guid>
		<description><![CDATA[Introduction In this post I&#8217;ll document the steps I had to take to build DXX-Rebirth (a modernized Descent game engine) for Windows using MSYS and MinGW. MinGW, MSYS From  Pantokrator&#8217;s blog: install MinGW choose a lowercase install path: c:\mingw choose to download and install current version enable g++ (for physfs) install MSYS install msysDTK SDL [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>In this post I&#8217;ll document the steps I had to take to build <a href="http://www.dxx-rebirth.com/">DXX-Rebirth</a> (a modernized <a href="http://en.wikipedia.org/wiki/Descent_(computer_game)">Descent</a> game engine) for Windows using <a href="http://www.mingw.org/wiki/msys">MSYS</a> and <a href="http://www.mingw.org/">MinGW</a>.</p>
<h2>MinGW, MSYS</h2>
<p>From  <a href="http://blog.pantokrator.net/2006/08/08/setting-up-msysmingw-build-system-for-compiling-sdlopengl-applications/">Pantokrator&#8217;s blog</a>:</p>
<ul>
<li>install <a href="http://prdownloads.sf.net/mingw/MinGW-5.0.2.exe">MinGW</a>
<ul>
<li>choose a lowercase install path: c:\mingw</li>
<li>choose to download and install current version</li>
<li>enable g++ (for physfs)</li>
</ul>
</li>
<li>install <a href="http://prdownloads.sf.net/mingw/MSYS-1.0.10.exe">MSYS</a></li>
<li>install <a href="http://prdownloads.sf.net/mingw/msysDTK-1.0.1.exe">msysDTK</a></li>
</ul>
<h2>SDL and SDL_mixer</h2>
<p>Also from  <a href="http://blog.pantokrator.net/2006/08/08/setting-up-msysmingw-build-system-for-compiling-sdlopengl-applications/">Pantokrator&#8217;s blog</a>:</p>
<ul>
<li>download the <a href="http://www.libsdl.org/release/SDL-1.2.13.tar.gz">SDL</a> source</li>
<li>in the MSYS shell, compile it with</li>
</ul>
<pre>./configure --prefix=/mingw &amp;&amp; make &amp;&amp; make install</pre>
<ul>
<li>download the <a href="http://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-1.2.8.tar.gz">SDL_mixer</a> source and in a MSYS shell, build it with the same command:</li>
</ul>
<pre>./configure --prefix=/mingw &amp;&amp; make &amp;&amp; make install</pre>
<h2>PhysicsFS</h2>
<ul>
<li>Download the <a href="http://icculus.org/physfs/downloads/physfs-1.1.0.tar.gz">physfs 1.1.0</a> source.</li>
</ul>
<ul>
<li>Compile with the same command again:</li>
</ul>
<pre>./configure --prefix=/mingw &amp;&amp; make &amp;&amp; make install</pre>
<h2>SCons and Python</h2>
<p>From <a href="http://globulation2.org/wiki/Mingw_compilation">Globulation2 MinGW instructions</a>:</p>
<ul>
<li> install <a href="http://www.python.org/ftp/python/2.6/python-2.6.msi">Python 2.6</a></li>
<li> install <a href="http://prdownloads.sourceforge.net/scons/scons-1.1.0.win32.exe">SCons</a></li>
<li> add:</li>
</ul>
<pre>PATH=$PATH:/c/Python26:/c/Python26/Scripts</pre>
<ul>
<li> to the end of <em>/etc/profile</em> in MSYS so that SCons can run from the MSYS shell.</li>
</ul>
<h2>Subversion</h2>
<ul>
<li>install <a href="http://prdownloads.sourceforge.net/tortoisesvn/TortoiseSVN-1.5.9.15518-win32-svn-1.5.6.msi">TortoiseSVN</a></li>
</ul>
<h2>DXX-Rebirth</h2>
<ul>
<li>checkout DXX-Rebirth from <em>https://dxx-rebirth.svn.sourceforge.net/svnroot/dxx-rebirth</em></li>
<li>change the SConstruct script to call sdl-config as &#8216;sh sdl-config &#8216;:</li>
</ul>
<pre>...
Flags and stuff for all platforms...
env.ParseConfig('sh sdl-config --cflags')
env.ParseConfig('sh sdl-config --libs')
env.Append(CPPFLAGS = ['-Wall', '-funsigned-char'])
...</pre>
<ul>
<li>finally, in the MSYS shell, built with:</li>
</ul>
<pre>scons sdlmixer=1</pre>
<h2>Final Remarks</h2>
<p>I had trouble with the latest version of PhysicsFS (1.1.1) because it uses cmake. For some reason it failing to find some prerequisites in MSYS. I also had trouble with version 1.0.1 of PhysicsFS (this is the version the official <a style="font-weight: normal;" href="http://downloads.sourceforge.net/dxx-rebirth/d1x-rebirth_v0.55.1-win.zip">d1x-rebirth_v0.55.1-win.zip</a> is built with) because the built failed with the following error:</p>
<pre>warning: cannot find entry symbol _DllMainCRTStartup@12; defaulting to 00401000
...
undefined reference to WinMain@16</pre>
<p>If you notice any problems or mistakes in this post, please mention them in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.plouj.com/blog/2009/03/07/howto-build-dxx-rebirth-for-windows-with-msysmingw/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>TAP that DHCP bridge for some Qemu TUN in Fedora</title>
		<link>http://www.plouj.com/blog/2008/07/29/tap-that-dhcp-bridge-for-some-qemu-tun-in-fedora/</link>
		<comments>http://www.plouj.com/blog/2008/07/29/tap-that-dhcp-bridge-for-some-qemu-tun-in-fedora/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 23:22:40 +0000</pubDate>
		<dc:creator>plouj</dc:creator>
				<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[bridge]]></category>
		<category><![CDATA[DHCP]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[Qemu]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[sysconfig]]></category>
		<category><![CDATA[TAP]]></category>
		<category><![CDATA[TUN]]></category>

		<guid isPermaLink="false">http://www.plouj.com/blog/?p=20</guid>
		<description><![CDATA[The other day I needed to setup bridged networking for a Qemu virtual machine. Although I found a rather well written generic TAP interfaces guide on Wikibooks. It only explained how to configure a network bridge on a host machine with a static IP. I wanted to do this on a host that used DHCP. [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I needed to setup bridged networking for a Qemu virtual machine. Although I found a rather well written generic <a href="http://en.wikibooks.org/wiki/QEMU/Networking#TAP_interfaces">TAP interfaces guide on Wikibooks</a>. It only explained how to configure a network bridge on a host machine with a static IP. I wanted to do this on a host that used DHCP. Plus I wanted to keep all configuration in Fedora specific places. Having discovered a good way to do this through experimentation after a few fruitless Google searches I thought it would be useful for myself and others to have the configuration documented here.</p>
<h2>ifcfg-eth0</h2>
<p>First, I changed the host&#8217;s (auto-generated) <code>/etc/sysconfig/network-scripts/ifcfg-eth0</code> script from this:</p>
<pre># Attansic Technology Corp. L1 Gigabit Ethernet Adapter
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:1D:60:35:A7:64
ONBOOT=yes</pre>
<p>to this:</p>
<pre># Attansic Technology Corp. L1 Gigabit Ethernet Adapter
DEVICE=eth0
TYPE=Ethernet
BRIDGE=br0
ONBOOT=yes</pre>
<p>This turns off DHCP on the physical Ethernet device and just specifies that it will be connected to or a part of a bridge.</p>
<h2>ifcfg-br0</h2>
<p>Second, I created <code>/etc/sysconfig/network-scripts/ifcfg-br0</code>, which will be called to setup a bridge device:</p>
<pre>DEVICE=br0
TYPE=Bridge
BOOTPROTO=dhcp
HWADDR=00:1D:60:35:A7:64
ONBOOT=yes
DELAY=0
STP=off</pre>
<p>As you can see, most of this configuration is copied from eth0 plus the bridge configuration as per the Qemu Wikibook.</p>
<h2>qemu-ifup/down</h2>
<p>Third, I shortened the <code>/etc/qemu-ifup</code> and <code>/etc/qemu-ifdown</code> from Wikibooks to get this:</p>
<p><em>/etc/qemu-ifup:</em></p>
<pre>#!/bin/sh
USER=$(id -un)
sudo /usr/sbin/openvpn --mktun --dev $1 --user "$USER"
sudo /sbin/ifconfig $1 0.0.0.0 promisc up
sudo /usr/sbin/brctl addif br0 $1</pre>
<p><em>/etc/qemu-ifdown:</em></p>
<pre>#!/bin/sh
sudo /sbin/ifconfig $1 down
sudo /usr/sbin/brctl delif br0 $1
sudo /usr/sbin/openvpn --rmtun --dev $1</pre>
<p>Here I basically removed all of the configuration that is taken care of in the sysconfig scripts. I also made explicit use of sudo simply because that is my preference.</p>
<h2>Final steps</h2>
<p>Now I can simply run <code>/etc/qemu-ifup tap0</code> once to create a TAP device, and use something like: <code>qemu-kvm -hda /virtual-machines/fedora9.disk -m 512 -net nic -net tap,ifname=tap0,script=no</code> to start a virtual machine. When I&#8217;m done running the virtual machine, I can run <code>/etc/qemu-ifdown tap0</code> to remove the TAP device.</p>
<p>All this sounds simple now that it&#8217;s working, but initially it took a lot of guessing on my part so I&#8217;m documenting it here for the future.</p>
<p>I would appreciate it if someone can point me to the official Redhat/Fedora documentation on editing <code>/etc/sysconfig/network-scripts/</code> scripts.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.plouj.com/blog/2008/07/29/tap-that-dhcp-bridge-for-some-qemu-tun-in-fedora/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>HOWTO: run rTorrent from Cron inside Screen at boot</title>
		<link>http://www.plouj.com/blog/2008/03/31/howto-run-rtorrent-from-cron-inside-screen/</link>
		<comments>http://www.plouj.com/blog/2008/03/31/howto-run-rtorrent-from-cron-inside-screen/#comments</comments>
		<pubDate>Mon, 31 Mar 2008 17:13:48 +0000</pubDate>
		<dc:creator>plouj</dc:creator>
				<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[bittorrent]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[p2p]]></category>
		<category><![CDATA[screen]]></category>

		<guid isPermaLink="false">http://www.plouj.com/blog/?p=3</guid>
		<description><![CDATA[Once I figured out how to do QoS on my openwrt router I decided that I would make use of the bandwidth provided to me by my ISP to seed some nice legal torrents as long as I can without interrupting my Internet browsing. Since I was already using rTorrent, it seemed like a good [...]]]></description>
			<content:encoded><![CDATA[<p>Once I figured out how to do <a href="http://wiki.openwrt.org/MiniHowtos/QoSHowto">QoS on my openwrt router</a> I decided that I would make use of the bandwidth provided to me by my ISP to seed some nice legal torrents as long as I can without interrupting my Internet browsing. Since I was already using rTorrent, it seemed like a good choice for a console application running inside screen that would be started by cron each time my computer boots. In theory that was true, but in practice the lack of documentation of various peculiarities cost me a few hours of digging and asking around before I had a properly working solution. In this post I will document my solution.</p>
<p>Right away I knew that I wanted to be able to easily attach to the bittorrent screen session at any time, so I used an easy to remember name for it:</p>
<pre>screen -s torrent</pre>
<p>I also knew that for screen to work with cron it had to start in a &#8220;detached&#8221; mode. Thankfully, the screen manual told me how to do that:</p>
<pre>screen -d m</pre>
<p>During my research I came across different people mentioning a <a href="http://www.google.ca/search?q=cron+screen+%22-dmS%22">short form</a> for all of the above switches:</p>
<pre>screen -dmS torrent</pre>
<p>Since I like to simplify things I immediately adopted it and unfortunately paid dearly in the end. In fact, this was one of those attractive in theory but poorly executed features that cause other things to fail and waste my time with unhelpful error messages. It took me a few hours to figure out that it was causing screen to keep failing to start from inside cron with a &#8220;Must be connected to a terminal.&#8221; error.</p>
<p>Once I got over that hurdle I tried the full command without cron:</p>
<pre>screen -d -m -S torrent /usr/bin/rtorrent</pre>
<p>Everything was good until I noticed that I couldn&#8217;t use any rTorrent keyboard commands. I couldn&#8217;t even quit it apart from killing it from a separate terminal. According to the <a href="http://libtorrent.rakshasa.no/wiki/RTorrentUserGuide">rTorrent user guide</a> this was a result of a flow control conflict with screen. Thankfully screen also had a switch -fa just for that:</p>
<pre>screen -fa -d -m -S torrent /usr/bin/rtorrent</pre>
<p>To be on the safe side I used an absolute path to screen in the cron job:</p>
<pre>/usr/bin/screen -fa -d -m -S torrent /usr/bin/rtorrent</pre>
<p>Making sure cron starts this each time my computer boots was easy with the @reboot directive so this is exactly what should go in the crontab:</p>
<pre>@reboot /usr/bin/screen -fa -d -m -S torrent /usr/bin/rtorrent</pre>
<p>After running rTorrent like this for a few days I noticed that it was a bit unstable and would crash sometimes so I came up with a simple Bash script to keep it running:</p>
<pre>
$ cat ~/bin/myrtorrent
#!/bin/bash
PROGRAM="/usr/bin/rtorrent"
GRACE_DELAY=15
while true;
do
    "$PROGRAM"
    RETURNED=$?
    if [ $RETURNED -ne 0 ]
    then
	echo "$PROGRAM did not exit cleanly with status code $RETURNED"
	echo "pausing for $GRACE_DELAY seconds before restarting $PROGRAM"
	sleep $GRACE_DELAY;
    else
	echo "$PROGRAM exited cleanly. It will not be restarted automatically"
	exit 0
    fi
done
</pre>
<p>The final cronjob looks like this now:</p>
<pre>
@reboot /usr/bin/screen -fa -d -m -S torrent $HOME/bin/myrtorrent
</pre>
<p>Sadly, the usefullness of this setup is questionable since <a href="http://arstechnica.com/news.ars/post/20080325-canadian-isps-furious-about-bell-canadas-traffic-throttling.html">Bell is throttling DSL resellers&#8217; peer-to-peer traffic</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.plouj.com/blog/2008/03/31/howto-run-rtorrent-from-cron-inside-screen/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
