<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <id>http://andrewho.co.uk/feeds/weblog.xml</id>
    <title type="text">Andrew Ho &#8250; Weblog</title>
    <updated>2010-01-24T23:06:14+00:00</updated>
    <author>
        <name>Andrew Ho</name>
        <uri>http://andrewho.co.uk/</uri>
    </author>
    <link rel="alternate" type="text/html" href="http://andrewho.co.uk/weblog/list" />
    <link rel="self" type="application/atom+xml" href="http://andrewho.co.uk/feeds/weblog.xml" />
    <rights>Creative Commons Licence: Attribution-Noncommercial-Share Alike 2.0</rights>

    <entry>
        <id>tag:andrewho.co.uk,2010-01-24:/weblog/read/2010-n-52-week-four</id>
        <title type="text">2010 n/52: Week four</title>
        <updated>2010-01-24T23:06:14+00:00</updated>
        <author>
            <name>Andrew Ho</name>
            <uri>http://andrewho.co.uk/</uri>
        </author>
        <link rel="alternate" type="text/html" href="http://andrewho.co.uk/weblog/read/2010-n-52-week-four" />
        <content type="xhtml" xml:base="http://andrewho.co.uk/" xml:lang="en-GB">
            <div xmlns="http://www.w3.org/1999/xhtml">
                	<p><a href="http://www.flickr.com/photos/andrewlkho/4302046208/in/set-72157623130355734/"><img src="/files/DSC_5582.jpg" title="2010 n/52: Week four" alt="2010 n/52: Week four" width="500" height="330" /></a></p>

	<p>Cassie likes feet.  There&#8217;s no getting around this rather odd penchant of hers for all things feety.  When we lived in our previous house she wasn&#8217;t allowed to access the area where we kept our shoes (and, by association, socks stuffed inside shoes).  Every now and then she&#8217;d manage to get there and the first thing she would aim for as soon as she got past The Forbidden Door was my dad&#8217;s shoes, where there were guaranteed to be a pair of socks.  She&#8217;d pick them up and not let them go without quite a lot of coercion.  She&#8217;s also ruined a few pairs of slippers by carrying them around and playing with them (I think she likes to put her nose into them and wear them like some sort of muzzle).</p>

	<p>Anyway, the other day I wasn&#8217;t paying all that much attention and I left my flip-flops within easy reach of her.  Of course, she spent the next ten minutes biting and licking and pulling at them as if she would somehow evoke some sort of reaction from the poor flip-flop.  She even got angry with me when I tried to take them away from her!  I decided to leave her to her worrying and take a few photos of the spectacle (which isn&#8217;t easy with a manual focus lens and a crazy dog).</p>
            </div>
        </content>
    </entry>

    <entry>
        <id>tag:andrewho.co.uk,2010-01-20:/weblog/read/2010-n-52-week-three</id>
        <title type="text">2010 n/52: Week three</title>
        <updated>2010-01-20T02:16:50+00:00</updated>
        <author>
            <name>Andrew Ho</name>
            <uri>http://andrewho.co.uk/</uri>
        </author>
        <link rel="alternate" type="text/html" href="http://andrewho.co.uk/weblog/read/2010-n-52-week-three" />
        <content type="xhtml" xml:base="http://andrewho.co.uk/" xml:lang="en-GB">
            <div xmlns="http://www.w3.org/1999/xhtml">
                	<p><a href="http://www.flickr.com/photos/andrewlkho/4288887457/in/set-72157623130355734/"><img src="/files/2010-01-20.jpg" title="2010 n/52: Week three" alt="2010 n/52: Week three" width="500" height="375" /></a></p>

	<p>Week three already, and I&#8217;ve fallen behind.  My lateness (which I hope won&#8217;t become a recurring theme) is due to a combination of working nights at the end of last week, being away last weekend, and getting a new iPhone.  As a testimony to that, here&#8217;s a photo rather hastily taken on my iPhone just now which shows that Mr Bear has had the opportunity to play with my D40 now that I&#8217;m spending lots of time playing with the new phone.  The novelty has yet to wear off!</p>
            </div>
        </content>
    </entry>

    <entry>
        <id>tag:andrewho.co.uk,2010-01-10:/weblog/read/2010-n-52-week-two</id>
        <title type="text">2010 n/52: Week two</title>
        <updated>2010-01-10T23:07:30+00:00</updated>
        <author>
            <name>Andrew Ho</name>
            <uri>http://andrewho.co.uk/</uri>
        </author>
        <link rel="alternate" type="text/html" href="http://andrewho.co.uk/weblog/read/2010-n-52-week-two" />
        <content type="xhtml" xml:base="http://andrewho.co.uk/" xml:lang="en-GB">
            <div xmlns="http://www.w3.org/1999/xhtml">
                	<p><a href="http://www.flickr.com/photos/andrewlkho/4263448609/in/set-72157623130355734/"><img src="/files/DSC_5481.jpg" title="2010 n/52: Week two" alt="2010 n/52: Week two" width="500" height="330" /></a></p>

	<p>Continuing on the theme of <a href="/weblog/read/photo-a-week-project-week-one">week one</a>, I arrived home at the end of this weekend to discover that my mother had bought a new toy for Cassie (this is not an infrequent occurrence).  What was unusual, however, was that this new toy bears a startling resemblance to Mr Bear who, as you may well remember, had a mildly distressing incident wherein he became Cassie&#8217;s toy.  I protested that we might teach Cassie a bad habit (<em>viz</em> that all bears can be considered hers) but this seems to have fallen on deaf ears.  At any rate, she seems happy with the new addition to her playthings :-).</p>
            </div>
        </content>
    </entry>

    <entry>
        <id>tag:andrewho.co.uk,2010-01-04:/weblog/read/photo-a-week-project-week-one</id>
        <title type="text">Photo a week project: Week one</title>
        <updated>2010-01-04T00:17:19+00:00</updated>
        <author>
            <name>Andrew Ho</name>
            <uri>http://andrewho.co.uk/</uri>
        </author>
        <link rel="alternate" type="text/html" href="http://andrewho.co.uk/weblog/read/photo-a-week-project-week-one" />
        <content type="xhtml" xml:base="http://andrewho.co.uk/" xml:lang="en-GB">
            <div xmlns="http://www.w3.org/1999/xhtml">
                	<p><a href="http://www.flickr.com/photos/andrewlkho/4241029339/in/set-72157623130355734/"><img src="/files/DSC_5184.jpg" title="2010 n/52: Week one" alt="2010 n/52: Week one" width="500" height="330" /></a></p>

	<p>As part of a bid to improve my photography this year, I&#8217;ve decided to start a &#8220;photo a week&#8221; project.  Whilst I admire the the resolution with which many attempt a &#8220;photo a day&#8221; project, the unpredictable nature of my schedule means that I&#8217;d likely fall at a very early hurdle.  I shall therefore endeavour to post a photo at the end of every week this year that I took during the week; some may be playful, some may be poignant, some will likely be mundane.  With any luck, the ratio of the the first two the the last will improve as the year marches on.  I&#8217;ll post the photo to <a href="http://www.flickr.com/photos/andrewlkho/sets/72157623130355734/">my flickr photostream</a> with a link back to a weblog post with some remarks about the photo.</p>

	<p>So to start off the year, I&#8217;ll introduce two characters who will probably return throughout the year.  In the foreground we have Mr Bear, a Cambridge University bear that the lovely Tara presented to me when I graduated from that university in June 2008.  In the background we have Cassie (in particular, <a href="http://www.flickr.com/photos/andrewlkho/4211465149/">this photo</a>), the six month old puppy that we now have in the house.  She&#8217;s a rather adorable handful of a Westie who loves soft things (especially socks).  She was running around my room earlier this week when she made her way onto the bed, and before I knew it had carried Mr Bear off in her mouth to play with elsewhere.  Needless to say, it took quite a lot of coaxing and tickling to convince her to give up her newfound friend.  Mr Bear is now a little bit scared of her, and is in need of a wash before he is allowed back into the bed!</p>
            </div>
        </content>
    </entry>

    <entry>
        <id>tag:andrewho.co.uk,2009-08-11:/weblog/read/debian-powerbook-g4-vodafone-payg-usb-modem-k3565</id>
        <title type="text">Debian/PowerBook G4: Vodafone <span class="caps">PAYG</span> <span class="caps">USB</span> modem (K3565)</title>
        <updated>2009-08-11T21:27:38+01:00</updated>
        <author>
            <name>Andrew Ho</name>
            <uri>http://andrewho.co.uk/</uri>
        </author>
        <link rel="alternate" type="text/html" href="http://andrewho.co.uk/weblog/read/debian-powerbook-g4-vodafone-payg-usb-modem-k3565" />
        <content type="xhtml" xml:base="http://andrewho.co.uk/" xml:lang="en-GB">
            <div xmlns="http://www.w3.org/1999/xhtml">
                	<p>I frequently find myself in need of mobile internet, and for this I use a Vodafone <span class="caps">PAYG</span> <span class="caps">USB</span> modem.  It&#8217;s the best plan in the UK, mostly due to the fact that the bandwidth doesn&#8217;t run out.  I pay Â£15 for 1 GB, but that 1 GB never expires and given that it&#8217;ll take me about two years to get through that it&#8217;s a pretty good deal (I mostly just <span class="caps">SSH</span> a terminal out).</p>

	<p>The model I bought about a year ago is the Vodafone K3565, which I believe is a rebranded Huawei E160.  This device can function in two different &#8220;modes&#8221;: as a storage device (it also contains a microSD slot) or as a modem.  Some people report having to manually define which mode you want it to be in, but I&#8217;ve not experienced this problem.  To check if it&#8217;s working as a modem, just plug it in and use <code>lsusb</code>.  If you do need to switch, remove all of the relevant modules (<code>usb-storage</code>, <code>usb-serial</code> and possibly <code>option</code>) before loading <code>usb-serial</code> back again.  There&#8217;s also a package available called <code>usb-modeswitch</code> (in Debian&#8217;s testing repository) which will do this for you.</p>

	<p>On the assumption that you&#8217;ve got mode switching sorted, install the <code>wvdial</code> package which will make <span class="caps">PPP</span> configuration and dialing rather a lot easier.  Whilst there is a Linux version of the Vodafone mobile connect software available <a href="https://forge.betavine.net/projects/vodafonemobilec/">here</a>, it requires <span class="caps">GTK</span> and often I don&#8217;t want to fire up X just to connect to the internet (I actually used that software to help me determine the initialisation strings needed to be sent).  Then put the following as your <code>/etc/wvdial.conf</code>:</p>

