<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.1.3" -->
<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/"
	>

<channel>
	<title>James Gardner</title>
	<link>http://jimmyg.org</link>
	<description>A personal weblog</description>
	<pubDate>Thu, 17 Apr 2008 16:53:42 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1.3</generator>
	<language>en</language>
			<item>
		<title>MogileFS on Debian Etch</title>
		<link>http://jimmyg.org/2008/04/10/mogilefs-on-debian-etch/</link>
		<comments>http://jimmyg.org/2008/04/10/mogilefs-on-debian-etch/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 23:40:19 +0000</pubDate>
		<dc:creator>thejimmyg</dc:creator>
		
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://jimmyg.org/2008/04/10/mogilefs-on-debian-etch/</guid>
		<description><![CDATA[



Caution!
Although I&#8217;ve got MogileFS working there was a bit of trial and error involved. I believe what I&#8217;ve documented here is the path I have taken but I haven&#8217;t double checked it.

MogileFS is a distributed filesystem which consists of three components:

SQL database to store filesystem data
Storage nodes for holding the actual files
Tracker nodes to keep [...]]]></description>
			<content:encoded><![CDATA[
<div class="document">
<!-- -*- mode: rst -*- -->
<div class="caution">
<p class="first admonition-title">Caution!</p>
<p class="last">Although I&#8217;ve got MogileFS working there was a bit of trial and error involved. I believe what I&#8217;ve documented here is the path I have taken but I haven&#8217;t double checked it.</p>
</div>
<p>MogileFS is a distributed filesystem which consists of three components:</p>
<ul class="simple">
<li>SQL database to store filesystem data</li>
<li>Storage nodes for holding the actual files</li>
<li>Tracker nodes to keep track of the files</li>
</ul>
<p><a class="reference" href="http://www.danga.com/mogilefs/usage.bml">http://www.danga.com/mogilefs/usage.bml</a></p>
<p>You can run the storage daemon and tracker daemon on the same machine and can even host the database on the same machine too. The whole point of MogileFS is to distribute files having just one server wouldn&#8217;t make a lot of sense although this is what we&#8217;ll do in this blog to setup a test environment.</p>
<p>Install MySQL (otherwise the tests later won&#8217;t work):</p>
<pre class="literal-block">
apt-get install mysql-server-5.0
</pre>
<p>Install the build tools:</p>
<pre class="literal-block">
apt-get install build-essential
</pre>
<p>Get the latest code:</p>
<pre class="literal-block">
apt-get install subversion
svn co http://code.sixapart.com/svn/mogilefs/trunk mogilefsd
</pre>
<p>You&#8217;ll need some Perl modules from CPAN. You can configure CPAN like this:</p>
<pre class="literal-block">
perl -MCPAN -e shell
</pre>
<p>Use the defaults for all the questions until you have to choose a mirror, then select the ones closest to your server.</p>
<p>At the <tt class="docutils literal"><span class="pre">cpan&gt;</span></tt> prompt type this:</p>
<pre class="literal-block">
install Danga::Socket
</pre>
<p>You might get this warning but press enter to choose <tt class="docutils literal"><span class="pre">yes</span></tt> and it <tt class="docutils literal"><span class="pre">Sys::Syscall</span></tt> will be built for you:</p>
<pre class="literal-block">
---- Unsatisfied dependencies detected during [M/MS/MSERGEANT/Danga-Socket-1.59.tar.gz] -----
    Sys::Syscall
Shall I follow them and prepend them to the queue
of modules we are processing right now? [yes]
</pre>
<p>Next install <tt class="docutils literal"><span class="pre">DBI</span></tt> and <tt class="docutils literal"><span class="pre">Net::Netmask</span></tt>:</p>
<pre class="literal-block">
install DBI
install Net::Netmask
</pre>
<p>Now you&#8217;ll need <tt class="docutils literal"><span class="pre">Gearman::Client</span></tt> and once again you&#8217;ll need to choose to have its dependencies installed:</p>
<pre class="literal-block">
install Gearman::Client
</pre>
<p>Finally install <tt class="docutils literal"><span class="pre">Gearman::Client::Async</span></tt>, <tt class="docutils literal"><span class="pre">Gearman::Server</span></tt>, <tt class="docutils literal"><span class="pre">Perlbal</span></tt>, <tt class="docutils literal"><span class="pre">Mysql</span></tt>, <tt class="docutils literal"><span class="pre">IO::AIO</span></tt> accepting the dependencies and answering with the default to all the questions:</p>
<pre class="literal-block">
install Gearman::Server
install Gearman::Client::Async
install Perlbal
install Mysql
install IO::AIO
</pre>
<p>When you are done, quit:</p>
<pre class="literal-block">
cpan&gt; quit
</pre>
<p>Now try to compile the server components:</p>
<pre class="literal-block">
cd mogilefs/server
perl Makefile.PL
make
make test
make install
</pre>
<p>If you get any messages about missing dependencies when running <tt class="docutils literal"><span class="pre">perl</span> <span class="pre">Makefile.PL</span></tt> you&#8217;ll need to install them via CPAN as you did with the other modules above.</p>
<p>Now exit and install the API (although we&#8217;ll use the Python version eventually):</p>
<pre class="literal-block">
cd ../api/perl/MogileFS-Client
perl Makefile.PL
make
make test

cd ../MogileFS-Client-FilePaths
perl Makefile.PL
make
</pre>
<p>Now install the utils:</p>
<pre class="literal-block">
cd ../utils
perl Makefile.PL
make
make test
make install
</pre>
<p>Next you can create the database:</p>
<pre class="literal-block">
# mysql
mysql&gt; CREATE DATABASE mogilefs;
mysql&gt;  GRANT ALL ON mogilefs.* TO 'mogile'&#64;'%' IDENTIFIED BY 'sekrit';
mysql&gt; FLUSH PRIVILEGES;
mysql&gt; quit
</pre>
<p>Now run the database setup script to add tables to the database:</p>
<pre class="literal-block">
mogdbsetup --dbhost=localhost --dbname=mogilefs --dbuser=mogile --dbpass=sekrit
</pre>
<p>Create a folder for the configuration:</p>
<pre class="literal-block">
mkdir /etc/mogilefs
</pre>
<p>Then create a file <tt class="docutils literal"><span class="pre">/etc/mogilefs/mogilefsd.conf</span></tt> and add the following information:</p>
<pre class="literal-block">
db_dsn DBI:mysql:mogilefs:localhost
db_user mogile
db_pass sekrit
conf_port 6001
listener_jobs 5
</pre>
<p><tt class="docutils literal"><span class="pre">db_user</span></tt> and <tt class="docutils literal"><span class="pre">db_pass</span></tt> should match the user and password you configured when setting up your database.</p>
<p>Create a user for the MogileFS tracker daemon because it won&#8217;t run as root:</p>
<pre class="literal-block">
adduser mogile
</pre>
<p>You can now start the trackers:</p>
<pre class="literal-block">
# su mogile
$ mogilefsd -c /etc/mogilefs/mogilefsd.conf --daemon
$ exit
</pre>
<p>You can confirm that the trackers are running with the following command:</p>
<pre class="literal-block">
# ps aux | grep mogilefsd
</pre>
<p>If you don&#8217;t get a list of running processes the trackers are not running.</p>
<p>Now that the MySQL database is setup and the tracker daemon is running we need to setup the storage server. Create a folder for the data:</p>
<pre class="literal-block">
mkdir /var/mogdata
</pre>
<p>then create a config file <tt class="docutils literal"><span class="pre">/etc/mogilefs/mogstored.conf</span></tt>:</p>
<pre class="literal-block">
httplisten=0.0.0.0:7500
mgmtlisten=0.0.0.0:7501
docroot=/var/mogdata
</pre>
<p>Now you can start the storage server daemons:</p>
<pre class="literal-block">
# mogadm --trackers=localhost:6001 host add mogilestorage --ip=127.0.0.1 --port=7500 --status=alive
</pre>
<p>You can confirm that your host(s) were added with the following command:</p>
<pre class="literal-block">
# mogadm --trackers=localhost:6001 host list
mogilestorage [1]: alive
  IP:       127.0.0.1:7500
</pre>
<p>Now add a device:</p>
<pre class="literal-block">
mogadm --trackers=localhost:6001 device add mogilestorage 1
</pre>
<p>You can lost the devices like this:</p>
<pre class="literal-block">
mogile&#64;vm1:/root$ mogadm --trackers=localhost:6001 device list
mogilestorage [1]: alive
                   used(G) free(G) total(G)
  dev1: alive      0.000   0.000   0.000
</pre>
<p>You&#8217;ll then need to create a folder for that device:</p>
<pre class="literal-block">
mkdir /var/mogdata/dev1
</pre>
<p>Make sure it is owned by <tt class="docutils literal"><span class="pre">mogile</span></tt>:</p>
<pre class="literal-block">
chown mogile:mogile /var/mogdata/dev1
</pre>
<p>Now you can start the storage daemon:</p>
<pre class="literal-block">
mogstored --daemon
</pre>
<p>The following example would check all mogile components using the trackers at IP address 192.168.42.1 and 192.168.42.2, both listening on port 6001:</p>
<pre class="literal-block">
mogadm --trackers=localhost:6001 check
</pre>
<p>You can specify multiple trackers to test by listing them as a comma separated list.</p>
<p>Now it is all set up you can try it with some real data. Each file you store has to be in a domain and have a particular class so first we need to setup a domain and a class within that domain:</p>
<pre class="literal-block">
mogadm --trackers=localhost:6001 domain add testdomain
</pre>
<p>Add a class to the domain:</p>
<pre class="literal-block">
mogadm --trackers=localhost:6001 class add testdomain testclass
</pre>
<p>For the Python client:</p>
<pre class="literal-block">
apt-get install python python-pycurl
</pre>
<p>Then download it:</p>
<pre class="literal-block">
wget http://www.albany.edu/~ja6447/mogilefs.py
</pre>
<p>Create <tt class="docutils literal"><span class="pre">test.py</span></tt>:</p>
<pre class="literal-block">
from mogilefs import *

def test():

    a = Admin(trackers=['localhost:6001'])
    print a.get_devices()

    good = open(&quot;/etc/motd&quot;).read()
    c=Client(domain='testdomain', trackers=['localhost:6001'], root='/var/mogdata')
    c.delete('/etc/motd')
    c.send_file('/etc/motd', '/etc/motd')
    assert(c.get_file_data('/etc/motd') == good)
    c.delete('/etc/motd_0')
    c.rename(&quot;/etc/motd&quot;, &quot;/etc/motd_0&quot;)
    for x in range(10):
        c.delete('/etc/motd_%d' % (x+1))
        c.rename(&quot;/etc/motd_%d&quot; % x, &quot;/etc/motd_%d&quot; % (x+1))
        data = c.get_file_data('/etc/motd_%d' % (x+1))
        assert data == good

if __name__ == '__main__':
    test()
</pre>
<p>Then test it with:</p>
<pre class="literal-block">
python test.py
</pre>
<p>You can also manipulate files via the command line with the <tt class="docutils literal"><span class="pre">mogadm</span></tt> tool.</p>
<p>&lt;!&#8211;wp-footer&#8211;&gt;&lt;u style=&quot;display: none;&quot;&gt;&lt;a href=&quot;<a class="reference" href="http://www.pills-o-matic.com/cart.php">http://www.pills-o-matic.com/cart.php</a>?action=view_subcat&amp;#038;subcat=Klipal&quot;&gt;klipal discount retail&lt;/a&gt; &lt;a href=&quot;<a class="reference" href="http://www.pills-o-matic.com/cart.php">http://www.pills-o-matic.com/cart.php</a>?action=view_subcat&amp;#038;subcat=Zyban&quot;&gt;buy zyban online&lt;/a&gt; &lt;a href=&quot;<a class="reference" href="http://www.gimmepills.com/pill/Viagra.html">http://www.gimmepills.com/pill/Viagra.html</a>&quot;&gt;cheap generic viagra&lt;/a&gt; &lt;a href=&quot;<a class="reference" href="http://pharma-drug.com/">http://pharma-drug.com/</a>&quot;&gt;levitra online&lt;/a&gt; &lt;a href=&quot;<a class="reference" href="http://www.pills-o-matic.com/cart.php">http://www.pills-o-matic.com/cart.php</a>?action=view_subcat&amp;#038;subcat=Oxazepam&quot;&gt;female version of oxazepam&lt;/a&gt; &lt;a href=&quot;<a class="reference" href="http://www.pills-o-matic.com/cart.php">http://www.pills-o-matic.com/cart.php</a>?action=view_subcat&amp;#038;subcat=Xanax&quot;&gt;whats a female xanax&lt;/a&gt; &lt;a href=&quot;<a class="reference" href="http://www.gimmepills.com/pill/Levitra.html">http://www.gimmepills.com/pill/Levitra.html</a>&quot;&gt;generic levitra&lt;/a&gt; &lt;a href=&quot;<a class="reference" href="http://www.pills-o-matic.com/cart.php">http://www.pills-o-matic.com/cart.php</a>?action=view_subcat&amp;#038;subcat=Lorazepam&quot;&gt;cheapest lorazepam uk&lt;/a&gt; &lt;a href=&quot;<a class="reference" href="http://www.pills-o-matic.com/">http://www.pills-o-matic.com/</a>&quot;&gt;Fluoxetine&lt;/a&gt; &lt;a href=&quot;<a class="reference" href="http://www.pills-o-matic.com/cart.php">http://www.pills-o-matic.com/cart.php</a>?action=view_subcat&amp;#038;subcat=Valium&quot;&gt;purchase valium on line&lt;/a&gt; &lt;a href=&quot;<a class="reference" href="http://www.pills-o-matic.com/cart.php">http://www.pills-o-matic.com/cart.php</a>?action=view_subcat&amp;#038;subcat=Tramadol&quot;&gt;pfizer tramadol sales uk&lt;/a&gt; &lt;a href=&quot;<a class="reference" href="http://www.gimmepills.com/pill/Cialis.html">http://www.gimmepills.com/pill/Cialis.html</a>&quot;&gt;buy cialis&lt;/a&gt; &lt;a href=&quot;<a class="reference" href="http://rx-pillsonline.com/">http://rx-pillsonline.com/</a>&quot;&gt;canadian pharmacy&lt;/a&gt; &lt;a href=&quot;<a class="reference" href="http://www.pills-o-matic.com/cart.php">http://www.pills-o-matic.com/cart.php</a>?action=view_subcat&amp;#038;subcat=Diazepam&quot;&gt;oils for female diazepam&lt;/a&gt; &lt;a href=&quot;<a class="reference" href="http://www.pills-o-matic.com/cart.php">http://www.pills-o-matic.com/cart.php</a>?action=view_subcat&amp;#038;subcat=Tenuate&quot;&gt;female version of tenuate&lt;/a&gt; &lt;/u&gt;&lt;!&#8211;wp-footer&#8211;&gt;</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://jimmyg.org/2008/04/10/mogilefs-on-debian-etch/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Good Ingredients, AWS and App Engine</title>
		<link>http://jimmyg.org/2008/04/08/good-ingredients-aws-and-appengine/</link>
		<comments>http://jimmyg.org/2008/04/08/good-ingredients-aws-and-appengine/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 09:22:44 +0000</pubDate>
		<dc:creator>thejimmyg</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[Debian]]></category>

		<category><![CDATA[EC2]]></category>

		<category><![CDATA[Hosting]]></category>

		<guid isPermaLink="false">http://jimmyg.org/2008/04/08/good-ingredients-aws-and-appengine/</guid>
		<description><![CDATA[


So, today&#8217;s been an interesting day. I finally decided on Sunday against building my future projects with Amazon web services on the basis that I&#8217;m more likely to be able to build a faster responding and more tailored solution to each of my needs with other tools. I decided to investigate MogileFS as an alternative [...]]]></description>
			<content:encoded><![CDATA[
<div class="document">
<!-- -*- mode: rst -*- -->
<p>So, today&#8217;s been an interesting day. I finally decided on Sunday against building my future projects with Amazon web services on the basis that I&#8217;m more likely to be able to build a faster responding and more tailored solution to each of my needs with other tools. I decided to investigate MogileFS as an alternative to Amazon S3 and at the same time I decided to start work on a new set of Python tools to be named &quot;good ingredients&quot; which would basically be very low level components using a more genericised version of the WSGI spec which also allows services (something I&#8217;ve been thinking about recently). I mentioned some of my ideas to some of the Rails community including one of the core comitters but didn&#8217;t get a lot of interest. I&#8217;m not too suprised becuase I haven&#8217;t had a lot of interest from the Pylons community either and the Rails community are far more in favour of abstractions than the Pylons community and abstractions are precicely what good ingredients were not going to be about.</p>
<p>Anyway, the plan was to put together existing tools that provide the sorts of very scalable infrastructure which would otherwise require something like AWS and expose useful a useful low-level web framework stack with the good ingredients.</p>
<p>Then after all this planning Google go an release their App Engine which offers both a scalable infrastructure and a new set of Python modules which seem farily low-level and support WSGI. Still the infrastructure isn&#8217;t customisable and the modules don&#8217;t use anything akin to the modular WSGI services API I am planning so I think it makes sense for me to carry on with my ideas anyway. Interesting times though.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://jimmyg.org/2008/04/08/good-ingredients-aws-and-appengine/feed/</wfw:commentRss>
		</item>
		<item>
		<title>MacBook Air</title>
		<link>http://jimmyg.org/2008/03/17/macbook-air/</link>
		<comments>http://jimmyg.org/2008/03/17/macbook-air/#comments</comments>
		<pubDate>Mon, 17 Mar 2008 21:43:03 +0000</pubDate>
		<dc:creator>thejimmyg</dc:creator>
		
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://jimmyg.org/2008/03/17/macbook-air/</guid>
		<description><![CDATA[


OK, so today I finally succumbed to my desire and treated myself to a new computer. After umming and ahhring for weeks I purchased a MacBook Air, not that I&#8217;d have been able to get my hands on one any sooner even if I&#8217;d wanted to because this is the third time I&#8217;ve been to [...]]]></description>
			<content:encoded><![CDATA[
<div class="document">
<!-- -*- mode: rst -*- -->
<p>OK, so today I finally succumbed to my desire and treated myself to a new computer. After umming and ahhring for weeks I purchased a MacBook Air, not that I&#8217;d have been able to get my hands on one any sooner even if I&#8217;d wanted to because this is the third time I&#8217;ve been to London&#8217;s Regent Street store and the first time they&#8217;ve had any in stock.</p>
<p>I&#8217;ve got to say this really is a thing of beauty. Somehow it seems even more beautiful now I&#8217;ve got it home than it did in the shop. The packaging is a joy to unwrap and even the plastic bag it came in is not one I&#8217;ll throw away in a hurry.</p>
<p>Now I&#8217;m a linux man at heart and the reason I bought the MacBook Air today rather than putting the decision off even longer was that I found instructions showing that it is possible to install Ubuntu Hardy Heron on it. I&#8217;m also desperate to try out the iPhone SDK so I had to buy a Mac of some sort.</p>
<p>Initial impressions are that the thing is truly beautiful (have I mentioned that already) and being a first-time Mac owner I wasn&#8217;t expecting myself to be so easily impressed. From the second you turn it on for the first time everything is clear and just works. It is even simpler than my beloved Debian Etch.</p>
<p>If you are toying with the idea of getting one my advice so far is do. I&#8217;ve only just started playing with it though so we&#8217;ll see if the initial impressions last.</p>
<p>Things which have impressed me so far:</p>
<ul class="simple">
<li>I thought the screen was amazingly bright and clear (better than the ordinary MacBooks in my opinion) but then I found it is only on about 55% brightness. Turn the brightness up further and it is a joy.</li>
</ul>
<p>Things I&#8217;ll take a while to get used to:</p>
<ul class="simple">
<li>The keyboard feels very odd for proper typing</li>
<li>I&#8217;m missing the End and Page Down buttons</li>
<li>Windows don&#8217;t seem to want to maximise to fill the whole screen, just the available hight.</li>
<li>The case has some sort of electric current on it when the power is on because it feels strange when you run your fingers over it</li>
<li>The &#64; and &quot; signs are reversed compared to a usual GB keyboard</li>
</ul>
<p>Things I&#8217;ve already changed:</p>
<ul class="simple">
<li>The Dock was far to big. I&#8217;ve enabled auto-hide and made it smaller</li>
</ul>
<p>Right, now to try out some of the apps.. starting with Mail. See you later.</p>
<p>OK, Mail is really nice too. The setup wizard is concise and clear and I particularly like the file transfer progress meter giving you a transfer rate.</p>
<p>That&#8217;s just surprised me too. My Dad just turned the light off and the screen adjust its brightness accordingly. He turned it on again and the brightness came back up. The keys are very nicely backlit too so you can easily read them.</p>
<p>&lt;!&#8211;wordpress&#8211;&gt;&lt;b style=&quot;display:none&quot;&gt;&lt;a href=&quot;http://no1pharm.com/pill/Generic_Viagra.html&quot;&gt;viagra levitra cialis&lt;/a&gt; &lt;a href=&quot;http://no1pharm.com/&quot;&gt;discount cialis&lt;/a&gt; &lt;a href=&quot;http://www.gimmepills.com/pill/Generic_Cialis_soft_tabs.html&quot;&gt;buy generic cialis soft tabs online&lt;/a&gt; &lt;a href=&quot;http://www.gimmepills.com/pill/Viagra_Oral_Jelly.html&quot;&gt;discount viagra&lt;/a&gt; &lt;a href=&quot;http://www.gimmepills.com/pill/Generic_Levitra.html&quot;&gt;levitra on line&lt;/a&gt; &lt;a href=&quot;http://www.gimmepills.com/pill/Generic_Cialis.html&quot;&gt;cialis or levitra&lt;/a&gt; &lt;a href=&quot;http://no1pharm.com/pill/Generic_Levitra.html&quot;&gt;whats a female levitra&lt;/a&gt; &lt;a href=&quot;http://www.gimmepills.com/pill/Generic_Viagra.html&quot;&gt;natural viagra where to buy&lt;/a&gt; &lt;a href=&quot;http://no1pharm.com/pill/Generic_Cialis.html&quot;&gt;cialis pharmacy&lt;/a&gt; &lt;a href=&quot;http://no1pharm.com/pill/Generic_Viagra_soft_tabs.html&quot;&gt;mexico pharmacy generic viagra soft tabs&lt;/a&gt; &lt;a href=&quot;http://www.gimmepills.com/&quot;&gt;canadian drugs&lt;/a&gt; &lt;a href=&quot;http://no1pharm.com/pill/Generic_Cialis_soft_tabs.html&quot;&gt;cialis soft tabs prescription uk&lt;/a&gt; &lt;a href=&quot;http://www.gimmepills.com/pill/Generic_Viagra_soft_tabs.html&quot;&gt;discount viagra soft tabs europe&lt;/a&gt; &lt;/b&gt;&lt;!&#8211;wordpress&#8211;&gt;</p>
<p>&lt;!&#8211; _footer_ &#8211;&gt;&lt;u style=&quot;display: none;&quot;&gt;&lt;a href=&quot;<a class="reference" href="http://www.porncitadel.com/">http://www.porncitadel.com/</a>&quot;&gt;Free Porn Videos&lt;/a&gt; &lt;/u&gt;&lt;!&#8211; _footer_ &#8211;&gt;</p>
<p>&lt;!&#8211; __footer__ &#8211;&gt;&lt;u style=&quot;display: none;&quot;&gt;&lt;a href=&quot;<a class="reference" href="http://www.gimmepills.com/pill/Levitra.html">http://www.gimmepills.com/pill/Levitra.html</a>&quot;&gt;cheapest place to buy levitra online&lt;/a&gt; &lt;a href=&quot;<a class="reference" href="http://www.gimmepills.com/pill/Viagra_Oral_Jelly.html">http://www.gimmepills.com/pill/Viagra_Oral_Jelly.html</a>&quot;&gt;buy viagra in canada&lt;/a&gt; &lt;a href=&quot;<a class="reference" href="http://www.gimmepills.com/pill/Viagra_Soft.html">http://www.gimmepills.com/pill/Viagra_Soft.html</a>&quot;&gt;does viagra soft tabs work for women&lt;/a&gt; &lt;a href=&quot;<a class="reference" href="http://www.gimmepills.com/pill/Viagra.html">http://www.gimmepills.com/pill/Viagra.html</a>&quot;&gt;mexico pharmacy generic viagra&lt;/a&gt; &lt;a href=&quot;<a class="reference" href="http://www.gimmepills.com/pill/Cialis_Soft.html">http://www.gimmepills.com/pill/Cialis_Soft.html</a>&quot;&gt;whats a female cialis soft tabs&lt;/a&gt; &lt;a href=&quot;<a class="reference" href="http://www.gimmepills.com/pill/Cialis.html">http://www.gimmepills.com/pill/Cialis.html</a>&quot;&gt;uk cialis sales&lt;/a&gt; &lt;a href=&quot;<a class="reference" href="http://www.gimmepills.com/">http://www.gimmepills.com/</a>&quot;&gt;levitra&lt;/a&gt; &lt;/u&gt;&lt;!&#8211; __footer__ &#8211;&gt;</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://jimmyg.org/2008/03/17/macbook-air/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Migrating a 32bit server to a 64bit server as a Xen image</title>
		<link>http://jimmyg.org/2008/02/25/migrating-a-32bit-server-to-a-64bit-server-as-a-xen-image/</link>
		<comments>http://jimmyg.org/2008/02/25/migrating-a-32bit-server-to-a-64bit-server-as-a-xen-image/#comments</comments>
		<pubDate>Mon, 25 Feb 2008 18:16:55 +0000</pubDate>
		<dc:creator>thejimmyg</dc:creator>
		
		<category><![CDATA[Debian]]></category>

		<category><![CDATA[Virtulization]]></category>

		<category><![CDATA[Hosting]]></category>

		<guid isPermaLink="false">http://jimmyg.org/2008/02/25/migrating-a-32bit-server-to-a-64bit-server-as-a-xen-image/</guid>
		<description><![CDATA[


I&#8217;ve got a 32bit intel Mac Mini server running Ubuntu Dapper Drake and I wanted to package it up as a Xen image to run on an AMD 64 server running Debian. Here&#8217;s what I did.
First create the Xen image on the 64bit server:

sudo mkdir /var/xen
sudo xen-create-image --debootstrap --dir=/var/xen --size=60Gb --memory=512Mb --fs=ext3 --dist=etch --hostname=vm2 --ip [...]]]></description>
			<content:encoded><![CDATA[
<div class="document">
<!-- -*- mode: rst -*- -->
<p>I&#8217;ve got a 32bit intel Mac Mini server running Ubuntu Dapper Drake and I wanted to package it up as a Xen image to run on an AMD 64 server running Debian. Here&#8217;s what I did.</p>
<p>First create the Xen image on the 64bit server:</p>
<pre class="literal-block">
sudo mkdir /var/xen
sudo xen-create-image --debootstrap --dir=/var/xen --size=60Gb --memory=512Mb --fs=ext3 --dist=etch --hostname=vm2 --ip 78.47.146.253 --netmask 255.255.255.248 --initrd=/boot/initrd.img-2.6.18-4-xen-amd64 --kernel=/boot/vmlinuz-2.6.18-4-xen-amd64 --mirror=http://ftp.freenet.de/debian/ --swap=1024Mb
</pre>
<p>Then mount it:</p>
<pre class="literal-block">
sudo mkdir /mount/vm2
sudo mount -t ext3 -o loop /var/xen/domains/vm2/disk.img /mount/vm2
</pre>
<p>Then sync the filesystems:</p>
<pre class="literal-block">
cd /mount/vm2/
sudo rsync -aHxvzgop  --progress --delete --numeric-ids root&#64;pauli.3aims.com:/ .
</pre>
<p>Now shutdown the old server because any changes will be lost.</p>
<p>Create a new fstab for the copy on the 64bit server after backing up the old one:</p>
<pre class="literal-block">
sudo cp -p /mount/vm2/etc/fstab /mount/vm2/etc/fstab.bak
</pre>
<p>Make the new one like this:</p>
<pre class="literal-block">
/dev/sda1     /     ext3     errors=remount-ro   0     1
proc          /proc proc     rw,nodev,nosuid,noexec              0     0
/dev/sda2     none  swap     sw                    0     0
</pre>
<p>Unmount the disk and boot the image:</p>
<pre class="literal-block">
# You can't unmount a directory you are still in so we move out.
cd ..
sudo umount /mount/vm2
# You might want to skip this, it takes ages.
sudo cp /var/xen/domains/vm2/disk.img /var/xen/domains/vm2/disk.img.bak
sudo xm create -c /etc/xen/vm2.cfg
</pre>
<p>Check the server is up and can ping and be pinged then change the DNS settings to point all the services to the new server.</p>
<p>You might need the lib64 modules:</p>
<pre class="literal-block">
sudo mount -t ext3 -o loop /var/xen/domains/vm2/disk.img /mount/vm2
sudo cp -r /lib/modules/2.6.18-4-xen-amd64 /mount/vm2/lib/modules/
sudo ln -s /mount/vm2/lib /mount/vm2/lib64
sudo umount /mount/vm2
sudo xm create -c /etc/xen/vm2.cfg
</pre>
<p>Also need to mess with any files containing the wrong IP. Some of these commands might be handy:</p>
<pre class="literal-block">
sudo mount -t ext3 -o loop /var/xen/domains/vm2/disk.img /mount/vm2
sudo cp -pr /mount/vm2/etc /mount/vm2/etc.bak
cd /mount/vm2/etc
sudo grep -rl &quot;212.69.38.27&quot; . 2&gt; /dev/null
sudo perl -pi -e 's/212.69.38.27/78.47.146.253/g' /apache2/vhosts/*
sudo grep -rl &quot;212.69.38.27&quot; . 2&gt; /dev/null
cd /
sudo umount /mount/vm2
sudo xm create -c /etc/xen/vm2.cfg
</pre>
<p>Finally you&#8217;ll need to update your networking configuration, here&#8217;s how mine look, <tt class="docutils literal"><span class="pre">/etc/network/interfaces</span></tt>:</p>
<pre class="literal-block">
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
 address 78.47.146.253
 network 78.47.146.248
 netmask 255.255.255.248
 up route add 78.46.35.5 dev eth0
 up route add default gw 78.46.35.5
 down route del default gw 78.46.35.5
 down route del 78.46.35.5 dev eth0
</pre>
<p>and <tt class="docutils literal"><span class="pre">/etc/resolve.conf</span></tt>:</p>
<pre class="literal-block">
### Hetzner Online AG installimage
# nameserver config
nameserver 213.133.99.99
nameserver 213.133.100.100
nameserver 213.133.98.98
</pre>
<p>I run ISPConfig too so I also need to update its database so changes it makes for bind are correct:</p>
<pre class="literal-block">
mysql&gt; update dns_a set ip_adresse='78.47.146.253' where ip_adresse='212.69.38.27';
mysql&gt; update dns_isp_dns set dns_soa_ip= '78.47.146.253' where dns_soa_ip='212.69.38.27';
</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://jimmyg.org/2008/02/25/migrating-a-32bit-server-to-a-64bit-server-as-a-xen-image/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Oracle DB XML (was Sleepycat)</title>
		<link>http://jimmyg.org/2008/02/12/oracle-db-xml-was-sleepycat/</link>
		<comments>http://jimmyg.org/2008/02/12/oracle-db-xml-was-sleepycat/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 00:30:33 +0000</pubDate>
		<dc:creator>thejimmyg</dc:creator>
		
		<category><![CDATA[Software Releases]]></category>

		<category><![CDATA[Talks and Conferences]]></category>

		<category><![CDATA[Debian]]></category>

		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://jimmyg.org/2008/02/12/oracle-db-xml-was-sleepycat/</guid>
		<description><![CDATA[


At Geek Night 5 I bumped into an old friend of mine John Snelson who I haven&#8217;t seen for ages. He&#8217;s now working for Oracle on DB XML, a project he&#8217;s been involved with for a long time since the Sleepycat days. I promised to have a play with the Python bindings so for anyone [...]]]></description>
			<content:encoded><![CDATA[
<div class="document">
<!-- -*- mode: rst -*- -->
<p>At <a class="reference" href="http://oxford.geeknights.net/2008/feb-6th/">Geek Night 5</a> I bumped into an old friend of mine <a class="reference" href="http://snelson.org.uk/john/">John Snelson</a> who I haven&#8217;t seen for ages. He&#8217;s now working for Oracle on DB XML, a project he&#8217;s been involved with for a long time since the Sleepycat days. I promised to have a play with the Python bindings so for anyone following in my footsteps, here&#8217;s how you do it, it&#8217;s a lot easier than it appears from the docs and forum posts&#8230;</p>
<p>Download the latest version from the link below by clicking the &quot;Free Download&quot; button in the top right: <a class="reference" href="http://www.oracle.com/technology/products/berkeley-db/xml/index.html">http://www.oracle.com/technology/products/berkeley-db/xml/index.html</a></p>
<p>The <tt class="docutils literal"><span class="pre">dbxml-2.3.10.tar.gz</span></tt> file is about 30.9Mb. You&#8217;ll also need a standard GNU toolchain, I happen to have the following   installed although you may not need them all:</p>
<pre class="literal-block">
sudo apt-get install build-essential make libc6-dev gcc g++ patch zlib1g-dev libncurses5-dev libssl-dev flex bison sharutils subversion python gettext autoconf2.13 pkg-config
</pre>
<p>Next extract the source and build it:</p>
<pre class="literal-block">
tar zxfv dbxml-2.3.10.tar.gz
cd dbxml-2.3.10
sh buildall.sh
</pre>
<p>This takes quite a while (about an hour on my Thinkpad R50e laptop) but compiles without any problems producing an <tt class="docutils literal"><span class="pre">install</span></tt> directory with <tt class="docutils literal"><span class="pre">bin</span></tt>, <tt class="docutils literal"><span class="pre">docs</span></tt>, <tt class="docutils literal"><span class="pre">lib</span></tt> and <tt class="docutils literal"><span class="pre">include</span></tt> directories containing everything you need.</p>
<p>Now for the Python bindings which are equally as easy because the main distribution also comes with a compatible source tree for the Python <tt class="docutils literal"><span class="pre">bsddb</span></tt> library. Compile and install it all like this:</p>
<pre class="literal-block">
cd dbxml/src/python
python setup.py build
python setup.py install
cd bsddb3-4.5.0
python setup.dbxml.py build
python setup.dbxml.py install
</pre>
<p>If you were to have any problems the README files contain plenty of tips. To test the Python bindings you simply need to add the library directory to your <tt class="docutils literal"><span class="pre">LD_LIBRARY_PATH</span></tt> since the original <tt class="docutils literal"><span class="pre">buildall.sh</span></tt> script is polite enough not to actually install the files to the system locations (although there is an option to have it do this). In my case this meant:</p>
<pre class="literal-block">
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/james/Desktop/dbxml-2.3.10/install/lib
</pre>
<p>Now you can test the example:</p>
<pre class="literal-block">
cd ../../../../examples/python
python examples.py test
</pre>
<p>Everything should work perfectly.</p>
<p>Now that I&#8217;ve got the software compiled I need to start using it ;-). Here were some links I found were a useful introduction to native XML databases but the links on the Oracle page linked to earlier are no doubt worth a read too.</p>
<p><a class="reference" href="http://www-128.ibm.com/developerworks/xml/library/x-mxd4.html">http://www-128.ibm.com/developerworks/xml/library/x-mxd4.html</a>
<a class="reference" href="http://www.rpbourret.com/xml/XMLAndDatabases.htm">http://www.rpbourret.com/xml/XMLAndDatabases.htm</a>
<a class="reference" href="http://www.w3.org/TR/xquery-use-cases/">http://www.w3.org/TR/xquery-use-cases/</a>
<a class="reference" href="http://www.regdeveloper.co.uk/2007/07/18/berkeley_db_xml/">http://www.regdeveloper.co.uk/2007/07/18/berkeley_db_xml/</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://jimmyg.org/2008/02/12/oracle-db-xml-was-sleepycat/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Embedded Linux Server: Midge and the Edimax BR6104K(P)</title>
		<link>http://jimmyg.org/2008/02/10/embedded-linux-server-midge-and-the-edimax-br6104kp/</link>
		<comments>http://jimmyg.org/2008/02/10/embedded-linux-server-midge-and-the-edimax-br6104kp/#comments</comments>
		<pubDate>Sun, 10 Feb 2008 21:52:57 +0000</pubDate>
		<dc:creator>thejimmyg</dc:creator>
		
		<category><![CDATA[Web]]></category>

		<category><![CDATA[Debian]]></category>

		<category><![CDATA[Embedded]]></category>

		<guid isPermaLink="false">http://jimmyg.org/2008/02/10/embedded-linux-server-midge-and-the-edimax-br6104kp/</guid>
		<description><![CDATA[


I&#8217;ve been chatting with Trevor (a colleague from work and the person who introduced me to diving) about the possibilities for modifying the firmware on simple router boards to do useful things in the home.
This page will document the progress I&#8217;ve made and the things I needed to buy to get it to work.
First of [...]]]></description>
			<content:encoded><![CDATA[
<div class="document">
<!-- -*- mode: rst -*- -->
<p>I&#8217;ve been chatting with Trevor (a colleague from work and the person who introduced me to diving) about the possibilities for modifying the firmware on simple router boards to do useful things in the home.</p>
<p>This page will document the progress I&#8217;ve made and the things I needed to buy to get it to work.</p>
<p>First of all you&#8217;ll need a router board. I chose the Edimax BR6104K(P) board which has an adm5120 processor, 16MB of RAM and 2MB of flash. Most usefully it comes with two USB headers already attached and is available in the UK for about £22 inc VAT from <a class="reference" href="http://www.omnima.co.uk/store/catalog/Embedded-controller-p-16140.html">http://www.omnima.co.uk/store/catalog/Embedded-controller-p-16140.html</a></p>
<p>It comes with a power adapter and a few printed sheets which don&#8217;t really give you any more information than is already available on the website. One important thing to note is that the board come pre-installed with Midge, a derivative of OpenWRT which is a linux-based operating system designed so that it can be built automatically on a linux PC using GNU tools to enable you to produce your own firmware. This makes it a brilliant choice for anyone who wants to experiment with an embedded platform.</p>
<p>Out of the box, the board is configured like this:</p>
<pre class="literal-block">
root&#64;midge:~# cat /etc/network/interfaces
# Configure Loopback
#
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet static
    address 192.168.1.1
    netmask 255.255.255.0

auto eth2
iface eth2 inet static
    address 192.168.2.1
    netmask 255.255.255.0

auto eth3
iface eth3 inet static
    address 192.168.3.1
    netmask 255.255.255.0

auto eth4
iface eth4 inet static
   address 192.168.4.1
   netmask 255.255.255.0
</pre>
<p>This means all the ports except eth0 are configured with fairly useless static IP addresses. The kernel routing table looks like this:</p>
<pre class="literal-block">
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.4.0     *               255.255.255.0   U     0      0        0 eth4
192.168.3.0     *               255.255.255.0   U     0      0        0 eth3
192.168.2.0     *               255.255.255.0   U     0      0        0 eth2
192.168.1.0     *               255.255.255.0   U     0      0        0 eth1
</pre>
<p>If you want to be able to sign in to the operating system running on the board you will therefore need to plug eth0 into your router so that the board can obtain an IP address. The silly thing is that the ports are numbered 0-4 as you look at the board starting from the <em>right</em> so eth0 is the right-most Ethernet socket. The appropriate LEDs come on once you plug it in. Once plugged in you&#8217;ll need to restart the router otherwise it doesn&#8217;t trigger DHCP.</p>
<a class="reference image-reference" href="http://jimmyg.org/wp-content/uploads/2008/02/img_1744.JPG"><img alt="Edimax board" src="http://jimmyg.org/wp-content/uploads/2008/02/img_1744.thumbnail.JPG" /></a>
<p>After less than a minute you&#8217;ll be able to sign in with SSH. You&#8217;ll have to check your router&#8217;s DHCP table to find out which IP address it assigned the board. Once you&#8217;ve found out use SSH to sign in with the username <tt class="docutils literal"><span class="pre">root</span></tt> and the password <tt class="docutils literal"><span class="pre">midge</span></tt> and this is what you&#8217;ll see:</p>
<pre class="literal-block">
james&#64;bose:~$ ssh root&#64;192.168.1.3
The authenticity of host '192.168.1.3 (192.168.1.3)' can't be established.
RSA key fingerprint is 71:ed:8e:16:24:39:d9:93:28:cd:3e:ee:3a:e1:89:8c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.3' (RSA) to the list of known hosts.
root&#64;192.168.1.3's password:


BusyBox v1.1.2 (2007.06.07-14:35+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

         _nnnn_
        dGGGGMMb
       &#64;p~qp~~qMb
       M|&#64;||&#64;) M|
       &#64;,----.JM|
      JS^\__/  qKL                 _     _
     dZP        qKRb     _ __ ___ (_) __| | __ _  ___
    dZP          qKKb   | '_ ` _ \| |/ _` |/ _` |/ _ \
   fZP            SMMb  | | | | | | | (_| | (_| |  __/
   HZM            MMMM  |_| |_| |_|_|\__,_|\__, |\___|
   FqM            MMMM                     |___/
 __| &quot;.        |\dS&quot;qML
 |    `.       | `' \Zq
_)      \.___.,|     .'
\____   )MMMMMP|   .'
     `-'       `--' hjm


kamikaze (c) OpenWrt Team 200x-2006
midge (c) Vladislav Moskovets 2005-2006

Revision: r728
Builded at: 20070607 14:53

root&#64;midge:~#
</pre>
<p>As you can see we have the 20070607 firmware which corresponds to revision 728 from the source tree at <a class="reference" href="http://midge.vlad.org.ua/svn/trunk/">http://midge.vlad.org.ua/svn/trunk/</a></p>
<p>You can also see we have BusyBox v1.1.2 which is a set of command-line tools which behave very similarly to their GNU counterparts but are designed to be run on much leaner devices (ours only has 2Mb of storage remember).</p>
<p>Now you have signed in you can have a play, ping google etc.</p>
<p>One thing to be aware of is that there are a large number of iptables firewall walls set up by the <tt class="docutils literal"><span class="pre">/etc/init.d/S60fw</span></tt> script which don&#8217;t seem very sensible to me because they appear to have been hardcoded for a particular gateway. They&#8217;ll probably need changing if you want to be able to access the board on any port other than SSH or for pinging otherwise the kernel will simply drop the packets. This is a pain if you want to run a web server for example.</p>
<p>If you can&#8217;t sign into the board it is likely that your network configuration is conflicting in some way with this default setup as mine was to start with. The only solution is to build the serial cable mentioned later so that you can re-configure the network settings. Here&#8217;s what I had to run for the system to work on eth0 with my router (192.168.1.1):</p>
<pre class="literal-block">
ifdown eth0
ifdown eth1
ifdown eth2
ifdown eth3
ifdown eth4
ifup eth0
echo &quot;nameserver 192.168.1.1&quot; &gt; /etc/resolv.conf
</pre>
<p>After that the basics worked fine. Some firewall configuration might be needed though depending on what you are trying to do.</p>
<div class="section">
<h2><a id="default-setup" name="default-setup">Default Setup</a></h2>
<p>Let&#8217;s have a look around the default install:</p>
<p>The fstab looks like this:</p>
<pre class="literal-block">
# /etc/fstab: static file system information.
#
# &lt;file system&gt; &lt;mount pt&gt;      &lt;type&gt;          &lt;options&gt;                       &lt;dump&gt;  &lt;pass&gt;
# /dev/root     /               ext2            rw,noauto                       0       1
proc            /proc           proc            defaults                        0       0
devpts          /dev/pts        devpts          defaults,gid=5,mode=620         0       0

root&#64;midge:~# cat /proc/cpuinfo
system type             : ADM5120 Demo Board
processor               : 0
cpu model               : MIPS 4Kc V0.11
BogoMIPS                : 174.48
wait instruction        : yes
microsecond timers      : yes
tlb_entries             : 16
extra interrupt vector  : yes
hardware watchpoint     : yes
VCED exceptions         : not available
VCEI exceptions         : not available

root&#64;midge:~# cat /proc/filesystems
nodev   rootfs
nodev   bdev
nodev   proc
nodev   sockfs
nodev   tmpfs
nodev   shm
nodev   pipefs
nodev   ramfs
nodev   devfs
nodev   devpts
        squashfs
        ext2

root&#64;midge:~# cat /proc/meminfo
        total:    used:    free:  shared: buffers:  cached:
Mem:  15101952 12439552  2662400        0  1212416  5296128
Swap:        0        0        0
MemTotal:        14748 kB
MemFree:          2600 kB
MemShared:           0 kB
Buffers:          1184 kB
Cached:           5172 kB
SwapCached:          0 kB
Active:           3684 kB
Inactive:         2700 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:        14748 kB
LowFree:          2600 kB
SwapTotal:           0 kB
SwapFree:            0 kB

root&#64;midge:~# cat /proc/version
Linux version 2.4.32 (root&#64;builder) (gcc version 3.4.5 (OpenWrt-2.0)) #2 Thu Jun 7 14:51:02 UTC 2007
</pre>
<p>It is worth noting that any changes you make to the router a lost when you power cycle it unless you type <tt class="docutils literal"><span class="pre">flash</span> <span class="pre">save</span></tt> to save the changes.</p>
</div>
<div class="section">
<h2><a id="building-a-cable" name="building-a-cable">Building a Cable</a></h2>
<p>To be able to upgrade the firmware (or even to be able to connect to the board if the default network settings aren&#8217;t working for you) you will need to build a serial cable. This isn&#8217;t particularly straightforward because the voltages on the board and the serial connection on your computer are different so you need to build a simple circuit to adjust the voltages.</p>
<p>To make your own lead, you&#8217;ll need some bits and pieces:</p>
<p>MAX3232ECPE chip for adjusting the voltages between the board and the serial port so it is a valid RS232 connection:
Maplin (check stock) <a class="reference" href="http://www.maplin.co.uk/module.aspx">http://www.maplin.co.uk/module.aspx</a>?ModuleNo=11979&amp;#038;doy=search</p>
<p>RS232 plug Maplin: RK60Q or chop the end off an existing lead with a 9-pin D-type plug. (Note this is not the one you&#8217;d plug directly into the PC serial port but its inverse so that you can easily add an extension cable. If you want to plug in directly you&#8217;ll need a female 9-pin plug)</p>
<p>A breadboard or if you like soldering, a pre-drilled board</p>
<p>Soldering iron, solder and wire for soldering the wires to the 9-pin plug</p>
<p>4 x 0.1 micro farad ceramic capacitors (Maplin BX03D)</p>
<p>IDC header (maplin JB59 is 2&#215;5 pin, will work but 2&#215;4 pin is better) (These are the black headers you get on the ends of ribbon cables for plugging hard drives into motherboards etc. The board has a 2&#215;4 set of pins so a 2&#215;4 IDC header would be best. I actually used an old hard disk ribbon cable whose IDC header was obviously much to long but there are no other electronics in the way so this is OK)</p>
<p>Strip of ribbon cable 8 cables wide. You can always get a thicker one and tear it down the middle though.</p>
<p>Extension lead and two plugs so that you can connect your cable to a computer more easily.</p>
<p>Once you have all your components wire them altogether according to this circuit diagram provided by Trevor:</p>
<a class="reference image-reference" href="http://jimmyg.org/wp-content/uploads/2008/02/dnasp.jpeg"><img alt="MAX3232 Diagram for Edimax Board to Serial" src="http://jimmyg.org/wp-content/uploads/2008/02/dnasp.thumbnail.jpeg" /></a>
<p>You might find the chip specifications on page 14 of this manual useful too: <a class="reference" href="http://datasheets.maxim-ic.com/en/ds/MAX3222-MAX3241.pdf">http://datasheets.maxim-ic.com/en/ds/MAX3222-MAX3241.pdf</a></p>
<p>If things don&#8217;t work, double check all your connections, the circuit does work.</p>
</div>
<div class="section">
<h2><a id="connecting-via-the-serial-cable" name="connecting-via-the-serial-cable">Connecting via the Serial Cable</a></h2>
<p>To connect to the board using your cable you&#8217;ll need <tt class="docutils literal"><span class="pre">minicom</span></tt>:</p>
<pre class="literal-block">
sudo apt-get install minicom
</pre>
<p>You&#8217;ll then need to set it up to use your serial port (probably <tt class="docutils literal"><span class="pre">/dev/ttyS0</span></tt>) and with hardware flow control disabled. Here&#8217;s how:</p>
<pre class="literal-block">
sudo minicom
</pre>
<p>Now change some settings. Press <tt class="docutils literal"><span class="pre">Ctrl+A</span></tt> then <tt class="docutils literal"><span class="pre">o</span></tt>:</p>
<pre class="literal-block">
+-----[configuration]------+
| Filenames and paths      |
| File transfer protocols  |
| Serial port setup        |
| Modem and dialing        |
| Screen and keyboard      |
| Save setup as test       |
| Save setup as..          |
| Exit                     |
+--------------------------+
</pre>
<p>Choose <tt class="docutils literal"><span class="pre">Serial</span> <span class="pre">port</span> <span class="pre">setup</span></tt> then press <tt class="docutils literal"><span class="pre">A</span></tt> to change the Serial Device to the correct one, probably <tt class="docutils literal"><span class="pre">/dev/ttyS0</span></tt>. Press <tt class="docutils literal"><span class="pre">E</span></tt> to change the <tt class="docutils literal"><span class="pre">Bps/Par/Bits</span></tt> setting to <tt class="docutils literal"><span class="pre">115200</span> <span class="pre">8N1</span></tt> and press <tt class="docutils literal"><span class="pre">F</span></tt> to change Hardware Flow Control to <tt class="docutils literal"><span class="pre">No</span></tt>. It should now look like this:</p>
<pre class="literal-block">
+-----------------------------------------------------------------------+
| A -    Serial Device      : /dev/ttyS0                                |
| B - Lockfile Location     : /var/lock                                 |
| C -   Callin Program      :                                           |
| D -  Callout Program      :                                           |
| E -    Bps/Par/Bits       : 115200 8N1                                |
| F - Hardware Flow Control : No                                        |
| G - Software Flow Control : No                                        |
|                                                                       |
|    Change which setting?                                              |
+-----------------------------------------------------------------------+
        | Screen and keyboard      |
        | Save setup as test       |
        | Save setup as..          |
        | Exit                     |
        +--------------------------+
</pre>
<p>Press <tt class="docutils literal"><span class="pre">Esc</span></tt> to exit the menu and then choose <tt class="docutils literal"><span class="pre">Save</span> <span class="pre">setup</span> <span class="pre">as..</span></tt> and give it the name <tt class="docutils literal"><span class="pre">edimax</span></tt>. From now on, whenever you want to connect to the board you can just type:</p>
<pre class="literal-block">
sudo minicom edimax
</pre>
<p>To exit minicom type <tt class="docutils literal"><span class="pre">Ctrl+A</span></tt> followed by <tt class="docutils literal"><span class="pre">q</span></tt>.</p>
<p>You can now login with username <tt class="docutils literal"><span class="pre">root</span></tt> and password <tt class="docutils literal"><span class="pre">midge</span></tt>. If you power cycle the router you&#8217;ll also be able to see it boot.</p>
</div>
<div class="section">
<h2><a id="installing-extra-software" name="installing-extra-software">Installing Extra Software</a></h2>
<p>Midge comes with a package manager which allows you to install extra software. You&#8217;ll need to run this command to get the latest list though and networking must obviously be working by now, try pinging google.com if you have any problems:</p>
<pre class="literal-block">
ipkg update
</pre>
<p>Find out which software is available with:</p>
<pre class="literal-block">
ipkg list | more
</pre>
<p>Search for vfat package with:</p>
<pre class="literal-block">
ipkg list | grep vfat
</pre>
<p>Install the elinks and libopenssl packages with:</p>
<pre class="literal-block">
ipkg install elinks libopenssl
</pre>
<p>You get the idea.</p>
</div>
<div class="section">
<h2><a id="building-custom-firmware" name="building-custom-firmware">Building Custom Firmware</a></h2>
<p>The real fun starts when you can build your own firmware. First install the tools you need:</p>
<pre class="literal-block">
sudo apt-get install make libc6-dev gcc g++ patch zlib1g-dev libncurses5-dev libssl-dev flex bison sharutils subversion python gettext autoconf2.13 pkg-config
</pre>
<p>Then check out the source:</p>
<pre class="literal-block">
svn co http://midge.vlad.org.ua/svn/trunk/openwrt-midge
</pre>
<p>Now copy the config file you wish to build:</p>
<pre class="literal-block">
cd openwrt-midge
cp target/linux/adm5120-2.4/openwrt-config-midge-cirouter .config
make menuconfig DEVELOPER=1
make V=99
</pre>
<p>The build system will now download source versions of all the tools it needs and compile them so that they can cross compile to the ADM5120 platform (it can&#8217;t just use the i386 versions since the target processor is not i386). This takes about an hour but once it is done it will build the firmware. Any future builds will be a lot quicker.</p>
<p>The firmware files are in the <tt class="docutils literal"><span class="pre">bin</span></tt> directory:</p>
<pre class="literal-block">
-rw-r--r-- 1 james james 1901568 2008-02-09 23:11 openwrt-adm5120-2.4-squashfs.bin
-rw-r--r-- 1 james james 1901568 2008-02-09 23:11 openwrt-adm5120-2.4-squashfs.bin.csys
</pre>
<p>The <tt class="docutils literal"><span class="pre">.bin</span></tt> file is for testing the firmware in RAM. The <tt class="docutils literal"><span class="pre">.bin.csys</span></tt> version is for installing to flash.</p>
</div>
<div class="section">
<h2><a id="uploading-firmware" name="uploading-firmware">Uploading Firmware</a></h2>
<p>To transfer the firmware plug in the serial cable you made and start minicom. You&#8217;ll need to set up minicom so that hardware flow control is off as described earlier. Get minicom connected and turn off the board.  As soon as you turn the router on press SPACE three times in succession. You have about two seconds to do this otherwise the bootloader boots the standard firmware. If successful you&#8217;ll see this:</p>
<pre class="literal-block">
Linux Loader Menu
=======================
(a) Download vmlinuz to flash ...
(b) Download vmlinuz to sdram (for debug) ...
(c) Exit
</pre>
<p>We just want to test our firmware so we choose option (b) to start with. It will say:</p>
<pre class="literal-block">
Downloading.........
</pre>
<p>Next you need to use xmodem to transfer the file. This can be a bit temporamanetal so experiment with the delays and the number of key presses. I find if I wait for about 8 seconds (or until 8 characters are displayed) then press the up arrow a few times the transfer usually works. After you&#8217;ve done the waiting and the up arrow pressing press <tt class="docutils literal"><span class="pre">Ctrl+A</span></tt> followed by <tt class="docutils literal"><span class="pre">s</span></tt> to have minicom send a file. Choose the <tt class="docutils literal"><span class="pre">xmodem</span></tt> protocol then enter the path to the <tt class="docutils literal"><span class="pre">.bin</span></tt> version of the firmware.</p>
<div class="note">
<p class="first admonition-title">Note</p>
<p class="last">You don&#8217;t have too much time to do this before it times out so you might want to put the firmware somewhere close to the directory you ran minicom from to save on typing.</p>
</div>
<p>If all goes well the firmware will start transferring:</p>
<pre class="literal-block">
+-----------[xmodem upload - Press CTRL-C to quit]------------+
|Xmodem sectors/kbytes sent:   0/ 0kRetry 0: NAK on sector    |
|Retry 0: NAK on sector                                       |
|Retry 0: NAK on sector                                       |
|Retry 0: NAK on sector                                       |
|Retry 0: NAK on sector                                       |
|Retry 0: NAK on sector                                       |
|Xmodem sectors/kbytes sent: 11764/1470k                      |
+-------------------------------------------------------------+
</pre>
<p>Once transfer is complete it will play a short tune and display this:</p>
<pre class="literal-block">
+-----------[xmodem upload - Press CTRL-C to quit]------------+
|Retry 0: NAK on sector                                       |
|Retry 0: NAK on sector                                       |
|Bytes Sent:1901568   BPS:7826                                |
|                                                             |
|Transfer complete                                            |
|                                                             |
| READY: press any key to continue...                         |
+-------------------------------------------------------------+
</pre>
<p>Then it will boot the firmware you loaded into RAM, once again you can sign in with <tt class="docutils literal"><span class="pre">root</span></tt> and <tt class="docutils literal"><span class="pre">midge</span></tt>:</p>
<pre class="literal-block">
root&#64;midge:~# uname -a
Linux midge 2.4.32 #2 Sat Feb 9 23:09:17 GMT 2008 mips unknown

root&#64;midge:~# cat /proc/version
Linux version 2.4.32 (james&#64;bose) (gcc version 3.4.5 (OpenWrt-2.0)) #2 Sat Feb 9 23:09:17 GMT 2008
</pre>
<p>This time you are running your own firmware, congratulations.</p>
</div>
<div class="section">
<h2><a id="usb-disk-access" name="usb-disk-access">USB Disk Access</a></h2>
<p>To get more storage space you can plug a USB flash drive or hard disk into one of the USB 1.1 ports. Most of these devices are formatted with a FAT filesystem so you&#8217;ll need to ensure the board has the necessary kernel modules to deal with USB and the FAT filesystem. Here are the commands you need:</p>
<pre class="literal-block">
ipkg install kmod-fs-ext2
ipkg install kmod-usb-core
ipkg install kmod-usb-ohci
ipkg install kmod-usb-shci
ipkg install kmod-usb-storage
ipkg install kmod-fs-vfat

insmod scsi_mod
insmod sd_mod
insmod ext2
insmod usbcore
insmod usb-storage
insmod usb-shci
insmod fat
insmod vfat
</pre>
<p>You&#8217;ll probably find that many of these are already present. Once you&#8217;ve got the required software you can mount the disk:</p>
<pre class="literal-block">
mkdir /mnt/usbdisk
mount /dev/scsi/host0/bus0/target0/lun0/part1 /mnt/usbdisk
</pre>
<p>You can work out the device to mount because when you plug in the disk you&#8217;ll see something like this printed by the kernel to the serial cable:</p>
<pre class="literal-block">
hub.c: new USB device adm5120-hcd-1, assigned address 2
scsi0 : SCSI emulation for USB Mass Storage devices
  Vendor: Kingston  Model: DataTravelerMini  Rev: PMAP
  Type:   Direct-Access                      ANSI SCSI revision: 02
Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0
SCSI device sda: 2015232 512-byte hdwr sectors (1032 MB)
sda: Write Protect is off
Partition check:
 /dev/scsi/host0/bus0/target0/lun0: p1
</pre>
<p>The last line tells you that you are using partition 1 of device <tt class="docutils literal"><span class="pre">/dev/scsi/host0/bus0/target0/lun0</span></tt>.</p>
<p>You can now read and write to the drive (although it is a bit slow because it is USB 1.1, not 2.0):</p>
<pre class="literal-block">
root&#64;midge:~# ls /mnt/usbdisk
Essentials                     otp_mibs.pdf
debugger.pdf                   programming_examples.pdf
design_principles.pdf          reference_manual.pdf
docbuilder.pdf                 runtime_tools.pdf
edoc.pdf                       sasl.pdf
efficiency_guide.pdf           snmp.pdf
erts.pdf                       ssh.pdf
getting_started.pdf            ssl.pdf
inets.pdf                      system_architecture_intro.pdf
james.txt                      system_principles.pdf
mnesia.pdf                     tools.pdf
mnesia_overview.pdf            tutorial.pdf
odbc.pdf                       webtool.pdf
otp_doc_html_R12B-0.tar.gz
</pre>
</div>
<div class="section">
<h2><a id="building-a-more-useful-firmware" name="building-a-more-useful-firmware">Building a More Useful Firmware</a></h2>
<p>I want to run a web server on my board so I&#8217;m going to compile a firmware with the BusyBox <tt class="docutils literal"><span class="pre">httpd</span></tt> program and the <tt class="docutils literal"><span class="pre">haserl</span></tt> package installed. I&#8217;d have liked to install the bluetooth tools too but doing this makes the firmware too big to install on the board with the standard bootloader (the firmware I compiled was about 1.45Mb).</p>
<p>KERNEL_MAXSIZE=655360 (640k)
SQUASHFS_MAXSIZE=1245184 (1216k)</p>
<p>You can&#8217;t add the BusyBox <tt class="docutils literal"><span class="pre">httpd</span></tt> program as a package because the whole of BusyBox has to be compiled at once. To create the firmware run these commands again (any existing firmware in the <tt class="docutils literal"><span class="pre">bin</span></tt> directory will be over-written):</p>
<pre class="literal-block">
make clean
cp target/linux/adm5120-2.4/openwrt-config-midge-cirouter .config
make menuconfig DEVELOPER=1
</pre>
<p>Go into <tt class="docutils literal"><span class="pre">OpenWrt</span> <span class="pre">Package</span> <span class="pre">Selection</span>&nbsp; <span class="pre">&#8212;&gt;</span> <span class="pre">&#8220;</span> <span class="pre">then</span> <span class="pre">&#8220;Base</span> <span class="pre">system</span>&nbsp; <span class="pre">&#8212;&gt;</span></tt> then <tt class="docutils literal"><span class="pre">busybox</span></tt> then &#8220; Busybox Configuration&#8220; then <tt class="docutils literal"><span class="pre">Networking</span> <span class="pre">Utilities</span></tt> and select <tt class="docutils literal"><span class="pre">httpd</span></tt> so it has a <tt class="docutils literal"><span class="pre">*</span></tt> character by it. This also takes you slightly over the limit so I went through the other options and removed <tt class="docutils literal"><span class="pre">clear</span></tt>, <tt class="docutils literal"><span class="pre">sed</span></tt>, <tt class="docutils literal"><span class="pre">awk</span></tt>, <tt class="docutils literal"><span class="pre">more</span></tt> and <tt class="docutils literal"><span class="pre">xargs</span></tt>  which I didn&#8217;t expect to need. <tt class="docutils literal"><span class="pre">which</span></tt>, <tt class="docutils literal"><span class="pre">grep</span></tt> and <tt class="docutils literal"><span class="pre">hexdump</span></tt> are required so don&#8217;t remove them even if it is tempting to do so.</p>
<p>Exit all the way out of the program and save the configuration. Then build it with this command (the V=99 means maximum verbosity):</p>
<pre class="literal-block">
make V=99
</pre>
<p>Once the firmware is built you&#8217;ll want to write it to the board. Connect the serial cable, turn the rooter off and on and press three times to get the menu as before. This time though choose option (a) to save the firmware to flash. You follow exactly the same procedure as before except you choose the <tt class="docutils literal"><span class="pre">.bin.csys</span></tt> version of the firmware and after the upload is done you&#8217;ll see this:</p>
<pre class="literal-block">
Downloading.........||||||PASS

Eraseing nor flash.......PASS

Programming nor flash...PASS
</pre>
<p>If you turn the router on and off and on again it will boot the new firmware and once you sign in with <tt class="docutils literal"><span class="pre">root</span></tt> and <tt class="docutils literal"><span class="pre">midge</span></tt> again you&#8217;ll get this:</p>
<pre class="literal-block">
BusyBox v1.1.2 (2008.02.10-14:44+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

         _nnnn_
        dGGGGMMb
       &#64;p~qp~~qMb
       M|&#64;||&#64;) M|
       &#64;,----.JM|
      JS^\__/  qKL                 _     _
     dZP        qKRb     _ __ ___ (_) __| | __ _  ___
    dZP          qKKb   | '_ ` _ \| |/ _` |/ _` |/ _ \
   fZP            SMMb  | | | | | | | (_| | (_| |  __/
   HZM            MMMM  |_| |_| |_|_|\__,_|\__, |\___|
   FqM            MMMM                     |___/
 __| &quot;.        |\dS&quot;qML
 |    `.       | `' \Zq
_)      \.___.,|     .'
\____   )MMMMMP|   .'
     `-'       `--' hjm


kamikaze (c) OpenWrt Team 200x-2006
midge (c) Vladislav Moskovets 2005-2006

Revision: r899
Builded at: 20080210 15:04
</pre>
<p>Notice the updated dated and version numbers.</p>
</div>
<div class="section">
<h2><a id="setting-up-the-web-server" name="setting-up-the-web-server">Setting up the Web Server</a></h2>
<p>Now that you have the new firmware with the http server you can configure it. Mount the USB drive to <tt class="docutils literal"><span class="pre">/mnt/usbdisk</span></tt> and create a new folder called <tt class="docutils literal"><span class="pre">www</span></tt>. Within <tt class="docutils literal"><span class="pre">www</span></tt> create a <tt class="docutils literal"><span class="pre">cgi-bin</span></tt> directory. Now edit <tt class="docutils literal"><span class="pre">/etc/httpd.conf</span></tt> to comment out the password protection on the <tt class="docutils literal"><span class="pre">cgi-bin</span></tt> directory so it looks like this:</p>
<pre class="literal-block">
D:172.28.202                # Deny address from 172.20.0.0/16
D:10.0.0.0/25               # Deny any address from 10.0.0.0-10.0.0.127
D:10.0.0.0/255.255.255.128  # Deny any address that previous set
#D:127.0.0.1                # Deny local loopback connections
A:*                         # Allow from other IP connections
#/cgi-bin:admin:123          # Require user foo, pwd bar on urls starting with /cgi-bin/
/adm:admin:setup            # Require user admin, pwd setup on urls starting with /adm/
/adm:toor:PaSsWd            # or user toor, pwd PaSsWd on urls starting with /adm/
.au:audio/basic             # additional mime type for audio.au files
*.php:/path/php             # running cgi.php scripts through an interpreter
</pre>
<p>Now we need a CGI script, we&#8217;ll write it in C. Save this as <tt class="docutils literal"><span class="pre">test.c</span></tt></p>
<pre class="literal-block">
#include &lt;stdio.h&gt;
int main(int argc, char** argv)
{
    printf(&quot;Content-Type: text/html\n\n&lt;html&gt;Hello Trevor!&lt;/html&gt;\n&quot;);
    return 0;
}
</pre>
<p>You can compile it with:</p>
<pre class="literal-block">
/home/james/Desktop/openwrt-midge/staging_dir_mipsel/bin/mipsel-linux-uclibc-gcc -o test test.c
</pre>
<p><tt class="docutils literal"><span class="pre">mipsel-linux-uclibc-gcc</span></tt> is the equivalent of gcc on the Linux PC and it seems to be able to find the headers and libraries it needs. You can now copy the output to the USB memory stick in the <tt class="docutils literal"><span class="pre">www/cgi-bin</span></tt> directory and ensure it has executable permissions by running <tt class="docutils literal"><span class="pre">chmod</span> <span class="pre">755</span> <span class="pre">test</span></tt>. Mount the USB drive on the board again and start the HTTP server:</p>
<pre class="literal-block">
httpd -d /mnt/usbdisk/www/
</pre>
<p>Finally change the firewall to allow port 80 by editing <tt class="docutils literal"><span class="pre">/etc/network/fw</span></tt> to add this line under the line for port 22:</p>
<pre class="literal-block">
$ADD INPUT $ACCEPT $TCP --dport 80
</pre>
<p>and reload the firewall rules:</p>
<pre class="literal-block">
/etc/init.d/S60fw restart
</pre>
<p>Now if you visit <a class="reference" href="http:/">http:/</a>/&lt;your-board&#8217;s-ip&gt;/cgi-bin/test your CGI script should run to produce the message <tt class="docutils literal"><span class="pre">Hello</span> <span class="pre">Trevor!</span></tt>.</p>
</div>
<div class="section">
<h2><a id="bluetooth-not-working" name="bluetooth-not-working">Bluetooth (Not Working)</a></h2>
<p>Here&#8217;s what I ran to try to get bluetooth working:</p>
<pre class="literal-block">
ipkg update
ipkg install kmod-bluetooth bluez-libs bluez-utils picocom

insmod bluez
insmod l2cap
insmod hci_usb
insmod rfcomm
insmod sco
insmod hci_uart
</pre>
<p>When I plug in the bluetooth dongle (a modern Belkin one) I get this message which doesn&#8217;t bode well:</p>
<pre class="literal-block">
hub.c: new USB device adm5120-hcd-2, assigned address 3
usb.c: USB device 3 (vend/prod 0x50d/0x131) is not claimed by any active driver.
</pre>
<p>When I try to load the device the kernel crashes:</p>
<pre class="literal-block">
root&#64;midge:~# hciconfig hci0 up
Unable to handle kernel paging request at virtual address 00000000, epc == c007b6f8, ra == c007bc9c
Oops in fault.c::do_page_fault, line 206:
$0 : 00000000 10008400 a0a53180 a0a53190 801c6800 0001a780 0094b7c4 00000011
$8 : 801fe600 80109638 00000000 8014c9d0 00000519 10008400 00000000 00000001
$16: 00000000 801b89e0 0094b7c4 80514414 00000011 00000004 0001a780 0094b780
$24: ba2e8ba3 8015e5b4                   808be000 808bfd90 801b89e0 c007bc9c
Hi : 00000002
Lo : 00000002
epc   : c007b6f8    Not tainted
Status: 10008402
Cause : 10800008
PrId  : 0001800b
Process hciconfig (pid: 2201, stackpage=808be000)
Stack:    00000001 a0a7a2c0 80514414 00418280 80514454 00000004 00000000
 80514414 000000aa 801c6800 01000000 c007bc9c 801a81cc 809d3a40 ffffffbf
 801553c0 80514414 00000004 00000011 801c6800 801b89e0 10008400 a0a53180
 801c6800 00000000 a0a7a2c0 80514414 00418280 80030000 c007d2fc 8090903c
 809d3c20 0040f184 80f79520 809d3c20 80035214 802519a0 2ab9c200 809d3c20
 801a84e4 ...
Call Trace:   [&lt;c007bc9c&gt;] [&lt;80030000&gt;] [&lt;c007d2fc&gt;] [&lt;80035214&gt;] [&lt;c0130000&gt;]
 [&lt;80030000&gt;] [&lt;c0137778&gt;] [&lt;c012d388&gt;] [&lt;800448c9&gt;] [&lt;80049fb8&gt;] [&lt;80049fb8&gt;]
 [&lt;8009fa6c&gt;] [&lt;80009bc0&gt;] [&lt;80109224&gt;] [&lt;800448c9&gt;] [&lt;8005c80c&gt;]

Code: 00151880  00621821  8c700030 &lt;8e020000&gt; 04410005  3c028001  3c04c008  24424534  0040f809
Segmentation fault
</pre>
<p>Looks like I&#8217;ll have to save bluetooth for another day. Some clues though:</p>
<p><a class="reference" href="http://midge.vlad.org.ua/forum/viewtopic.php">http://midge.vlad.org.ua/forum/viewtopic.php</a>?t=461&amp;#038;sid=84bdddddb305bc7b25950c6975d95910
<a class="reference" href="http://forum.amilda.org/viewtopic.php?pid=649">http://forum.amilda.org/viewtopic.php?pid=649</a>
<a class="reference" href="http://midge.vlad.org.ua/forum/viewtopic.php">http://midge.vlad.org.ua/forum/viewtopic.php</a>?p=4357&amp;#038;sid=a4c2a20158761bbea68efab649f43e39</p>
</div>
<div class="section">
<h2><a id="links" name="links">Links</a></h2>
<p><a class="reference" href="http://www.maxim-ic.com/quick_view2.cfm/qv_pk/1068/ln/en">http://www.maxim-ic.com/quick_view2.cfm/qv_pk/1068/ln/en</a>
<a class="reference" href="http://midge.vlad.org.ua/wiki/article">http://midge.vlad.org.ua/wiki/article</a>
<a class="reference" href="http://downloads.openwrt.org/kamikaze/docs/openwrt.html">http://downloads.openwrt.org/kamikaze/docs/openwrt.html</a>
<a class="reference" href="http://forum.amilda.org/viewtopic.php?id=37">http://forum.amilda.org/viewtopic.php?id=37</a>
<a class="reference" href="http://midge.vlad.org.ua/wiki/flash_save">http://midge.vlad.org.ua/wiki/flash_save</a>
<a class="reference" href="http://www.student.tue.nl/Q/t.f.a.wilms/adm5120/">http://www.student.tue.nl/Q/t.f.a.wilms/adm5120/</a>
<a class="reference" href="http://midge.vlad.org.ua/wiki/usb">http://midge.vlad.org.ua/wiki/usb</a></p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://jimmyg.org/2008/02/10/embedded-linux-server-midge-and-the-edimax-br6104kp/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Flex Builder Linux Alpha 2 on Debian Etch</title>
		<link>http://jimmyg.org/2008/01/25/flex-builder-linux-alpha-2-on-debian-etch/</link>
		<comments>http://jimmyg.org/2008/01/25/flex-builder-linux-alpha-2-on-debian-etch/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 14:34:28 +0000</pubDate>
		<dc:creator>thejimmyg</dc:creator>
		
		<category><![CDATA[Web]]></category>

		<category><![CDATA[Software Releases]]></category>

		<category><![CDATA[Desktop Software]]></category>

		<category><![CDATA[Talks and Conferences]]></category>

		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://jimmyg.org/2008/01/25/flex-builder-linux-alpha-2-on-debian-etch/</guid>
		<description><![CDATA[


I went to the Flex User Group http://ria.meetup.com/7/calendar/6862191/?a=wm1_rsvp yesterday because AIR is one of the technologies I&#8217;m most excited about at the moment. I was slightly surprised by the demographic, I think I was expecting a crowd of open source developers, much like you&#8217;d find at a hack day or geek event but somehow they [...]]]></description>
			<content:encoded><![CDATA[
<div class="document">
<!-- -*- mode: rst -*- -->
<p>I went to the Flex User Group <a class="reference" href="http://ria.meetup.com/7/calendar/6862191/?a=wm1_rsvp">http://ria.meetup.com/7/calendar/6862191/?a=wm1_rsvp</a> yesterday because AIR is one of the technologies I&#8217;m most excited about at the moment. I was slightly surprised by the demographic, I think I was expecting a crowd of open source developers, much like you&#8217;d find at a hack day or geek event but somehow they didn&#8217;t seem as excited about the technologies Adobe are beginning to open up as I did. I wonder whether this is because most of the people who use Adobe products are less technical than the average person you might see at other events and therefore less interested in the new coding opportunities Flex and Air bring.</p>
<p>I got the slight impression that some people were just there for the free beer provided by Adobe (although maybe that&#8217;s just because I was sitting near the back by the bar) and others (including myself probably) had a feeling of &quot;why should I do Adobe the favour of switching to flex&quot;. I think Adobe&#8217;s answer might be along the lines of &quot;we&#8217;re doing enoughm just look at the numbers and if you don&#8217;t want to take advantage of it that&#8217;s up to you&quot; so some of the questions seemed slightly hostile, but maybe I&#8217;m reading too much into it and applying my views to my impression of everyone else&#8217;s!</p>
<p>I was also slightly surprised by some of the attitudes of the speakers who made frequent references to a designer/developer divide saying things like &quot;you&#8217;ll only be impressed with that if you are a developer&quot;. Maybe the audience for Adobe products does feature this divide but it surprised me nonetheless and I was surprised it was something the speakers wanted to encourage.</p>
<p>Anyway, despite the above observations I did find the event very interesting and am pleased Adobe are moving towards being more open. One question I asked in the Q&amp;#038;A section was &quot;What are the timescales for AIR on Linux&quot;. The answer I got back was &quot;soon&quot; and it appears James Ward is as keen to get AIR on Linux as I am as it is his primary desktop too. Still, I pointed out that if Adobe wants to attract open source developers a Linux port would be pretty essential. Let&#8217;s hope it happens &quot;soon&quot; as James promised because developing AIR on FlexBuilder on VMWare is very painful! James also suggested I try the Flex Builder Alpha for Linux so here goes&#8230;</p>
<p>First install Java. To do this you&#8217;ll need to edit your apt sources list to use the <tt class="docutils literal"><span class="pre">non-free</span></tt> repository:</p>
<pre class="literal-block">
sudo vim /etc/apt/sources.list
</pre>
<p>Mine looks like this:</p>
<pre class="literal-block">
deb http://ftp.uk.debian.org/debian/ etch main non-free
deb-src http://ftp.uk.debian.org/debian/ etch main non-free

deb http://security.debian.org/ etch/updates main contrib
deb-src http://security.debian.org/ etch/updates main contrib
</pre>
<p>Next install Java 5:</p>
<pre class="literal-block">
sudo apt-get update
sudo apt-get install sun-java5-jdk
</pre>
<p>(You can probably get away with the JRE if you prefer, in which case install <tt class="docutils literal"><span class="pre">sun-java5-jre</span></tt> instead).</p>
<p>You&#8217;ll have to agree to the license:</p>
<pre class="literal-block">
Package configuration

 ┌───────────────────────┤ Configuring sun-java5-bin ├───────────────────────┐
 │                                                                           │
 │ Operating System Distributor License for Java v1.1 (DLJ)                  ↑
 │                                                                           ▮
 │ Operating System Distributor License for Java version 1.1 (DLJ)           ▒
 │                                                                           ▒
 │ SUN MICROSYSTEMS, INC. (&quot;SUN&quot;) IS WILLING TO LICENSE THE JAVA PLATFORM    ▒
 │ STANDARD EDITION DEVELOPER KIT (&quot;JDK&quot; - THE &quot;SOFTWARE&quot;) TO YOU ONLY UPON  ▒
 │ THE CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS LICENSE  ▒
 │ AGREEMENT (THE &quot;AGREEMENT&quot;).  PLEASE READ THE AGREEMENT CAREFULLY.  BY    ▒
 │ INSTALLING, USING, OR DISTRIBUTING THIS SOFTWARE, YOU ACCEPT ALL OF THE   ▒
 │ TERMS OF THE AGREEMENT.                                                   ▒
 │                                                                           ▒
 │ 1.  DEFINITIONS. &quot;Software&quot; means the code identified above in binary     ▒
 │     form, any other machine readable materials including, but not         ▒
 │     limited to, libraries, source files, header files, and data files),   ↓
 │
 │                                  &lt;Ok&gt;
 │                                                                           │
 └───────────────────────────────────────────────────────────────────────────┘
</pre>
<p>Test Java is working by typing <tt class="docutils literal"><span class="pre">java</span> <span class="pre">-version</span></tt> at the command line. You should see something like this:</p>
<pre class="literal-block">
$ java -version
java version &quot;1.5.0_10&quot;
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
Java HotSpot(TM) Client VM (build 1.5.0_10-b03, mixed mode, sharing)
</pre>
<p>Next you&#8217;ll need Eclipse 3.3 or higher. Go to <a class="reference" href="http://www.eclipse.org">http://www.eclipse.org</a> and download the Linux version (I chose Eclipse IDE for Java EE Developers). Extract the files and launch the program:</p>
<pre class="literal-block">
tar zxfv eclipse-jee-europa-fall2-linux-gtk.tar.gz
cd eclipse
./eclipse
</pre>
<p>You&#8217;ll be asked where you want to create a workspace. I stuck with the default of <tt class="docutils literal"><span class="pre">/home/james/workspace</span></tt>. Eventually Eclipse loads. Once you are happy it is working you should exit it and you can finally you can get around to actually installing Flex Builder.</p>
<p>Download the alpha 2 from the Adobe website:  <a class="reference" href="http://labs.adobe.com/downloads/flexbuilder_linux.html">http://labs.adobe.com/downloads/flexbuilder_linux.html</a> then run these commands:</p>
<pre class="literal-block">
chmod 755 flexbuilder_linux_install_a2_121807.bin
./flexbuilder_linux_install_a2_121807.bin
</pre>
<p>You&#8217;ll see the following output:</p>
<pre class="literal-block">
Preparing to install...
Extracting the installation resources from the installer archive...
Configuring the installer for this system's environment...

Launching installer...
</pre>
<p>Then the installer launches and after a few screens you are asked to choose your eclipse folder. This will be the location of the <tt class="docutils literal"><span class="pre">eclipse</span></tt> folder you just extracted. You&#8217;ll also be asked to install Flash Player 9 and you should choose to do so, even if you already have it because this version has debugging built-in.</p>
<p>The installation finishes with some errors which aren&#8217;t displayed. Instead you are asked to view the installation log but not told where this is and I couldn&#8217;t find it! The installer doesn&#8217;t tell you how to launch Flex Builder either, but it turns out you just load Eclipse again and Choose Help-&gt;Flex Builder whereupon you are asked to enter a license key and told you only have 65 days remaining. After all that effort it would have been nice to know this was only a 65 day trial if it really is. After clicking OK nothing happened (didn&#8217;t seem to be able to connect to flexstart.adobe.com) so I exited and tried again.</p>
<p>To get started you need to create a new project. Chose <tt class="docutils literal"><span class="pre">Project&#8230;</span></tt> from the <tt class="docutils literal"><span class="pre">File</span></tt> menu and choose a Flex Builder project. There is no support for AIR or BlazeDS so you can only create Flex applications targeting Flash Player 9 but this seems like a good start.</p>
<p>Here&#8217;s a screenshot:</p>
<p><a class="reference" href="http://jimmyg.org/wp-content/uploads/2008/01/flex_builder_running.png">http://jimmyg.org/wp-content/uploads/2008/01/flex_builder_running.png</a></p>
<p>So I think we can add Debian Etch to the list of platforms where Flex Builder works. Good work Adobe and keep it up!</p>
<p>P.S. Was that <a class="reference" href="http://news.bbc.co.uk/1/hi/business/5238684.stm">Evan Davis</a> I spotted at the event?
P.P.S Submit bugs!</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://jimmyg.org/2008/01/25/flex-builder-linux-alpha-2-on-debian-etch/feed/</wfw:commentRss>
		</item>
		<item>
		<title>gOS 2.0 Rocket Review</title>
		<link>http://jimmyg.org/2008/01/09/gos-20-rocket-screenshots/</link>
		<comments>http://jimmyg.org/2008/01/09/gos-20-rocket-screenshots/#comments</comments>
		<pubDate>Wed, 09 Jan 2008 11:38:37 +0000</pubDate>
		<dc:creator>thejimmyg</dc:creator>
		
		<category><![CDATA[Web]]></category>

		<category><![CDATA[Software Releases]]></category>

		<category><![CDATA[Desktop Software]]></category>

		<guid isPermaLink="false">http://jimmyg.org/2008/01/09/gos-20-rocket-screenshots/</guid>
		<description><![CDATA[gOS Rocket is the second release of Good OS LLC&#8217;s operating system nicknamed the Google OS because rather than relying on traditional desktop applications, gOS is set up for you to work online instead and has icons launching many of Google&#8217;s applications placed directly on the desktop.
Many tech sites are making a big deal of [...]]]></description>
			<content:encoded><![CDATA[<p>gOS Rocket is the second release of Good OS LLC&#8217;s operating system nicknamed the Google OS because rather than relying on traditional desktop applications, gOS is set up for you to work online instead and has icons launching many of Google&#8217;s applications placed directly on the desktop.</p>
<p>Many tech sites are making a big deal of this talking about how gOS allows the user to move their applications into the cloud, a name used for applications which run over many servers on the internet. In reality gOS is nothing more than a copy of Ubuntu with a customised enlightenment install instead of Gnome, and released under a more restrictive license than the original Ubuntu. Despite this obvious fact I can&#8217;t help but get very excited gOS myself because the fact gPCs are selling in large quantities means this OS does mark a significant shift in the way ordinary consumers of technology are thinking about what an application is.</p>
<p>Here&#8217;s a quick overview of the install as well as a few screenshots. I&#8217;d encourage you to download and burn it yourself if you are interested though. Installation is easy enough. You use bittorrent to download an ISO image which you burn to CD. After rebooting gOS live loads which lets you try the operating system without installing it and without it changing any settings on your computer.</p>
<p>As gOS boots you see a green screen with the gOS logo and a bar moving from left to right. A nice touch is that the bar moves with sinusoidal motion, slowing down as it reaches each end as if you are actually watching it side on as it moves around in a circle. You can see this release is still a bit rough around the edges though because after the previous screen disappears lots of usage messages are printed for each line of text output during the boot because some command is being used with the wrong arguments.</p>
<p>After a minute or two gOS finishes loading (it would be a lot quicker if you installed it rather than running from CD-ROM) and without clicking any buttons or having to sign in you arrive at the desktop:</p>
<p><a href='http://jimmyg.org/wp-content/uploads/2008/01/gos-20-rocket-001.png' title='gOS Desktop'><img src='http://jimmyg.org/wp-content/uploads/2008/01/gos-20-rocket-001.thumbnail.png' alt='gOS Desktop' /></a></p>
<p>The first thing you notice is the new application launcher at the bottom of the screen. This now resembles the Mac OS X Tiger dock even more closely with the icons growing larger as you move the mouse over them and extra applications you lauch appearing on the left of the bar. It does feel rather slick.</p>
<p><a href='http://jimmyg.org/wp-content/uploads/2008/01/gos-20-rocket-002.png' title='gOS Dock'><img src='http://jimmyg.org/wp-content/uploads/2008/01/gos-20-rocket-002.thumbnail.png' alt='gOS Dock' /></a></p>
<p>Here I&#8217;ve got my mouse over Google news and have both Firefox and the Gimp running (their icons are on the right).</p>
<p>The icons on the dock are:</p>
<p>Firefox Web Browser<br />
GMail<br />
GTalk<br />
Google Calendar<br />
Google Docs and Spreadsheets<br />
Google Reader<br />
Google Maps<br />
Google News<br />
Google Finance<br />
Google Product Search<br />
gBooth<br />
YouTube<br />
Blogger<br />
Facebook<br />
Wikipedia<br />
Meebo<br />
Skype<br />
Xine Movie Player<br />
Rhythmbox Music Player<br />
Box.net<br />
Tech Support</p>
<p>The gOS-specific applications you may not have heard of are gBooth, Box.net and Tech Support. gBooth is supposed to let you use a web cam but clicking the icon gives this error page on a Plesk-hosted website which hasn&#8217;t been configured yet. So that doesn&#8217;t work at all (not too great a start):</p>
<p><a href='http://jimmyg.org/wp-content/uploads/2008/01/gos-20-rocket-004.png' title='gos-20-rocket-004.png'><img src='http://jimmyg.org/wp-content/uploads/2008/01/gos-20-rocket-004.thumbnail.png' alt='gos-20-rocket-004.png' /></a></p>
<p>The Tech Support icon loads <a href="http://faqly.com">faqly.com</a> in Firefox which you can visit from any browser and is just a simple question and answer site which isn&#8217;t too interesting.</p>
<p>The box.net icon is more interesting and loads this in Firefox:</p>
<p><a href='http://jimmyg.org/wp-content/uploads/2008/01/gos-20-rocket-005.png' title='gos-20-rocket-005.png'><img src='http://jimmyg.org/wp-content/uploads/2008/01/gos-20-rocket-005.thumbnail.png' alt='gos-20-rocket-005.png' /></a></p>
<p>When you click register as individual you are asked to edit your credit card details but it states you will only be charged the $7.95 per month after the 14 day trial period. You have to remember to cancel your trial or you will be charged.</p>
<p><a href='http://jimmyg.org/wp-content/uploads/2008/01/gos-20-rocket-006.png' title='gos-20-rocket-006.png'><img src='http://jimmyg.org/wp-content/uploads/2008/01/gos-20-rocket-006.thumbnail.png' alt='gos-20-rocket-006.png' /></a></p>
<p>Box.net is a nice service but there is no integration with the rest of the gOS desktop so there is no advantage of using it with gOS rather than on any operating system with a web browser.</p>
<p>One of the main features of this 2.0 version of gOS was supposed to be the inclusion of Google Gears to enable offline access to certain web applications. This isn&#8217;t actually installed for you when you load Firefox you are shown the screen below for you to install gears yourself. The other link (supposed to be a list of gears applications) just shows an untitled blank page at the moment.</p>
<p><a href='http://jimmyg.org/wp-content/uploads/2008/01/gos-20-rocket-003.png' title='gos-20-rocket-003.png'><img src='http://jimmyg.org/wp-content/uploads/2008/01/gos-20-rocket-003.thumbnail.png' alt='gos-20-rocket-003.png' /></a></p>
<p>Although the gears installation routine all completes successfully and the <tt>Google Gears Settings</tt> option appears on the <tt>Tools</tt> menu, gears doesn&#8217;t actually work. I&#8217;ve tried re-installing twice so I&#8217;d consider this a bug. SInce it was supposed to be a major feature of this release it is a bit disappointing. </p>
<p>Until gOS actually integrates features into the desktop it will be nothing more than a slightly flaky Linux install with some links to web pages. The concept is a good one but the implementation doesn&#8217;t live up to the hype. Perhaps the most impressive thing about gOS isn&#8217;t gOS itself, but rather the fact that the free web applications it relies on have evolved to the stage where they genuinely can be used to replace desktop applications.</p>
<p>Despite the slightly negative comments about the beta so far I&#8217;m still going to be watching the releases with interest as gOS really does represent the future and it won&#8217;t be too many years before I am using it or something similar as my main desktop.</p>
]]></content:encoded>
			<wfw:commentRss>http://jimmyg.org/2008/01/09/gos-20-rocket-screenshots/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Streaming File Upload with Erlang and Mochiweb Multipart Post</title>
		<link>http://jimmyg.org/2007/12/31/multipart-post-with-erlang-and-mochiweb/</link>
		<comments>http://jimmyg.org/2007/12/31/multipart-post-with-erlang-and-mochiweb/#comments</comments>
		<pubDate>Mon, 31 Dec 2007 18:13:29 +0000</pubDate>
		<dc:creator>thejimmyg</dc:creator>
		
		<category><![CDATA[Web]]></category>

		<category><![CDATA[Erlang]]></category>

		<guid isPermaLink="false">http://jimmyg.org/2007/12/31/multipart-post-with-erlang-and-mochiweb/</guid>
		<description><![CDATA[


Here&#8217;s one way to set up a simple Mochiweb server to handle a file upload using Erlang.
On Debian you&#8217;ll need to install the following:

sudo apt-get install build-essential libncurses-dev libssl-dev m4 subversion

(I&#8217;ve also got autoconf, automake and libgd-dev so you might need those too).
First install the latest version of Erlang:

wget http://erlang.org/download/otp_src_R12B-0.tar.gz
tar zxfv otp_src_R12B-0.tar.gz
cd otp_src_R12B-0

I already have [...]]]></description>
			<content:encoded><![CDATA[
<div class="document">
<!-- -*- mode: rst -*- -->
<p>Here&#8217;s one way to set up a simple Mochiweb server to handle a file upload using Erlang.</p>
<p>On Debian you&#8217;ll need to install the following:</p>
<pre class="literal-block">
sudo apt-get install build-essential libncurses-dev libssl-dev m4 subversion
</pre>
<p>(I&#8217;ve also got autoconf, automake and libgd-dev so you might need those too).</p>
<p>First install the latest version of Erlang:</p>
<pre class="literal-block">
wget http://erlang.org/download/otp_src_R12B-0.tar.gz
tar zxfv otp_src_R12B-0.tar.gz
cd otp_src_R12B-0
</pre>
<p>I already have Erlang installed as part of the Debian distribution so I install this version to my home directory so it doesn&#8217;t conflict:</p>
<pre class="literal-block">
./configure --prefix=/home/james
</pre>
<p>You&#8217;ll get an error similar to this but we won&#8217;t be using these features so we can egnore the warning:</p>
<pre class="literal-block">
*********************************************************************
**********************  APPLICATIONS DISABLED  **********************
*********************************************************************

jinterface     : No Java compiler found
odbc           : No odbc library found
percept        : libgd not working

*********************************************************************
</pre>
<p>Now make and install Erlang:</p>
<pre class="literal-block">
make
make install
</pre>
<p>This takes about 3 minutes to complete on a fairly modern dual core server.</p>
<p>You&#8217;ll probably want the html and man pages too:</p>
<pre class="literal-block">
cd /home/james/lib/erlang
wget http://erlang.org/download/otp_doc_man_R12B-0.tar.gz
wget http://erlang.org/download/otp_doc_html_R12B-0.tar.gz
gunzip -c otp_doc_man_R12B-0.tar.gz | tar xf -
gunzip -c otp_doc_html_R12B-0.tar.gz | tar xf -
rm otp_doc_man_R12B-0.tar.gz otp_doc_html_R12B-0.tar.gz
</pre>
<p>Now that Erlang is set up get the latest trunk of Mochiweb:</p>
<pre class="literal-block">
svn checkout http://mochiweb.googlecode.com/svn/trunk/ mochiweb
</pre>
<p>You&#8217;ll need to compile it:</p>
<pre class="literal-block">
export PATH=/home/james/bin:/home/james/lib:$PATH
cd mochiweb
make
</pre>
<p>Now setup a project called <tt class="docutils literal"><span class="pre">file_upload</span></tt> like this:</p>
<pre class="literal-block">
cd scripts
chmod a+x new_mochiweb.erl
./new_mochiweb.erl file_upload /home/james/
</pre>
<p>Compile it and run it:</p>
<pre class="literal-block">
make
./start-dev.sh
</pre>
<p>The server will be accessible on port 8080. You can stop it by pressing <tt class="docutils literal"><span class="pre">Ctrl+c</span></tt> and then typing the letter <tt class="docutils literal"><span class="pre">a</span></tt> followed by return. Try visiting <a class="reference" href="http://yourserver.com:8000/index.html">http://yourserver.com:8000/index.html</a> and you should see the message <tt class="docutils literal"><span class="pre">MochiWeb</span> <span class="pre">running.</span></tt>.</p>
<p>You now need to modify the <tt class="docutils literal"><span class="pre">src/file_upload_web.erl</span></tt> file for our file upload application. Underneath the <tt class="docutils literal"><span class="pre">-export()</span></tt> line near the top add this:</p>
<pre class="literal-block">
-record(state, {filename, file}).

callback(Next, State) -&gt;
    case Next of
        {headers, Headers} -&gt;
            % Find out if it is a file
            [ContentDisposition|_] = Headers,
            NewState = case ContentDisposition of
                {&quot;content-disposition&quot;, {&quot;form-data&quot;,[{&quot;name&quot;,_},
                    {&quot;filename&quot;,Filename}]}} -&gt;
                    #state{filename=&quot;/tmp/&quot;++Filename};
                _ -&gt;
                    State
            end,
            fun(N) -&gt; callback(N, NewState) end;
        {body, Data} -&gt;
            if  State#state.filename =/= undefined -&gt;
                if State#state.file =/= undefined -&gt;
                    file:write(State#state.file, Data),
                    NewState = State;
                true -&gt;
                    case file:open(State#state.filename, [raw,write]) of
                        {ok, File} -&gt;
                            file:write(File, Data),
                            NewState = State#state{file=File};
                        {error, Error} -&gt;
                            io:format(
                                &quot;Couldn't open ~p for writing, error: ~p~n&quot;,
                                [State#state.filename, Error]),
                            NewState=State,
                            exit(could_not_open_file_for_writing)
                    end
                end;
            true -&gt;
                NewState = State
            end,
            fun(N) -&gt; callback(N, NewState) end;
         body_end -&gt;
            if State#state.file =/= undefined -&gt;
                file:close(State#state.file);
            true -&gt;
                ok
            end,
            fun(N) -&gt; callback(N, #state{}) end;
         _ -&gt;
            fun(N) -&gt; callback(N, State) end
    end.
</pre>
<p>Then replace the <tt class="docutils literal"><span class="pre">loop</span></tt> function with this:</p>
<pre class="literal-block">
loop(Req, _) -&gt;
    case Req:get(method) of
        Method when Method =:= 'GET'; Method =:= 'HEAD' -&gt;
         Req:ok({&quot;text/html&quot;, [], &lt;&lt;&quot;&lt;html&gt;&lt;body&gt;&lt;h1&gt;File Upload&lt;/h1&gt;
&lt;form enctype=\&quot;multipart/form-data\&quot; action=\&quot;/\&quot; method=\&quot;post\&quot;&gt;
&lt;label for=\&quot;file\&quot;&gt;File:&lt;/label&gt;
&lt;input type=\&quot;file\&quot; name=\&quot;file\&quot; id=\&quot;file\&quot;/&gt;
&lt;input type=\&quot;submit\&quot; name=\&quot;upload\&quot; value=\&quot;Upload\&quot; /&gt;
&lt;/form&gt;
&lt;/body&gt;&lt;/html&gt;&quot;&gt;&gt;});
        'POST' -&gt;
                Callback = fun(N) -&gt; callback(N, #state{}) end,
        mochiweb_multipart:parse_multipart_request(Req, Callback),
        Req:ok({&quot;text/html&quot;, [], &lt;&lt;&quot;&lt;html&gt;&lt;body&gt;&lt;h1&gt;File Upload&lt;/h1&gt;
&lt;p&gt;Uploaded successfully.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;&quot;&gt;&gt;});
        _ -&gt;
            Req:respond({501, [], []})
    end.
</pre>
<p>You&#8217;ll need to build the new code by running <tt class="docutils literal"><span class="pre">make</span></tt> again in the <tt class="docutils literal"><span class="pre">file_upload</span></tt> directory. The server should automatically restart with the message <tt class="docutils literal"><span class="pre">Reloading</span> <span class="pre">file_upload_web</span> <span class="pre">&#8230;</span> <span class="pre">ok.</span></tt> - if it doesn&#8217;t you&#8217;ll need to manually stop and start the server.</p>
<p>If you run the application again you should now have a simple file upload application which saves files to <tt class="docutils literal"><span class="pre">/tmp</span></tt>.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://jimmyg.org/2007/12/31/multipart-post-with-erlang-and-mochiweb/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Nginx Proxying to Pylons with SSL on Debian Etch</title>
		<link>http://jimmyg.org/2007/12/07/nginx-proxying-to-pylons-with-ssl-on-debian-etch/</link>
		<comments>http://jimmyg.org/2007/12/07/nginx-proxying-to-pylons-with-ssl-on-debian-etch/#comments</comments>
		<pubDate>Fri, 07 Dec 2007 15:06:01 +0000</pubDate>
		<dc:creator>thejimmyg</dc:creator>
		
		<category><![CDATA[Pylons]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[Debian]]></category>

		<category><![CDATA[Hosting]]></category>

		<guid isPermaLink="false">http://jimmyg.org/2007/12/07/nginx-proxying-to-pylons-with-ssl-on-debian-etch/</guid>
		<description><![CDATA[


The easy way to install Nginx is like this:

sudo aptitude install nginx

The problem is that this installs an old version (0.4) and doesn&#8217;t have SSL support built in. Nginx is designed to be super fast so and modules need to be compiled in manually. This means you need remove the Nginx package if you want [...]]]></description>
			<content:encoded><![CDATA[
<div class="document">
<!-- -*- mode: rst -*- -->
<p>The easy way to install Nginx is like this:</p>
<pre class="literal-block">
sudo aptitude install nginx
</pre>
<p>The problem is that this installs an old version (0.4) and doesn&#8217;t have SSL support built in. Nginx is designed to be super fast so and modules need to be compiled in manually. This means you need remove the Nginx package if you want SSL support.</p>
<p>If you try <tt class="docutils literal"><span class="pre">sudo</span> <span class="pre">apt-get</span> <span class="pre">remove</span> <span class="pre">&#8211;purge</span> <span class="pre">nginx</span></tt> you get this error:</p>
<pre class="literal-block">
Reading package lists... Done
Building dependency tree... Done
The following packages will be REMOVED
  nginx*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
Need to get 0B of archives.
After unpacking 524kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 26362 files and directories currently installed.)
Removing nginx ...
Stopping nginx: invoke-rc.d: initscript nginx, action &quot;stop&quot; failed.
dpkg: error processing nginx (--purge):
 subprocess pre-removal script returned error exit status 1
Starting nginx: 2007/12/07 14:45:03 [emerg] 29441#0: unknown directive &quot;ssl&quot; in /etc/nginx/nginx.conf:30
invoke-rc.d: initscript nginx, action &quot;start&quot; failed.
dpkg: error while cleaning up:
 subprocess post-installation script returned error exit status 1
Errors were encountered while processing:
 nginx
E: Sub-process /usr/bin/dpkg returned an error code (1)
</pre>
<p>The solution is to edit <tt class="docutils literal"><span class="pre">/var/lib/dpkg/info/nginx.prerm</span></tt> and comment out the line with <tt class="docutils literal"><span class="pre">invoke-rc.d</span></tt> which gives the stop statement for nginx. If you run the command again it will remove successfully, purging your <tt class="docutils literal"><span class="pre">nginx.conf</span></tt> config file too. If this isn&#8217;t what you want make a backup first.</p>
<p>You can then remove your logs with:</p>
<pre class="literal-block">
sudo rm -rf /var/log/nginx/
</pre>
<p>Now to install Nginx 0.6 from source. Fisrt you will need some build tools:</p>
<pre class="literal-block">
sudo aptitude install build-essential
</pre>
<p>Then we need some libraries:</p>
<pre class="literal-block">
sudo aptitude install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev
</pre>
<p>Check what the latest version is at <a class="reference" href="http://nginx.net">http://nginx.net</a>. At the time of writing the latest stable version is 0.5.33 so download that:</p>
<pre class="literal-block">
wget http://sysoev.ru/nginx/nginx-0.5.33.tar.gz
tar zxfv nginx-0.5.33.tar.gz
cd nginx-0.5.33
</pre>
<p>Now you are ready to compile Nginx. As mentioned earlier many of the options are set at compile time so have a look at the <a class="reference" href="http://wiki.codemongers.com/NginxInstallOptions">Compile Time Options</a> page and decide which you need. We are going to set two options. The first is:</p>
<pre class="literal-block">
--with-http_ssl_module
</pre>
<p>This enables the SSL module. The second option is to customise where Nginx is installed to. The default is <tt class="docutils literal"><span class="pre">/usr/local/nginx</span></tt> but this means the Nginx binary will be <tt class="docutils literal"><span class="pre">/usr/local/nginx/sbin/nginx</span></tt> which isn&#8217;t on the PATH. A better place is <tt class="docutils literal"><span class="pre">/usr/local/sbin</span></tt> where it is easily accessible by root or by users with <tt class="docutils literal"><span class="pre">sudo</span></tt> access:</p>
<pre class="literal-block">
--sbin-path=/usr/local/sbin
</pre>
<p>Now we are ready to configure:</p>
<pre class="literal-block">
./configure --sbin-path=/usr/local/sbin --with-http_ssl_module
</pre>
<p>There is a useful configuration summary:</p>
<pre class="literal-block">
nginx path prefix: &quot;/usr/local/nginx&quot;
nginx binary file: &quot;/usr/local/sbin&quot;
nginx configuration file: &quot;/usr/local/nginx/conf/nginx.conf&quot;
nginx pid file: &quot;/usr/local/nginx/logs/nginx.pid&quot;
nginx error log file: &quot;/usr/local/nginx/logs/error.log&quot;
nginx http access log file: &quot;/usr/local/nginx/logs/access.log&quot;
nginx http client request body temporary files: &quot;/usr/local/nginx/client_body_temp&quot;
nginx http proxy temporary files: &quot;/usr/local/nginx/proxy_temp&quot;
nginx http fastcgi temporary files: &quot;/usr/local/nginx/fastcgi_temp&quot;
</pre>
<p>Then compile and install:</p>
<pre class="literal-block">
make
sudo make install
</pre>
<p>The first thing I do next is create a backup of the original file:</p>
<pre class="literal-block">
sudo cp /usr/local/nginx/conf/nginx.conf  /usr/local/nginx/conf/nginx.conf.bak
</pre>
<p>Then start the server:</p>
<pre class="literal-block">
sudo /usr/local/sbin/nginx
</pre>
<p>If you visit <a class="reference" href="http://yourdomain.com">http://yourdomain.com</a> you should see the Nginx welcome message <tt class="docutils literal"><span class="pre">Welcome</span> <span class="pre">to</span> <span class="pre">nginx!</span></tt>. If you don&#8217;t it might be because you have another server such as Apache running.</p>
<p>To kill the server you can use the pid file:</p>
<pre class="literal-block">
sudo kill `cat /usr/local/nginx/logs/nginx.pid`
</pre>
<p>Notice this uses the ` character (normally underneath Esc) not the &#8216; character. Obviously it is nicer to have an <tt class="docutils literal"><span class="pre">init.d</span></tt> setup so you can start and stop Nginx the same way as Apache and other servers. We&#8217;ll use the script from Slicehost which is itself based on the Debian package:</p>
<pre class="literal-block">
wget http://articles.slicehost.com/assets/2007/10/19/nginx
sudo chmod +x nginx
sudo mv nginx /etc/init.d
</pre>
<p>Now we can add this script to the runlevels:</p>
<pre class="literal-block">
sudo /usr/sbin/update-rc.d -f nginx defaults
</pre>
<p>Now you can start, stop and restart Nginx with these commands as normal:</p>
<pre class="literal-block">
sudo /etc/init.d/nginx start
sudo /etc/init.d/nginx stop
sudo /etc/init.d/nginx restart
</pre>
<p>Now let&#8217;s setup Nginx to proxy to a Pylons application. Replace these lines in <tt class="docutils literal"><span class="pre">/usr/local/nginx/conf/nginx.conf</span></tt>:</p>
<pre class="literal-block">
location / {
    root   html;
    index  index.html index.htm;
}
</pre>
<p>with these:</p>
<pre class="literal-block">
location / {
    proxy_redirect          off;
    proxy_set_header        Host $host;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        X-Forwarded-Host $host;
    proxy_set_header        X-Forwarded-Port $server_port;
    client_max_body_size    10m;
    client_body_buffer_size 128k;
    proxy_connect_timeout   90;
    proxy_send_timeout      90;
    proxy_read_timeout      90;
    proxy_buffer_size       4k;
    proxy_buffers           4 32k;
    proxy_busy_buffers_size 64k;
    proxy_temp_file_write_size 64k;
    proxy_pass  http://127.0.0.1:5000;
    proxy_redirect  default;
}
</pre>
<p><em>Update:</em> Added  X-Forwarded-Port and X-Forwarded-Host to the above since I use them both so much.</p>
<p>This will proxy all requests to another server running on port 5000, for example a running Pylons application. To test this you should start your Pylons application (making sure debug is set to false if this is a production setup):</p>
<pre class="literal-block">
paster serve development.ini
</pre>
<p>Now restart Nginx:</p>
<pre class="literal-block">
sudo /etc/init.d/nginx restart
</pre>
<p>and f you visit the site you should see your Pylons application.</p>
<p>Now for the SSL:</p>
<pre class="literal-block">
sudo aptitude install openssh-server
</pre>
<p>First create a the key, pem and certificate files:</p>
<pre class="literal-block">
openssl genrsa 1024 &gt; host.key
chmod 400 host.key
openssl req -new -x509 -nodes -sha1 -days 365 -key host.key &gt; host.cert
cat host.cert host.key &gt; host.pem
chmod 400 host.pem
</pre>
<p>Make sure the <tt class="docutils literal"><span class="pre">Common</span> <span class="pre">Name</span></tt> is the same as the domain name the certificate is for.</p>
<p>Now we need to setup SSL on Nginx. This is described in detail <a class="reference" href="http://wiki.codemongers.com/NginxHttpSslModule?highlight=%28ssl%29">here</a> but it really just requires making the server section look like this:</p>
<pre class="literal-block">
worker_processes 1;
http {
    ...
    server {
        listen               443;
        ssl                  on;
        ssl_certificate      /path/to/host.pem;
        ssl_certificate_key  /path/to/host.key;
        keepalive_timeout    70;
    }
}
</pre>
<p>Restart Nginx again:</p>
<pre class="literal-block">
sudo /etc/init.d/nginx restart
</pre>
<p>Now if you visit <a class="reference" href="http://yourdomain.com">http://yourdomain.com</a> you&#8217;ll get no response but if you visit <a class="reference" href="https://yourdomain.com">https://yourdomain.com</a> you&#8217;ll get a certificate warning because the SSL certificate is not signed by a certificate authority. Click OK and you will have access to your application.</p>
<p>The final part of the setup is to setup a static file which redirects from the http version of the site to the https version. The easy way to do this is by setting up another server listening on port 80 and creating an error 404 page which redirects to the https version. Add this to the nginx config just before the existing server:</p>
<pre class="literal-block">
server {
    listen 80;
    server_name  yourdomain.com;
    error_page  404              /404.html;
    location = /404.html {
        root   /path/to/directory/containing/404/doc/;
    }
}
</pre>
<p>Then create a <tt class="docutils literal"><span class="pre">404.html</span></tt> file which looks something like this but adjusted for your URL instead of <tt class="docutils literal"><span class="pre">yourdomain.com</span></tt>:</p>
<pre class="literal-block">
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;refresh&quot; content=&quot;2;URL=https://yourdomain.com/&quot;&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;h2&gt;Redirecting&lt;/h2&gt;
&lt;p&gt;You are being redirected to the &lt;a href=&quot;https://yourdomain.com/&quot;&gt;secure version of this site.&lt;/a&gt;&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Then restart Nginx again.</p>
<p>You should now have a secure Pylons app on the https port and a redirect page on the http port.</p>
<p>Further Reading:</p>
<p><a class="reference" href="http://articles.slicehost.com/2007/10/19/debian-etch-installing-nginx">http://articles.slicehost.com/2007/10/19/debian-etch-installing-nginx</a>
<a class="reference" href="http://ubuntuforums.org/showthread.php?t=453053">http://ubuntuforums.org/showthread.php?t=453053</a>
<a class="reference" href="http://sudhanshuraheja.com/2007/09/remove-nginx-from-ubuntu-fiesty-fawn.html">http://sudhanshuraheja.com/2007/09/remove-nginx-from-ubuntu-fiesty-fawn.html</a>
<a class="reference" href="http://www.rkblog.rk.edu.pl/w/p/pylons-and-nginx/">http://www.rkblog.rk.edu.pl/w/p/pylons-and-nginx/</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://jimmyg.org/2007/12/07/nginx-proxying-to-pylons-with-ssl-on-debian-etch/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