<pre><code>[Dialer vodafone]
Modem = /dev/ttyUSB0
Phone = *99***1#
Username = web
Password = web
Baud = 460800
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &amp;C1 &amp;D2 +FCLASS=0
Init3 = AT+CGDCONT=1,&quot;IP&quot;,&quot;pp.internet&quot;
Stupid Mode = 1
Auto DNS = 0
</code></pre>

	<p>A quick note about that last line: that stops <code>wvdial</code> from setting the <span class="caps">DNS</span> servers in <code>/etc/resolv.conf</code>.  I also comment out the <code>usepeerdns</code> line in <code>/etc/ppp/peers/wvdial</code>.  Both of these are necessary to stop pppd from overwriting my <code>resolv.conf</code>.  I&#8217;ve found that <span class="caps">DNS</span> lookups are a bit of a bottleneck on the Vodafone <span class="caps">PAYG</span> modem, so I&#8217;m switching to my standard (<a href="http://www.opendns.com/">OpenDNS</a> based) <span class="caps">DNS</span> settings to see if things will be a bit snappier.  I haven&#8217;t done any formal benchmarking on this yet, just going by gut feeling.</p>

	<p>Finally, issue <code>wvdial vodafone</code> to bring the interface up.</p>
            </div>
        </content>
    </entry>

    <entry>
        <id>tag:andrewho.co.uk,2009-08-10:/weblog/read/debian-powerbook-g4-network-configuration</id>
        <title type="text">Debian/PowerBook G4: Network configuration</title>
        <updated>2009-08-10T21:00:30+01:00</updated>
        <author>
            <name>Andrew Ho</name>
            <uri>http://andrewho.co.uk/</uri>
        </author>
        <link rel="alternate" type="text/html" href="http://andrewho.co.uk/weblog/read/debian-powerbook-g4-network-configuration" />
        <content type="xhtml" xml:base="http://andrewho.co.uk/" xml:lang="en-GB">
            <div xmlns="http://www.w3.org/1999/xhtml">
                	<p>Debian&#8217;s network configuration is pretty straightforward (make sure you have the package <code>wireless-tools</code> installed).  The first thing to note is that on the PowerBook G4, you&#8217;ll need to extract the Broadcom firmware.  You can do this by installing the <code>b43-fwcutter</code> package (it&#8217;s in the <em>contrib</em> repository) which automatically extracts the firmware in its post-installation &#8220;configuration&#8221;.</p>

	<p>I have three scenarios that I need to account for:</p>

	<ul>
		<li>Wired ethernet port with a fixed IP on my home network</li>
		<li>Wireless on a defined access point (HO1) with a fixed IP on my home network</li>
		<li>Wireless roaming via <span class="caps">DHCP</span></li>
	</ul>

	<p>Debian stores all of the pertinent network configuration in <code>/etc/network/interfaces</code>.  Wireless networks are usually defined in <code>/etc/wpa_supplicant/wpa_supplicant.conf</code>.  I&#8217;ll explain how these files are laid out before going ahead and showing my configuration.  This explanation should cover a decent proportion of use cases, but for more information see <a href="http://manpages.debian.net/cgi-bin/man.cgi?query=interfaces&amp;apropos=0&amp;sektion=0&amp;manpath=Debian+5.0+lenny&amp;format=html&amp;locale=en">interfaces(5)</a>, <a href="http://manpages.debian.net/cgi-bin/man.cgi?query=wpa_supplicant.conf&amp;apropos=0&amp;sektion=0&amp;manpath=Debian+5.0+lenny&amp;format=html&amp;locale=en">wpa_supplicant.conf(5)</a>, <a href="http://manpages.debian.net/cgi-bin/man.cgi?query=wpa_action&amp;apropos=0&amp;sektion=0&amp;manpath=Debian+5.0+lenny&amp;format=html&amp;locale=en">wpa_action(8)</a> etc.</p>

	<p><code>interfaces</code> consists of stanzas defining logicial interfaces, starting with the word <code>iface</code> (there are also <code>mapping</code>, <code>auto</code> and <code>allow-</code> stanzas).  What happens is that when you call:</p>

<pre><code>% ifup &lt;physical-interface&gt;=&lt;logical-interface&gt;
</code></pre>

	<p>Debian brings up the physical interface with the configuration defined for the logical interface in <code>interfaces</code>.  If you don&#8217;t specify the logical interface, Debian looks for a logical interface with the same name as the physical interface.  In other words, when you issue <code>ifup eth0</code>, Debian thinks of this as <code>ifup eth0=eth0</code>.  Thus, for very simple (e.g. single-location) configurations, you don&#8217;t really need to think about the separation of physical and logical interfaces.</p>

	<p>The first line of each stanza has this syntax:</p>

<pre><code>iface &lt;logical-interface&gt; inet &lt;method&gt;
</code></pre>

	<p>Of course, <code>inet</code> just defines <span class="caps">TCP</span>/IP networking; if you want IPv6 or something else then you probably don&#8217;t need this article to help you with network configuration.  <code>&lt;method&gt;</code>, for our sake, can be <code>dhcp</code>, <code>static</code>, or <code>manual</code>.  <code>dhcp</code> is self-explanatory; <code>static</code> is for static IP configuration; <code>manual</code> is for completely manual configuration (as in the case of wireless).</p>

	<p>So, to give an example, the wired configuration stanza for my home network looks like this:</p>

<pre><code>iface eth0 inet static
    address 192.168.1.31
    netmask 255.255.255.0
    broadcast 192.168.1.0
    gateway 192.168.1.1
</code></pre>

	<p>Wireless configuration is a bit more complicated, and is handled by the <code>wpasupplicant</code> package.  There are two ways to configure a wireless network.  The first is to manual describe it in <code>interfaces</code>, such as the following two examples:</p>

<pre><code>iface ap1 inet dhcp
    wpa-ssid ap1
    wpa-psk &lt;hex-key&gt;
</code></pre>

<pre><code>iface ap2 inet static
    wpa-ssid ap2
    wpa-key-mgmt NONE
    address 192.168.1.31
    netmask 255.255.255.0
    broadcast 192.168.1.0
    gateway 192.168.1.1
</code></pre>

	<p>Whilst this is good for known configurations, it doesn&#8217;t really offer much flexibility in terms of wireless roaming.  The second option is to hand off deciding which wireless network to connect to (and associated configuration) to <code>wpa_supplicant.conf</code>.  You do this with the following stanza:</p>

<pre><code>iface wlan0 inet manual
    wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
</code></pre>

	<p>Then, define the wireless networks in <code>wpa_supplicant.conf</code>.  One interesting trick that you can use is to set <code>id_str</code> in <code>wpa_supplicant.conf</code> for each network.  This then invokes a logical interface of that name in <code>interfaces</code>, which is useful for IP configuration.</p>

	<h2>My configuration files</h2>

	<p>Hopefully this will bring it all together.  Here are the two files:</p>

<pre><code>[ /etc/network/interfaces ]
</code>
<code># Loopback
auto lo
iface lo inet loopback
</code>
<code># Wired interface with a static IP
iface eth0 inet static
    address 192.168.1.31
    netmask 255.255.255.0
    broadcast 192.168.1.0
    gateway 192.168.1.1
    up rm /etc/resolv.conf &amp;&amp; ln -s /path/to/etc.git/resolv.conf /etc/resolv.conf
</code>
<code># Use wpa_supplicant to determine which wireless network to associate to
iface wlan0 inet manual
    wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
</code>
<code># Configuration for id_str=&quot;wlan0-ho1&quot;
iface wlan0-ho1 inet static
    address 192.168.1.31
    netmask 255.255.255.0
    broadcast 192.168.1.0
    gateway 192.168.1.1
    up rm /etc/resolv.conf &amp;&amp; ln -s /path/to/etc.git/resolv.conf /etc/resolv.conf
</code>
<code># All other wireless networks should use DHCP
iface wlan0-dhcp inet dhcp
</code></pre>

<pre><code>[ /etc/wpa_supplicant/wpa_supplicant.conf ]
</code>
<code># For wpa_cli
ctrl_interface=DIR=/var/run/wpa_supplicant
</code>
<code># HO1 network
network={
    ssid=&quot;HO1&quot;
    priority=10
    key_mgmt=NONE
    id_str=&quot;wlan0-ho1&quot;
}
</code>
<code># Default: associate with any open network
network={
    key_mgmt=NONE
    id_str=&quot;wlan0-dhcp&quot;
}
</code></pre>

	<p>The <code>eth0</code> configuration should be pretty self explanatory.  I bring it up with <code>ifup eth0</code> and down with the corresponding command.  The wireless interface is a bit more interesting.  In all cases, I bring it up with <code>ifup wlan0</code> and down with <code>wpa_action wlan0 stop</code>.  This uses the <code>wlan0</code> stanza which tells Debian to look at <code>wpa_supplicant.conf</code>.  Here, we decide which network to associate to.  If HO1 is available, it associates to that, otherwise it associates to any open network.  In both cases, <code>id_str</code> causes the invokation of a <code>wlan-*</code> logical interface which results in either a static IP or <span class="caps">DHCP</span> assignment.</p>

	<p>The final thing to note is those <code>up</code> commands.  They just restore my home <span class="caps">DNS</span> configuration (the master <code>resolv.conf</code> is stored in a git repository) because <span class="caps">DHCP</span> overwrites <code>resolv.conf</code>.</p>
            </div>
        </content>
    </entry>

    <entry>
        <id>tag:andrewho.co.uk,2009-08-05:/weblog/read/debian-powerbook-g4-usb-key-for-an-encrypted-lvm</id>
        <title type="text">Debian/PowerBook G4: <span class="caps">USB</span> key for an encrypted <span class="caps">LVM</span></title>
        <updated>2009-08-05T00:04:57+01:00</updated>
        <author>
            <name>Andrew Ho</name>
            <uri>http://andrewho.co.uk/</uri>
        </author>
        <link rel="alternate" type="text/html" href="http://andrewho.co.uk/weblog/read/debian-powerbook-g4-usb-key-for-an-encrypted-lvm" />
        <content type="xhtml" xml:base="http://andrewho.co.uk/" xml:lang="en-GB">
            <div xmlns="http://www.w3.org/1999/xhtml">
                	<p>When setting Lenny up on my PowerBook, I wanted some way to encrypt important data on the hard drive.  Crucially, this includes the contents of the main PostgreSQL database cluster.  With this in mind, using an encrypted <span class="caps">LVM</span> seemed to be the obvious way to go and so I went ahead and did this during the initial installation (Debian makes it pretty easy to do).  The one downside is that the 16 character alphanumeric password is a little cumbersome to type in every time, so I opted to have a key file stored on a <span class="caps">USB</span> key which could be plugged in at boot time to authenticate and unlock the <span class="caps">LVM</span> instead.  Here&#8217;s how I did this.</p>

	<p>The first step is to generate a key that can be used.  You can use whatever you want, such as an innocuous-looking <span class="caps">PDF</span> on your <span class="caps">USB</span> key, maybe.  I stored my key in <code>&lt;usbkey&gt;/.keys/&lt;hostname&gt;.key</code>, and used this to generate it:</p>

<pre><code>% head -c 5000 /dev/random | uuencode -m - | head -n 65 | tail -n 64 &gt; /path/to/&lt;hostname&gt;.key
</code></pre>

	<p>Next, we need to tell <span class="caps">LUKS</span> about this key which requires us to know which is the encrypted device.  Note that <span class="caps">LUKS</span> will prompt you for a passphrase (likely the one you set during the partitioning stage of Debian&#8217;s installer).</p>

<pre><code>% cat /etc/crypttab
hda4_crypt /dev/hda4 none luks
% cryptsetup luksAddKey /dev/hda4 /path/to/&lt;machine&gt;.key
Enter any LUKS passphrase: &lt;passphrase&gt;
key slot 0 unlocked.
Command successful.
</code></pre>

	<p>Some modules need to be loaded to open and read the <span class="caps">USB</span> key, so append the following lines to <code>/etc/initramfs-tools/modules</code>:</p>

<pre><code>vfat
fat
nls_cp437
nls_utf8
</code></pre>

	<p>We need a self-contained script that will retrieve the key file from the plugged-in <span class="caps">USB</span> key and present it to <span class="caps">LUKS</span>.  I&#8217;ve used the one from <a href="http://wejn.org/stuff/hendrik-crypto-usb-key.sh">here</a> and stored it as <code>/usr/local/sbin/crypt-usb-key.sh</code>.  Tell the system about this by changing <code>/etc/crypttab</code> to your equivalent of this:</p>

<pre><code>hda4_crypt /dev/hda4 .keys/&lt;machine&gt;.key luks,keyscript=/usr/local/sbin/crypto-usb-key.sh
</code></pre>

	<p>Update your initramfs image:</p>

<pre><code>% update-initramfs -u all
</code></pre>

	<p>Finally, reboot with the <span class="caps">USB</span> key attached and you shouldn&#8217;t be prompted for your <span class="caps">LUKS</span> passphrase (unless you forget to plug it in).</p>

	<p><em>Hat tip: much of the above was derived from <a href="http://wejn.org/how-to-make-passwordless-cryptsetup.html">this article</a></em></p>
            </div>
        </content>
    </entry>

    <entry>
        <id>tag:andrewho.co.uk,2009-08-04:/weblog/read/debian-powerbook-g4-network-install</id>
        <title type="text">Debian/PowerBook G4: Network install</title>
        <updated>2009-08-04T23:18:56+01:00</updated>
        <author>
            <name>Andrew Ho</name>
            <uri>http://andrewho.co.uk/</uri>
        </author>
        <link rel="alternate" type="text/html" href="http://andrewho.co.uk/weblog/read/debian-powerbook-g4-network-install" />
        <content type="xhtml" xml:base="http://andrewho.co.uk/" xml:lang="en-GB">
            <div xmlns="http://www.w3.org/1999/xhtml">
                	<p>I&#8217;m currently in the process of setting up Debian <span class="caps">GNU</span>/Linux (<em>&#8220;Lenny&#8221;</em>, the latest stable) on my PowerBook G4 (12-inch; bought <em>circa</em> August 2004 in the UK).  I&#8217;m going to post a few bits and bobs here both to serve as a reference to myself but also to help anyone else who follows in this endeavour.</p>

	<p>The SuperDrive on my PowerBook no longer works, so I had to do a completely network-based install (it also feels a bit cleaner this way).  I couldn&#8217;t place the files on the hard drive for booting as the installer can&#8217;t boot from <span class="caps">HFS</span>+ filesystems.  The first step is to place the following files on a <span class="caps">TFTP</span> server on your network (I used my Mac Pro &#8212; Leopard comes with a pre-configured <span class="caps">TFTP</span> server):</p>

	<ul>
		<li><a href="http://ftp.uk.debian.org/debian/dists/lenny/main/installer-powerpc/current/images/powerpc/netboot/boot.msg"><code>boot.msg</code></a></li>
		<li><a href="http://ftp.uk.debian.org/debian/dists/lenny/main/installer-powerpc/current/images/powerpc/netboot/initrd.gz"><code>initrd.gz</code></a></li>
		<li><a href="http://ftp.uk.debian.org/debian/dists/lenny/main/installer-powerpc/current/images/powerpc/netboot/vmlinux"><code>vmlinux</code></a></li>
		<li><a href="http://ftp.uk.debian.org/debian/dists/lenny/main/installer-powerpc/current/images/powerpc/netboot/yaboot"><code>yaboot</code></a></li>
		<li><a href="http://ftp.uk.debian.org/debian/dists/lenny/main/installer-powerpc/current/images/powerpc/netboot/yaboot.conf"><code>yaboot.conf</code></a></li>
	</ul>

	<p>Also, make sure you have a working <span class="caps">DHCP</span> server on your network.  Next, boot into Open Firmware by pressing Command-Option-O-F before the startup chime.  Boot from your <span class="caps">TFTP</span> server by typing the following at the prompt (<code>192.168.1.33</code> is the IP address of my Mac Pro):</p>

<pre><code>boot enet:192.168.1.33,yaboot
</code></pre>

	<p>Now, just run through the installation as you normally would and you&#8217;ll soon reboot into a working Debian system.</p>
            </div>
        </content>
    </entry>

    <entry>
        <id>tag:andrewho.co.uk,2009-05-11:/weblog/read/filevault-hiccough</id>
        <title type="text">FileVault hiccough</title>
        <updated>2009-05-11T17:36:55+01:00</updated>
        <author>
            <name>Andrew Ho</name>
            <uri>http://andrewho.co.uk/</uri>
        </author>
        <link rel="alternate" type="text/html" href="http://andrewho.co.uk/weblog/read/filevault-hiccough" />
        <content type="xhtml" xml:base="http://andrewho.co.uk/" xml:lang="en-GB">
            <div xmlns="http://www.w3.org/1999/xhtml">
                	<p>So I was trying to secure my computer a couple of days ago, and thought I&#8217;d enable FileVault as an easy way to encrypt my important files.  However, when I tried to do so, I received the following message:</p>

	<blockquote>
		<p>You cannot turn on FileVault to protect the home folder of this user account. The home folder is located on a volume that is not a Mac OS Extended format volume.</p>
	</blockquote>

	<p>How odd.  I haven&#8217;t done anything weird; the filesystem that my home directory resides on is definitely a Mac OS Extended one.  It turns out that actually FileVault refuses to work on <em>case-sensitive</em> Mac OS Extended filesystems.  Which is not at all obvious from the error message.</p>

	<p>It all seems rather arbitrary, given that Disk Utility will happily create encrypted case-sensitive sparse bundle disk images.</p>
            </div>
        </content>
    </entry>

    <entry>
        <id>tag:andrewho.co.uk,2009-04-16:/weblog/read/installing-cgit-on-a-joyent-shared-accelerator-solaris</id>
        <title type="text">Installing cgit on a Joyent Shared Accelerator (Solaris)</title>
        <updated>2009-04-16T01:34:12+01:00</updated>
        <author>
            <name>Andrew Ho</name>
            <uri>http://andrewho.co.uk/</uri>
        </author>
        <link rel="alternate" type="text/html" href="http://andrewho.co.uk/weblog/read/installing-cgit-on-a-joyent-shared-accelerator-solaris" />
        <content type="xhtml" xml:base="http://andrewho.co.uk/" xml:lang="en-GB">
            <div xmlns="http://www.w3.org/1999/xhtml">
                	<p>I recently found the time to setup a web frontend to git on my <a href="http://joyent.com/connector/web-hosting/">Shared Accelerator</a>.  Pretty much all of my data (including work) is under version control so this is useful for those occasions when I&#8217;m away from my own computer but want to fetch a file.  I went with <a href="http://hjemli.net/git/cgit/">cgit</a> rather than gitweb because the configuration looked cleaner and more powerful; it also (utterly unscientifically) felt a lot more responsive (it is meant to be, especially once you enable the cache).  The installation proved to be less trivial than I expected upon first inspection, hence this documentation.</p>

	<h2>Compiling cgit</h2>

	<p>The first step is to fetch the cgit source and get it ready for compilation.  I did this in <code>~/tmp</code>.</p>

<pre><code>% git clone git://hjemli.net/pub/git/cgit
% cd cgit
% git submodule init
% git submodule update
</code></pre>

	<p>Edit the configuration variables at the top of the <code>Makefile</code>.  Pretty much the most important variable is <code>CGIT_CONFNIG</code>; here&#8217;s my configuration:</p>

<pre><code>CGIT_VERSION = v0.8.2.1
CGIT_SCRIPT_NAME = cgit.cgi
CGIT_SCRIPT_PATH = /users/home/andrewlkho/cgi-bin
CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH)
CGIT_CONFIG = /users/home/andrewlkho/etc/cgitrc
CACHE_ROOT = /users/home/andrewlkho/var/cache/cgit
SHA1_HEADER = &lt;openssl/sha.h&gt;
GIT_VER = 1.6.1.1
GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2
INSTALL = install
</code></pre>

	<p>There are some syntax oddities that Solaris&#8217; <code>/bin/sh</code> doesn&#8217;t like, so the easiest thing to do is change the interpreter to <code>/usr/local/bin/bash</code>.  This only applies to <code>gen-version.sh</code>.</p>

<pre><code>#!/usr/local/bin/bash
...
</code></pre>

	<p>Solaris doesn&#8217;t have <code>timegm</code> (a non-standard <span class="caps">GNU</span> extension) so we need to apply <a href="http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/timegm.3.html">this patch</a> from Apple.  Place the following code somewhere near the top of <code>ui-stats.c</code>.</p>

<pre><code>#include &lt;time.h&gt;
#include &lt;stdlib.h&gt;
</code>
<code>time_t timegm (struct tm *tm) {
    time_t ret;
    char  *tz;
</code>
<code>    tz = getenv(&quot;TZ&quot;);
    setenv(&quot;TZ&quot;, &quot;&quot;, 1);
    tzset();
    ret = mktime(tm);
    if (tz)
        setenv(&quot;TZ&quot;, tz, 1);
    else
        unsetenv(&quot;TZ&quot;);
    tzset();
    return ret;
}
</code></pre>

	<p>Finally, compile cgit and copy the relevant files into place.</p>

<pre><code>% LDFLAGS=&quot;-lnsl&quot; NO_STRCASESTR=yes NO_ICONV=yes CC=gcc \
&gt; gmake
% mkdir ~/web/public/git
% cp cgit ~/cgi-bin/cgit.cgi
% cp {cgit.css,cgit.png} ~/web/public/git
</code></pre>

	<h2>cgit configuration</h2>

	<p>The next step is to configure cgit.  The <a href="http://hjemli.net/git/cgit/tree/cgitrc.5.txt">manpage</a> documents all of the configuration variables, but to get you off the ground the following will suffice.  I&#8217;ve only entered one (bare) repository, but you can repeat those lines as many times as you want for more repositories.  Remember, this is in <code>~/etc/cgitrc</code></p>

<pre><code>css=/git/cgit.css
logo=/git/cgit.png
</code>
<code>repo.url=bin
repo.path=/users/home/andrewlkho/git/bin.git
repo.desc=A bunch of useful scripts for my ~/bin
</code></pre>

	<p>We now have a fully working cgit setup; just navigate to your equivalent of <code>http://andrewho.co.uk/cgi-bin/cgit.cgi</code> and browse away.</p>

	<h2>Extra credit: git.andrewho.co.uk</h2>

	<p>Whilst that&#8217;s all fine and dandy, I wanted a slightly more semantic path to the interface.  This isn&#8217;t as easy it sounds due to the fact that <code>mod_vd</code> and <code>mod_rewrite</code> simply don&#8217;t play together in any nice well-documented way.  To save you quite a bit of grief, I&#8217;ll just present the final result.</p>

	<p>This is what <code>~/etc/cgitrc</code> now looks like:</p>

<pre><code>virtual-root=/
</code>
<code>css=/cgit.css
logo=/cgit.png
</code>
<code>repo.url=bin
repo.path=/users/home/andrewlkho/git/bin.git
repo.desc=A bunch of useful scripts for my ~/bin
</code></pre>

	<p>The following is in <code>~/web/public/.htaccess</code></p>

<pre><code>RewriteEngine on
</code>
<code>RewriteCond %{HTTP_HOST} ^git\.
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .* - [L]
</code>
<code>RewriteCond %{HTTP_HOST} ^git\.
RewriteRule ^git/$ /cgi-bin/cgit.cgi [L]
</code>
<code>RewriteCond %{HTTP_HOST} ^git\.
RewriteRule ^(.*)$ /cgi-bin/cgit.cgi?url=$1 [L,QSA]
</code></pre>

	<p>Now if you fire up your equivalent of <code>http://git.andrewho.co.uk/</code> you should have a bunch of slightly nicer <span class="caps">URL</span>s to navigate through.  Enjoy!</p>
            </div>
        </content>
    </entry>

</feed>
