<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>roblog</title>
	<atom:link href="http://helms-deep.cable.nu/~rwh/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://helms-deep.cable.nu/~rwh/blog</link>
	<description>Ramblings through a geeky existence</description>
	<lastBuildDate>Wed, 25 Apr 2012 08:55:07 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Skeptics&#8217; Guide to the Universe transcripts project</title>
		<link>http://helms-deep.cable.nu/~rwh/blog/?p=270&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=skeptics-guide-to-the-universe-transcripts-project</link>
		<comments>http://helms-deep.cable.nu/~rwh/blog/?p=270#comments</comments>
		<pubDate>Wed, 11 Apr 2012 12:55:21 +0000</pubDate>
		<dc:creator>rwh</dc:creator>
				<category><![CDATA[Blogthings]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[sceptic]]></category>
		<category><![CDATA[science]]></category>
		<category><![CDATA[sgu]]></category>
		<category><![CDATA[skeptic]]></category>
		<category><![CDATA[skeptics]]></category>
		<category><![CDATA[skepticsguide]]></category>
		<category><![CDATA[transcripts]]></category>
		<category><![CDATA[universe]]></category>
		<category><![CDATA[wiki]]></category>

		<guid isPermaLink="false">http://helms-deep.cable.nu/~rwh/blog/?p=270</guid>
		<description><![CDATA[I&#8217;m a huge fan of the Skeptics&#8217; Guide to the Universe, a podcast of science and skepticism, and I&#8217;ve been thinking for a while that it&#8217;d be really good to have transcripts of the episodes to facilitate linking and searching. &#8230; <a href="http://helms-deep.cable.nu/~rwh/blog/?p=270">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m a huge fan of the <a href=http://www.theskepticsguide.org/>Skeptics&#8217; Guide to the Universe</a>, a podcast of science and skepticism, and I&#8217;ve been thinking for a while that it&#8217;d be really good to have transcripts of the episodes to facilitate linking and searching.  But I couldn&#8217;t find any other project, other than a <a href=http://sguforums.com/index.php/topic,12548.0.html>thread on the SGU forums</a>.  So I decided to put my time where my mouth is, and just do some transcribing.</p>
<p>It takes me about three times the amount of time to do a transcript as the podcast&#8217;s length (which is about 80 minutes), so generally a couple of nights&#8217; work for a single SGU podcast.  I guess I might be able to manage about two podcasts a week, and given that there are currently a bit over 350 podcasts in the archive, and a new one released each week, it&#8217;ll probably take me about seven years to finish them all!  So&#8230; I created a wiki, <a href=http://www.sgutranscripts.org>sgutranscripts.org</a>.  Now we&#8217;ll just have to see if the community gets behind it, otherwise I could be here for a long time.</p>
]]></content:encoded>
			<wfw:commentRss>http://helms-deep.cable.nu/~rwh/blog/?feed=rss2&#038;p=270</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>RDP VirtualBox without the proprietary Oracle extension pack</title>
		<link>http://helms-deep.cable.nu/~rwh/blog/?p=236&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rdp-virtualbox-without-the-proprietary-oracle-extension-pack</link>
		<comments>http://helms-deep.cable.nu/~rwh/blog/?p=236#comments</comments>
		<pubDate>Mon, 09 Apr 2012 09:18:21 +0000</pubDate>
		<dc:creator>rwh</dc:creator>
				<category><![CDATA[HOWTOs]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[consolidation]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[headless]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[ose]]></category>
		<category><![CDATA[oss]]></category>
		<category><![CDATA[RDP]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[VBoxHeadless]]></category>
		<category><![CDATA[VBoxManage]]></category>
		<category><![CDATA[virtual]]></category>
		<category><![CDATA[virtualbox]]></category>
		<category><![CDATA[vm]]></category>
		<category><![CDATA[vnc]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[xrdp]]></category>

		<guid isPermaLink="false">http://helms-deep.cable.nu/~rwh/blog/?p=236</guid>
		<description><![CDATA[These days, virtualisation is all the rage. The various competing virtualisation products have reached a level of maturity where they can be reliably used for server consolidation. VirtualBox is one of the easiest to use, most featureful programs available in &#8230; <a href="http://helms-deep.cable.nu/~rwh/blog/?p=236">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>These days, virtualisation is all the rage.  The various competing virtualisation products have reached a level of maturity where they can be reliably used for server consolidation.  VirtualBox is one of the easiest to use, most featureful programs available in this space and with the ability to run on many different OSes on hardware with or without VM extensions, it is also one of the most popular.  However, there is one wrinkle when it comes to using it for server consolidation: the proprietary RDP/USB2 extension pack.</p>
<p>The conventional wisdom when running a headless server with VirtualBox is that you need to install this <a href=https://www.virtualbox.org/wiki/Downloads>proprietary extension pack from Oracle</a>.  This is fine until you want to use the server in production: as the <a href=https://www.virtualbox.org/wiki/VirtualBox_PUEL>PUEL</a> only covers you for personal use and evaluation, you must <a href="http://www.oracle.com/us/technologies/virtualization/oraclevm/061976.html">purchase licenses</a>.  You can either pay £34 per user or £670 per &#8220;socket&#8221; (which has quite a <a href=http://www.orafaq.com/wiki/Oracle_Licensing#Standard_Edition_Per-socket_licensing>convoluted definition</a>).  This gets you USB2 and RDP support.</p>
<p>However, there is another way, at least when it comes to RDP support.<span id="more-236"></span>  <a href=http://www.virtualbox.org/manual/ch07.html>Chapter 7 of the VirtualBox manual</a> covers running virtual machines on a remote host, either with <code>VBoxManage</code> command (which offeres similar functionality to the VirtualBox GUI) or the <code>VBoxHeadless</code> command, which appears to be the backend binary that <code>VBoxManage</code> calls out to to do the actual work.  Now, chapter 7 covers in detail how to connect to remote VMs using the proprietary extensions, but there&#8217;s one feature that they conveniently failed to mention: the built-in VNC server.</p>
<pre>man VBoxHeadless
VBOXHEADLESS(1)            User Commands             VBOXHEADLESS(1)

NAME
       VBoxHeadless - x86 virtualization solution

DESCRIPTION
    Oracle  VM  VirtualBox Headless Interface (C) 2008-2011 Oracle
    Corporation All rights reserved.

Usage:
    -s, -startvm, --startvm &lt;name|uuid&gt;
           Start given VM (required argument)
    -n, --vnc
           Enable the built in VNC server
    -m, --vncport &lt;port&gt;
           TCP port number to use for the VNC server
    -o, --vncpass &lt;pw&gt;
           Set the VNC server password
    -v, -vrde, --vrde on|off|config
           Enable (default) or disable the VRDE  server  or  don't
           change the setting
    -e,  -vrdeproperty,  --vrdeproperty  &lt;name=[value]&gt;
    Set a VRDE property:
           "TCP/Ports" - comma-separated list of  ports  the  VRDE
           server can bind to. Use a dash between two port numbers
           to specify a range "TCP/Address"  -  interface  IP  the
           VRDE server will bind to
    -c, -capture, --capture
           Record the VM screen output to a file
    -w, --width
           Frame width when recording
    -h, --height
           Frame height when recording
    -r, --bitrate
           Recording bit rate when recording
    -f, --filename
           File  name when recording.  The codec used will be cho‐
           sen based on the file extension

VBoxHeadless                January 2011             VBOXHEADLESS(1)</pre>
<p>Right!  So we can start a virtual machine and forward its root console (or main video or out-of-band console or whatever you want to call it) over the network with a VNC server.  In my example I&#8217;ll use screen to keep my VMs running when I log out.  I&#8217;ll start a couple of VMs as an example:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">screen</span>
VBoxHeadless <span style="color: #660033;">--startvm</span> <span style="color: #ff0000;">'Ubuntu'</span> <span style="color: #660033;">--vnc</span> <span style="color: #660033;">--vncport</span> <span style="color: #000000;">5900</span>
<span style="color: #666666; font-style: italic;"># hit &quot;ctrl-a c&quot; to open a new terminal within screen</span>
VBoxHeadless <span style="color: #660033;">--startvm</span> <span style="color: #ff0000;">'XP1'</span> <span style="color: #660033;">--vnc</span> <span style="color: #660033;">--vncport</span> <span style="color: #000000;">5901</span> <span style="color: #660033;">--vncpass</span> vnc2xrdp</pre></div></div>

<p>Great!  We don&#8217;t need the proprietary expansion pack to do this.  However, there are a few drawbacks to this approach:</p>
<ul>
<li>VNC sucks over slow network connections, it&#8217;d be much nicer to use the more modern RDP protocol</li>
<li>You have to keep the command running so you have to use <code>screen</code> or <code>nohup</code> or equivalent, which is a bit less convenient than using <code>VBoxManage</code></li>
<li>If the VNC server crashes (which I&#8217;ve had happen only once so far in testing, when changing screen resolution in a Windows XP guest), the whole VM goes down with it</li>
<li>You need to make sure you only bind one VNC server to each port.  As far as I can tell if you try to bind a second one to a port that&#8217;s already in use, the VM still starts up but you have no way of interacting with it!</li>
</ul>
<p>We can actually work around the first limitation, by using the <code>xrdp</code> program to &#8220;translate&#8221; the VNC protocol into RDP.  I&#8217;m on Ubuntu, so I have the luxury of installing xrdp the easy way.  On the VirtualBox server machine:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> xrdp</pre></div></div>

<p>Now we configure it to use the existing VNC servers that we previously spawned with <code>VBoxHeadless</code>.  One neat thing here is that xrdp uses a single RDP port to manage multiple VNC connections:</p>
<p>/etc/xrdp/xrdp.ini</p>
<pre>[globals]
bitmap_cache=yes
bitmap_compression=yes
port=3389
crypt_level=low
channel_code=1

[xrdp1]
name=VBox-Ubuntu
lib=libvnc.so
ip=127.0.0.1
port=5900

[xrdp2]
name=VBox-XP1
lib=libvnc.so
username=
password=vnc2xrdp
ip=127.0.0.1
port=5901</pre>
<p>So we have two VirtalBox VMs running, Ubuntu and XP1.  In the example above, I started the ubuntu VNC without a password, so I&#8217;ve left out the username/password entries.  The XP1 connection is protected with the password <code>vnc2xrdp</code>.  You can also use the value <code>ask</code> and xrdp will prompt for a username/password for connecting to VNC.  Note that VNC passwords are generally insecure, so it&#8217;d probably be best to protect the vnc ports using firewalling.  It doesn&#8217;t appear to be possible to bind the VNC server to only the loopback device (at least from the man page above).</p>
<p>So now all that&#8217;s left to do is to connect to the RDP port using one of the myriad RDP clients for linux (I&#8217;m using Remmina, but there are <a href=http://en.wikipedia.org/wiki/Remote_Desktop_Protocol#Non-Microsoft_implementations>heaps of options</a>).  You can then choose the VNC connection you want xrdp to connect to and you&#8217;re away!</p>
<div id="attachment_267" class="wp-caption alignnone" style="width: 631px"><a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2012/04/xrdp.png"><img src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2012/04/xrdp.png" alt="" title="xrdp" width="621" height="380" class="size-full wp-image-267" /></a><p class="wp-caption-text">xrdp login screen</p></div>
<p>Of course, SSH local port forwarding is your friend if you&#8217;re doing any of this through firewalls or over insecure connections.  Remmina actually includes this functionality, or you can forward the remote port to your local machine with something like:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-L</span> <span style="color: #000000;">3389</span>:localhost:<span style="color: #000000;">3389</span> vboxservermachine</pre></div></div>

<p>So there you are, RDP connections to remote VirtualBox VMs without the proprietary Oracle extensions; all free software!</p>
<p>Have fun. <img src='http://helms-deep.cable.nu/~rwh/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://helms-deep.cable.nu/~rwh/blog/?feed=rss2&#038;p=236</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to build MySQL Workbench on Ubuntu Precise (pre-release)</title>
		<link>http://helms-deep.cable.nu/~rwh/blog/?p=229&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-build-mysql-workbench-on-ubuntu-precise-pre-release</link>
		<comments>http://helms-deep.cable.nu/~rwh/blog/?p=229#comments</comments>
		<pubDate>Wed, 04 Apr 2012 12:13:54 +0000</pubDate>
		<dc:creator>rwh</dc:creator>
				<category><![CDATA[HOWTOs]]></category>
		<category><![CDATA[12.04]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysqlworkbench]]></category>
		<category><![CDATA[pangolin]]></category>
		<category><![CDATA[precise]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[workbench]]></category>

		<guid isPermaLink="false">http://helms-deep.cable.nu/~rwh/blog/?p=229</guid>
		<description><![CDATA[Update 2012-04-25: mysql has appeared in the universe package archive. You should be able to install it with a simple: sudo apt-get install mysql-workbench Read on if you still want to compile from source. Right now (2012-04-04), Ubuntu 12.04 hasn&#8217;t &#8230; <a href="http://helms-deep.cable.nu/~rwh/blog/?p=229">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><strong>Update 2012-04-25</strong>: mysql has appeared in the <a href=http://packages.ubuntu.com/precise/mysql-workbench>universe package archive</a>.  You should be able to install it with a simple:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> mysql-workbench</pre></div></div>

<p>Read on if you still want to compile from source.</p>
<p>Right now (2012-04-04), Ubuntu 12.04 hasn&#8217;t been released yet, and so there is no binary package from Oracle of MySQL Workbench for Precise.  I managed to get the <a href=http://dev.mysql.com/downloads/workbench/>MySQL Workbench binaries for Oneiric</a> to run, by manually installing libzip1_0.9.3-1_amd64.deb from Oneiric, but this wasn&#8217;t stable (crashed as soon as I tried to run a SQL Query).</p>
<p>So I decided to build from source.  Here&#8217;s how I did it<span id="more-229"></span>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.mirrorservice.org<span style="color: #000000; font-weight: bold;">/</span>sites<span style="color: #000000; font-weight: bold;">/</span>ftp.mysql.com<span style="color: #000000; font-weight: bold;">/</span>Downloads<span style="color: #000000; font-weight: bold;">/</span>MySQLGUITools<span style="color: #000000; font-weight: bold;">/</span>mysql-workbench-gpl-5.2.38-src.tar.gz
md5sum mysql-workbench-gpl-5.2.38-src.tar.gz
<span style="color: #666666; font-style: italic;"># should be cd2a0cec9dffd5465b6999f5d9c8de78 (from http://dev.mysql.com/downloads/workbench/#downloads).</span>
<span style="color: #c20cb9; font-weight: bold;">tar</span> xvzf mysql-workbench-gpl-5.2.38-src.tar.gz
<span style="color: #7a0874; font-weight: bold;">cd</span> mysql-workbench-gpl-5.2.38-src
<span style="color: #666666; font-style: italic;"># from http://bugs.mysql.com/bug.php?id=63898</span>
<span style="color: #c20cb9; font-weight: bold;">fgrep</span> <span style="color: #660033;">-rlZ</span> pkglib_DATA <span style="color: #660033;">--include</span> Makefile.am . <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #660033;">-0</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #ff0000;">'s/pkglib_DATA/pkgdata_DATA/g'</span>
<span style="color: #666666; font-style: italic;"># from https://bugzilla.redhat.com/show_bug.cgi?id=750023</span>
<span style="color: #c20cb9; font-weight: bold;">vim</span> .<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>db.mysql.sqlparser<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>mysql_sql_parser_fe.cpp</pre></div></div>

<p>change line 23 from:</p>
<pre>#include &lt;glib/gunicode.h&gt;</pre>
<p>to</p>
<pre>#include &lt;glib.h&gt;</pre>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> update
<span style="color: #666666; font-style: italic;"># from http://ubuntuforums.org/showthread.php?t=1792874 plus updates from comments below.</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> build-essential <span style="color: #c20cb9; font-weight: bold;">autoconf</span> <span style="color: #c20cb9; font-weight: bold;">automake</span> libtool libzip-dev libxml2-dev libsigc++-<span style="color: #000000;">2.0</span>-dev libglade2-dev libgtkmm-<span style="color: #000000;">2.4</span>-dev libgl1-mesa-dev libmysqlclient-dev uuid-dev liblua5.1-dev libpcre3-dev <span style="color: #c20cb9; font-weight: bold;">g++</span> libgnome2-dev libgtk2.0-dev libpango1.0-dev libcairo2-dev libsqlite3-dev python-dev libboost-dev libctemplate-dev
.<span style="color: #000000; font-weight: bold;">/</span>autogen.sh
<span style="color: #666666; font-style: italic;"># I use -j4 below to use all four of my CPUs, set this appropriately for your setup.</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #660033;">-j</span> <span style="color: #000000;">4</span> <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #007800;">DESTDIR</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$USER</span><span style="color: #000000; font-weight: bold;">`/</span>mysql-workbench
~<span style="color: #000000; font-weight: bold;">/</span>mysql-workbench<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>mysql-workbench</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://helms-deep.cable.nu/~rwh/blog/?feed=rss2&#038;p=229</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Ubuntu on Amazon ec2 from scratch</title>
		<link>http://helms-deep.cable.nu/~rwh/blog/?p=211&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ubuntu-on-amazon-ec2-from-scratch</link>
		<comments>http://helms-deep.cable.nu/~rwh/blog/?p=211#comments</comments>
		<pubDate>Thu, 07 Jul 2011 13:46:55 +0000</pubDate>
		<dc:creator>rwh</dc:creator>
				<category><![CDATA[HOWTOs]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[certificate]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[credentials]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[groups]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[keypair]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[X.509]]></category>

		<guid isPermaLink="false">http://helms-deep.cable.nu/~rwh/blog/?p=211</guid>
		<description><![CDATA[Update: I&#8217;ve now rolled this blog post into the Ubuntu wiki&#8217;s: EC2 Starters Guide page. Hopefully this helps out the Ubuntu community! The informatics team here at MalariaGEN have been working with ec2 since before I joined them. So naturally, &#8230; <a href="http://helms-deep.cable.nu/~rwh/blog/?p=211">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Update: I&#8217;ve now rolled this blog post into the Ubuntu wiki&#8217;s: <a href="https://help.ubuntu.com/community/EC2StartersGuide">EC2 Starters Guide</a> page. Hopefully this helps out the Ubuntu community!</p>
<p>The informatics team here at MalariaGEN have been working with ec2 since before I joined them. So naturally, it&#8217;s one technology with which I&#8217;ve had to come to grips in the course of doing my job. For me, EC2 had a fairly steep learning curve, and after spending a while trying to learn it through doing, I decided that I would just have to spend some time getting properly to grips with how things worked. As part of that I decided to document it in a way that I&#8217;d not yet seen on the web: logically, comprehensively, explaining all the strange concepts and quirks that were clouding my understanding and stopping me from getting my job done efficiently.<span id="more-211"></span></p>
<p>We&#8217;re an Ubuntu shop here, or at least we&#8217;re moving to becoming one (the work I&#8217;m doing to move us off our ageing RHEL4 servers will be a topic for a future post), so this story will be from an Ubuntu point of view.</p>
<p>So first of all, we need to join up to the Amazon EC2 service. You can do this using your existing Amazon account, or create a completely new Amazon account to attach your EC2 subscription to.</p>
<p>So, we go to <a title="Amazon Web Services" href="https://aws.amazon.com/">https://aws.amazon.com/</a> and sign up, putting in our credit card details and so forth. Eventually, we will end up at the <a href="https://console.aws.amazon.com/ec2/">AWS Management Console</a> which is where we will first set up our credentials. But therein lay my first problem: I didn&#8217;t understand the various different types of credentials.</p>
<h2>EC2 Credentials</h2>
<p>In EC2, there are multiple different kinds of credential, Amazon uses slightly non-standard nomenclature, and it&#8217;s not always clear which credential is required for a given application.</p>
<p>1. <strong>Signon credentials</strong>: These are the email address/password pair that you use when you sign up. You use these to sign on to the <a href="https://console.aws.amazon.com/ec2/home">AWS Management Console</a>, and can be considered the &#8220;master&#8221; credentials as they allow you to regenerate all other types of credentials.</p>
<p>2. <strong>Access Credentials</strong>: There are three types: <em>access keys</em>, <em>X.509 certificates</em> and <em>key pairs</em>. The first and second type allow you to connect to the Amazon APIs. Which type of credential depends on which API and tool you are using. Some APIs and tools support both options, whereas others support just one. The third type is SSH public/private key pairs that are used for initial logins to newly created instances.</p>
<ol>
<li><strong>access keys</strong>: Symmetric key encryption. These are for making requests to AWS product REST or Query APIs. Can be obtained/regenerated from the <strong>Access Keys</strong> tab on the AWS <a title="Security Credentials" href="https://aws-portal.amazon.com/gp/aws/developer/account?ie=UTF8&amp;action=access-key">Security Credentials</a> page.</li>
<li><strong>X.509 certificates</strong>: Public key encryption. Use X.509 certificates to make secure SOAP protocol requests to AWS service APIs. These are the credentials you will use when using the command-line ec2 api tools. Can be obtained/regenerated from the <strong>X.509 Certificates</strong> tab on the AWS <a title="Security Credentials" href="https://aws-portal.amazon.com/gp/aws/developer/account?ie=UTF8&amp;action=access-key">Security Credentials</a> page.</li>
<li><strong>key pairs</strong>: SSH key pairs. When you create an instance, Amazon inserts the public key of your SSH key pair into your new instance so that you can log in using your private key. You can add new SSH key pairs through the <a title="AWS Management Console" href="https://console.aws.amazon.com/ec2/home">AWS Management Console</a> by clicking on <strong>Key Pairs</strong> under Networking and Security in the Navigation pane and then the <strong>Create Key Pair button</strong>. After specifying a name you will be prompted to download and save your private key. EC2 stores the public portion of your key pair, and inserts it into /home/ubuntu/.ssh/authorized_keys when you create your instance. If you lose this private key, it cannot be downloaded again; you will need to regenerate a new key pair.</li>
</ol>
<p>Now that we understand credentials, we can get them all set up. First, lets set up our SSH key pair:<br />
Go to the <a href="https://console.aws.amazon.com/ec2/">AWS Management Console</a>, <strong>Networking and Security</strong> in the <strong>Navigation</strong> pane and then click the <strong>Create Key Pair</strong>button (and save your SSH private key in e.g. ~/.ec2/ec2.pem).  The private key lives on your computer, while the public key lives in your AWS account.</p>
<p>You will also need to set up your Amazon API credentials. Go to Account-&gt;<a href="https://aws-portal.amazon.com/gp/aws/developer/account/index.html?action=access-key">Security Credentials</a></p>
<ol type="1">
<li>click <strong>X.509 Certificates</strong> tab</li>
<li>Create a new certificate</li>
<li>Download the private key and the certificate (save them in e.g. ~/.ec2/cert-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem and ~/.ec2/pk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem).</li>
<li>Make your credential files private: chmod go-rwx ~/.ec2/*.pem</li>
<li>Scroll to the bottom of the page and note your account ID (a number of the form XXXX-XXXX-XXXX).</li>
</ol>
<h2>Setting up the command line tools</h2>
<p>OK, we now have our X.509 certificate and private key for accessing the ec2-api calls (we&#8217;re going to use the linux command line tools, but you can use the AWS console to perform a subset of these tasks, and there are GUI applications that can be used too).</p>
<p>Make sure you <a href="https://help.ubuntu.com/community/Repositories/CommandLine#Adding%20the%20Universe%20and%20Multiverse%20Repositories">have multiverse enabled</a> and run the following command:</p>
<pre class="brush: bash; title: ; notranslate">sudo apt-get install ec2-api-tools</pre>
<p>Next, we set up some variables in our shell environment so that we don&#8217;t always have to specify them as options to the command line tools:</p>
<pre class="brush: bash; title: ; notranslate">export EC2_URL=https://ec2.eu-west-1.amazonaws.com
export EC2_KEYPAIR_EU_WEST_1=rwh-ec2 # ec2 SSH private key (name only, not the file)
export EC2_PRIVATE_KEY=$HOME/.ec2/rwh-ec2/pk-UZGAF4E4GLDA7DIDGUVWFIAKJTPK7MTX.pem # ec2 X.509 private key
export EC2_CERT=$HOME/.ec2/rwh-ec2/cert-UZGAF4E4GLDA7DIDGUVWFIAKJTPK7MTX.pem # ec2 X.509 certificate
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk/</pre>
<p>test that the environment is set up correctly:</p>
<pre class="brush: bash; title: ; notranslate">ec2-describe-images -o self -o amazon</pre>
<h2 id="EC2 security groups">EC2 security groups</h2>
<p>Security groups allow you to specify firewalling rules for your instances. These firewalling rules are independent of, and in addition to, the software firewalling provided by the instance&#8217;s operating system (<a href="https://help.ubuntu.com/community/IptablesHowTo">iptables</a> in the case of modern Ubuntu systems). Security groups must be defined before you create the instances that you would like to be members of those security groups. You specify the security groups to add an instance to at creation time with the <strong>-g</strong> option to the <strong>ec2-run-instances</strong> command. You cannot add an existing instance to a security group.</p>
<p>How you set up your security groups is up to you. You may choose to set up security groups that correspond to server functions, or have a separate security group for each instance. An instance may be a member of multiple security groups. If you don&#8217;t specify any security groups when you instantiate an instance, it will be added to the <strong>default</strong> security group. Our examples use the default security group, but keep in mind that this means that this causes an inability to set up firewalling rules in a granular fashion.</p>
<p>If you wish to create a more complex security group configuration, you can do so with these commands:</p>
<pre class="brush: bash; title: ; notranslate">ec2-add-group  -d
ec2-delete-group
ec2-describe-group [ ...]</pre>
<p>See the <a href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/using-network-security.html">Using Security Groups</a> section of the <a href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/">User Guide for Amazon EC2</a>for more information.</p>
<h2 id="Instantiating an image">Instantiating an image</h2>
<p>The first thing to do is work out what kind of instance that you want to instantiate. See <a href="http://aws.amazon.com/ec2/instance-types/">Amazon EC2 Instance Types</a> or <a href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?instance-types.html">Instance Families and Types</a> for descriptions of the available instance types, and <a href="https://aws.amazon.com/ec2/pricing/">Amazon EC2 Pricing</a> for the current pricing of instances, data transfer and storage. Next, decide what release of Ubuntu you&#8217;d like, then look up the AMI code from the links in this table of official Ubuntu EC2 images:</p>
<table>
<thead>
<tr>
<td>Release</td>
<td>Location</td>
</tr>
</thead>
<tbody>
<tr>
<td>11.04 Natty Narwhal</td>
<td><a href="http://uec-images.ubuntu.com/releases/11.04/release/">http://uec-images.ubuntu.com/releases/11.04/release/</a></td>
</tr>
<tr>
<td>10.10 Maverick Meerkat</td>
<td><a href="http://uec-images.ubuntu.com/releases/10.10/release/">http://uec-images.ubuntu.com/releases/10.10/release/</a></td>
</tr>
<tr>
<td>10.04 LTS Lucid Lynx</td>
<td><a href="http://uec-images.ubuntu.com/releases/10.04/release/">http://uec-images.ubuntu.com/releases/10.04/release/</a></td>
</tr>
<tr>
<td>9.10 Karmic Koala</td>
<td><a href="http://uec-images.ubuntu.com/releases/9.10/release/">http://uec-images.ubuntu.com/releases/9.10/release/</a></td>
</tr>
<tr>
<td>8.04 LTS Hardy Heron</td>
<td><a href="http://uec-images.ubuntu.com/releases/8.04/release/">http://uec-images.ubuntu.com/releases/8.04/release/</a></td>
</tr>
</tbody>
</table>
<p>I&#8217;ve chosen a t1.micro and the latest and greatest 11.04 for my example.  So let&#8217;s do it!  Let&#8217;s finally create an actual, running instance:</p>
<pre class="brush: bash; title: ; notranslate">ec2-run-instances ami-4290a636 --instance-type t1.micro --region eu-west-1 --key ${EC2_KEYPAIR_EU_WEST_1}</pre>
<pre class="brush: plain; title: ; notranslate">RESERVATION r-e61ead90 153873855856 default
INSTANCE i-3c75064a ami-4290a636 pending rwh-ec2 0 t1.micro 2011-06-16T14:59:24+0000 eu-west-1c aki-4feec43b monitoring-disabled ebs paravirtual</pre>
<p>Now we can find out a little bit about our new virtual machine:</p>
<pre class="brush: bash; title: ; notranslate">ec2-describe-instances</pre>
<pre class="brush: plain; title: ; notranslate">RESERVATION r-e61ead90 153873855856 default
INSTANCE i-3c75064a ami-4290a636 ec2-46-137-45-101.eu-west-1.compute.amazonaws.com ip-10-227-167-14.eu-west-1.compute.internal running rwh-ec2 0 t1.micro 2011-06-16T14:59:24+0000 eu-west-1c aki-4feec43b monitoring-disabled 46.137.45.101 10.227.167.14 ebs paravirtual
BLOCKDEVICE /dev/sda1 vol-1be88672 2011-06-16T14:59:44.000Z</pre>
<p>Now we need to open up the SSH port so that we can connect to the machine:</p>
<pre class="brush: bash; title: ; notranslate">ec2-authorize default -p 22</pre>
<pre class="brush: plain; title: ; notranslate">GROUP default
PERMISSION default ALLOWS tcp 22 22 FROM CIDR 0.0.0.0/0</pre>
<p>Now we should be able to see it in the aws web console, and SSH to it:</p>
<pre class="brush: bash; title: ; notranslate">ssh -i ~/.ec2/rwh-ec2/rwh-ec2.pem ubuntu@ec2-56-237-35-121.eu-west-1.compute.amazonaws.com</pre>
<pre class="brush: plain; title: ; notranslate">The authenticity of host 'ec2-56-237-35-121.eu-west-1.compute.amazonaws.com (46.137.45.101)' can't be established.
RSA key fingerprint is 09:99:28:1c:5f:1a:89:f3:f9:6b:b4:83:88:b4:4c:23.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ec2-56-237-35-121.eu-west-1.compute.amazonaws.com,56.237.35.121' (RSA) to the list of known hosts.</pre>
<p>And we&#8217;re in!  Now we can begin to set up and use the instance just like any other Ubuntu server machine.</p>
<p>You will be billed as long the host is running, so you will probably want to shut it down when you&#8217;re done. Note that each partial instance-hour consumed will be billed as a full hour.</p>
<pre class="brush: bash; title: ; notranslate">ec2-terminate-instances &lt;instance_id&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://helms-deep.cable.nu/~rwh/blog/?feed=rss2&#038;p=211</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Lentil soup</title>
		<link>http://helms-deep.cable.nu/~rwh/blog/?p=216&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=lentil-soup</link>
		<comments>http://helms-deep.cable.nu/~rwh/blog/?p=216#comments</comments>
		<pubDate>Tue, 05 Jul 2011 20:03:23 +0000</pubDate>
		<dc:creator>rwh</dc:creator>
				<category><![CDATA[Recipes]]></category>
		<category><![CDATA[carrots]]></category>
		<category><![CDATA[celery]]></category>
		<category><![CDATA[curry]]></category>
		<category><![CDATA[garlic]]></category>
		<category><![CDATA[lentils]]></category>
		<category><![CDATA[onions]]></category>
		<category><![CDATA[stock]]></category>
		<category><![CDATA[tomatoes]]></category>

		<guid isPermaLink="false">http://helms-deep.cable.nu/~rwh/blog/?p=216</guid>
		<description><![CDATA[Tablespoon olive oil 2 Onions, diced 2 Carrots, diced Some celery, diced 1 cup of red lentils 1L of veg stock 1-2 tsp curry powder 1 small tin of tomatoes 4 cloves of garlic, diced salt and pepper Fry the &#8230; <a href="http://helms-deep.cable.nu/~rwh/blog/?p=216">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Tablespoon olive oil<br />
2 Onions, diced<br />
2 Carrots, diced<br />
Some celery, diced<br />
1 cup of red lentils<br />
1L of veg stock<br />
1-2 tsp curry powder<br />
1 small tin of tomatoes<br />
4 cloves of garlic, diced<br />
salt and pepper</p>
<p>Fry the onions, carrots and celery until the onions are translucent.  Add the curry powder and fry a bit more.  Add the stock, lentils, tomatoes and garlic.  Bring to a boil then reduce heat and simmer for 25 mins or until lentils are cooked.  Salt and pepper to taste AND CHILLI. Eat with buttered toast.</p>
]]></content:encoded>
			<wfw:commentRss>http://helms-deep.cable.nu/~rwh/blog/?feed=rss2&#038;p=216</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu&#8217;s Ambiance: selected items in unfocused windows are invisible</title>
		<link>http://helms-deep.cable.nu/~rwh/blog/?p=189&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ubuntus-ambiance-selected-items-in-unfocused-windows-are-invisible</link>
		<comments>http://helms-deep.cable.nu/~rwh/blog/?p=189#comments</comments>
		<pubDate>Mon, 06 Jun 2011 10:13:22 +0000</pubDate>
		<dc:creator>rwh</dc:creator>
				<category><![CDATA[HOWTOs]]></category>
		<category><![CDATA[11.04]]></category>
		<category><![CDATA[ambiance]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[colour]]></category>
		<category><![CDATA[desaturated]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[gray]]></category>
		<category><![CDATA[grey]]></category>
		<category><![CDATA[gtkrc]]></category>
		<category><![CDATA[narwhal]]></category>
		<category><![CDATA[natty]]></category>
		<category><![CDATA[selected]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[unfocused]]></category>

		<guid isPermaLink="false">http://helms-deep.cable.nu/~rwh/blog/?p=189</guid>
		<description><![CDATA[I have a confession to make: I really like Ubuntu&#8217;s design, its look and feel, and its colour scheme.  And it seems to get better with each release.  The new Natty theme is really beautiful, and the dark window decorations &#8230; <a href="http://helms-deep.cable.nu/~rwh/blog/?p=189">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I have a confession to make: I really like Ubuntu&#8217;s design, its look and feel, and its colour scheme.  And it seems to get better with each release.  The new Natty theme is really beautiful, and the dark window decorations of the Ambiance theme are great (especially now that they&#8217;ve chased down the odd dark text on dark background problems).</p>
<p>Having said that, there&#8217;s one thing that I really don&#8217;t like: the way that it&#8217;s virtually impossible to tell what you have selected in windows other than the one that happens to be focused.  This is because the focused elements get completely desaturated, like this:</p>
<div id="attachment_190" class="wp-caption alignnone" style="width: 630px"><a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/06/Unfocused-old.png"><img class="size-full wp-image-190" title="Ambiance unfocused: all desaturated" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/06/Unfocused-old.png" alt="" width="620" height="396" /></a><p class="wp-caption-text">Which items are selected? It&#39;s anyone&#39;s guess!</p></div>
<p><span id="more-189"></span>For comparison, here&#8217;s the same window when it has focus:</p>
<div id="attachment_195" class="wp-caption alignnone" style="width: 630px"><a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/06/Focused-old.png"><img class="size-full wp-image-195" title="Focused version: you can tell what's selected" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/06/Focused-old.png" alt="" width="620" height="396" /></a><p class="wp-caption-text">We can see what&#39;s selected... so long as the window has focus.</p></div>
<p>This is a particular problem when you have two windows containing elements that you&#8217;d like to compare.  If you select these elements, and try to compare them by eye, you&#8217;ll often not be able to tell which one you selected in the unfocused window. <img src='http://helms-deep.cable.nu/~rwh/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>So I set out to change this by fiddling with the arcane theme files.  The one you need to change is:</p>
<pre class="brush: plain; title: ; notranslate">/usr/share/themes/Ambiance/gtk-2.0/gtkrc</pre>
<p>So, the way I did it was to add a new colour for my elements.  Line 1:</p>
<pre class="brush: plain; title: ; notranslate">gtk-color-scheme = &quot;base_color:#ffffff\nfg_color:#4c4c4c\ntooltip_fg_color:#ffffff\nselected_bg_color:#f07746\nselected_fg_color:#FFFFFF\ntext_color:#3C3C3C\nbg_color:#F2F1F0\ntooltip_bg_color:#000000\nlink_color:#DD4814&quot;</pre>
<p>becomes:</p>
<pre class="brush: plain; title: ; notranslate">gtk-color-scheme = &quot;base_color:#ffffff\nfg_color:#4c4c4c\ntooltip_fg_color:#ffffff\nselected_bg_color:#f07746\nselected_fg_color:#FFFFFF\ntext_color:#3C3C3C\nbg_color:#F2F1F0\ntooltip_bg_color:#000000\nlink_color:#DD4814\ntest-color:#f5d8b1&quot;</pre>
<p>Note the addition of the &#8220;\ntest-color:#f5d8b1&#8243; at the end of the line.  Next, we change the elements we want to that colour.  A bit of trial and error here and I found which one.  Line 93 was:</p>
<p>﻿
<pre class="brush: plain; title: ; notranslate">base[ACTIVE]      = shade (0.94, @bg_color)</pre>
<p>and becomes:</p>
<pre class="brush: plain; title: ; notranslate">base[ACTIVE]      = @test-color</pre>
<p>Voila!  Our unfocused window now looks much better:</p>
<div id="attachment_191" class="wp-caption alignnone" style="width: 630px"><a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/06/Unfocused-new.png"><img class="size-full wp-image-191" title="Ambiance unfocused but usable!" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/06/Unfocused-new.png" alt="" width="620" height="396" /></a><p class="wp-caption-text">Now we can tell exactly what&#39;s selected, and it even fits in nicely with the theme.</p></div>
<p>Now just open up the Appearance application, switch to a different theme, then back to Ambiance to load the changes, and enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://helms-deep.cable.nu/~rwh/blog/?feed=rss2&#038;p=189</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Installing Ubuntu on the lenovo ideapad S205</title>
		<link>http://helms-deep.cable.nu/~rwh/blog/?p=177&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=installing-ubuntu-on-the-lenovo-ideapad-s205</link>
		<comments>http://helms-deep.cable.nu/~rwh/blog/?p=177#comments</comments>
		<pubDate>Sun, 05 Jun 2011 11:24:44 +0000</pubDate>
		<dc:creator>rwh</dc:creator>
				<category><![CDATA[HOWTOs]]></category>
		<category><![CDATA[11.04]]></category>
		<category><![CDATA[boot]]></category>
		<category><![CDATA[chroot]]></category>
		<category><![CDATA[dualboot]]></category>
		<category><![CDATA[easybcd]]></category>
		<category><![CDATA[grub]]></category>
		<category><![CDATA[grub2]]></category>
		<category><![CDATA[grublegacy]]></category>
		<category><![CDATA[ideapad]]></category>
		<category><![CDATA[legacy]]></category>
		<category><![CDATA[lenovo]]></category>
		<category><![CDATA[narwhal]]></category>
		<category><![CDATA[natty]]></category>
		<category><![CDATA[network-manager]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[partition]]></category>
		<category><![CDATA[rfkill]]></category>
		<category><![CDATA[S205]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[unblock]]></category>
		<category><![CDATA[usb]]></category>
		<category><![CDATA[wicd]]></category>
		<category><![CDATA[wifi]]></category>
		<category><![CDATA[windows7]]></category>
		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false">http://helms-deep.cable.nu/~rwh/blog/?p=177</guid>
		<description><![CDATA[My girlfriend&#8217;s laptop died recently, and as her birthday was coming up I thought I&#8217;d buy her a new netbook to get her up and running again (well, really, to get my mac back).  For £300 from Amazon, we had &#8230; <a href="http://helms-deep.cable.nu/~rwh/blog/?p=177">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>My girlfriend&#8217;s laptop died recently, and as her birthday was coming up I thought I&#8217;d buy her a new netbook to get her up and running again (well, really, to get my mac back).  For £300 from Amazon, we had a machine that was much like her old laptop; it&#8217;s amazing what you can get for so little money these days.  However, there were two things I didn&#8217;t realise: one, the ideapad-S205 lacks an optical drive (whoops).  The second was that it&#8217;d take me basically a whole day of dicking around to get Ubuntu to dual boot with Windows 7.  I hope this guide will help people out with the second problem (and I solved the first one by buying a USB DVD drive for another £30).<span id="more-177"></span></p>
<p>1. download and install Ubuntu 11.04 on a USB key<br />
- I used the Startup Disk Creator on another Ubuntu machine to create the bootable USB key.</p>
<p>2. Put in the bootable Ubuntu USB key and boot the ideapad.  Press Fn-F11 to get the boot menu, and choose the USB boot device.  The screen will be garbled, seems like an issue with the kernel framebuffer driver.  Just hit enter, and the Ubuntu setup process will start fine.</p>
<p>3. Connect to an ethernet cable as wireless doesn&#8217;t work (says that it&#8217;s disabled by hardware switch despite not being, needs more investigation).</p>
<p><strong>Update:</strong> Turns out that wireless works in 10.10&#8230; OK I have found a workaround for the wireless.  It even works with suspend/resume.  <strong>Update 2:</strong> there&#8217;s an even simpler method in the comments, though I&#8217;ve not tested it myself.   Here&#8217;s how you can connect using wireless:<br />
- connect via the wired ethernet port<br />
- apt-get install wicd<br />
- apt-get remove network-manager<br />
- disconnect the wired ethernet port<br />
- rfkill unblock all<br />
- start wicd from the applications menu, then use it to connect to your wireless connection.</p>
<p>You can have the &#8220;rfkill unblock all&#8221; command run automatically on startup  by adding it to /etc/rc.local above the &#8220;exit 0&#8243; line.  That&#8217;s all you should need to do to have the wireless connection come up automatically when you log in.</p>
<p>Seems like this might be the combination of a couple of bugs, one a configuration problem that necessitates the use of rfkill unblock all, and the other a bug in network-manager.  I will file some bug reports when I get time and post an update here.</p>
<p>4. After the Ubuntu 11.04 environment starts up, double click on the desktop icon to start the install process.  You&#8217;ll eventually read the message: &#8220;This computer currently has Windows 7 on it.  What would you like to do?&#8221;<br />
- I first did the &#8220;Install Ubuntu alongside Windows 7&#8243; option and shrunk the windows partition.  As I later learned, this doesn&#8217;t work because GRUB 2 fails, we need to set up the partitions in a GRUB legacy friendly setup (it requires a boot partition, formatted ext2, as it doesn&#8217;t understand ext4 yet; I&#8217;m not sure what the status of its ext3 support is).  So I restarted the install process and:<br />
- chose the &#8220;Something else&#8221; option.  I deleted the ext4 and swap partitions from the previous install and then used the resulting empty space to set it up like this:<br />
- /dev/sda6 ext2 /boot 255MB<br />
- /dev/sda7 ext4 /    13684MB<br />
- /dev/sda8 swap<br />
- device boot loader installation: /dev/sda6<br />
- proceed through the install, setting up your location and user details, etc.</p>
<p>5. Once the install completes, you will be prompted to restart, however we need to set up GRUB legacy first, so:<br />
- start a terminal (click the button in the top left, type terminal and hit enter, or try ctrl-alt-t).  Then use the following commands (these assume my partition setup from above, modify them if yours differs):<br />
- sudo su<br />
- mkdir /mnt/sda7<br />
- mount /dev/sda7 /mnt/sda7<br />
- cd /mnt/sda7<br />
- mount /dev/sda6 ./boot<br />
- mount &#8211;bind /sys ./sys<br />
- mount &#8211;bind /proc ./proc<br />
- mount &#8211;bind /dev ./dev<br />
- chroot .<br />
In plain English, what we just did was mount the new partitions that we created, in the same configuration that they will be in the new system.  Then we bound all the special filesystems into this, and then we used &#8220;chroot&#8221; a magical command that moves our terminal into our newly setup system, almost as if we&#8217;d just booted into it.  So all our following commands will affect the new system instead of our temporary live USB boot.</p>
<p>6. Follow these instructions to download to grub legacy: https://help.ubuntu.com/community/Grub2#Uninstalling%20GRUB%202<br />
- apt-get update ; apt-get install grub<br />
- update-grub<br />
- yes to generate list<br />
- grub-install /dev/sda6<br />
We&#8217;ve now installed grub legacy in /dev/sda6, which is our ubuntu /boot partition.  We now need to get the Windows 7 bootloader to chain-boot this.  We do this using a little utility called <a title="EasyBCD" href="http://neosmart.net/dl.php?id=1">EasyBCD</a>, though it&#8217;s possible to modify the Windows config files manually if you prefer.</p>
<p>7. Reboot into windows 7.<br />
- download, install and run Easy BCD<br />
- Add new entry<br />
- Linux/BSD tab<br />
- Type: GRUB (Legacy)<br />
- Name: Ubuntu 11.04<br />
- Partition 5 (Linux -244 MiB)<br />
- Click Add Entry<br />
- Edit Boot Menu<br />
- Boot default OS after: change to 4 seconds.<br />
- Save Settings.</p>
<p>8. Reboot, and you should see a boot menu with Windows 7 and Ubuntu 11.04.  Done!</p>
]]></content:encoded>
			<wfw:commentRss>http://helms-deep.cable.nu/~rwh/blog/?feed=rss2&#038;p=177</wfw:commentRss>
		<slash:comments>80</slash:comments>
		</item>
		<item>
		<title>Gridengine the Ubuntu/Debian way</title>
		<link>http://helms-deep.cable.nu/~rwh/blog/?p=159&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=gridengine-on-ubuntu-11-04</link>
		<comments>http://helms-deep.cable.nu/~rwh/blog/?p=159#comments</comments>
		<pubDate>Wed, 01 Jun 2011 12:39:49 +0000</pubDate>
		<dc:creator>rwh</dc:creator>
				<category><![CDATA[HOWTOs]]></category>
		<category><![CDATA[apt]]></category>
		<category><![CDATA[cluster]]></category>
		<category><![CDATA[deb]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[environment]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[gridengine]]></category>
		<category><![CDATA[maverick]]></category>
		<category><![CDATA[parallel]]></category>
		<category><![CDATA[parallelenvironment]]></category>
		<category><![CDATA[qconf]]></category>
		<category><![CDATA[qmon]]></category>
		<category><![CDATA[sge]]></category>
		<category><![CDATA[sun]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://helms-deep.cable.nu/~rwh/blog/?p=159</guid>
		<description><![CDATA[I&#8217;ve had Sun GridEngine running on our cluster of 12-core HP blades from its earliest days. What has not been working is the the inter-host communication (the ability of the system to schedule and distribute jobs across the nodes). I &#8230; <a href="http://helms-deep.cable.nu/~rwh/blog/?p=159">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve had Sun GridEngine running on our cluster of 12-core HP blades from its earliest days. What has not been working is the the inter-host communication (the ability of the system to schedule and distribute jobs across the nodes). I therefore set out to fix this situation. It turns out that the problems that prevented this from working are mainly caused by quirks in the way that the Debian (and by inheritance, Ubuntu) packaging was done.<span id="more-159"></span></p>
<p>Prerequisites for gridengine: Most of the problems that I saw with the Debianised gridengine system are due to a lack of these prerequisites:</p>
<p><strong>1. check the hosts file for localhost.localdomain type entries.</strong> If these are present, they will cause host communication to fail. Ensure that, at minimum, there is an entry in the hosts file of the master for each exec node, and in the hosts file of the exec nodes there should be an entry for the master. For example:</p>
<p>I will set up a cluster between my desktop machine, KWIAT22 and my laptop, caleb.<br />
/etc/hosts on KWIAT22 contains:</p>
<pre class="brush: plain; title: ; notranslate">127.0.0.1       localhost
#127.0.0.1      localhost.localdomain   localhost
129.67.46.129   KWIAT22
129.67.46.255   caleb</pre>
<p>plus some other irrelevant entries. Note that localhost.localdomain is commented out.<br />
/etc/hosts on caleb contains:</p>
<pre class="brush: plain; title: ; notranslate">127.0.0.1       caleb
#127.0.0.1      localhost.localdomain   localhost
129.67.46.255   caleb
129.67.46.129   KWIAT22</pre>
<p>Note again, the localhost.localdomain entry has been commented out.</p>
<p><strong>2. Java is required for inter-host communication.</strong> We will use Sun Java, as it is assumed to be most compatible with Sun GridEngine. Edit /etc/apt/sources.list and uncomment the entries for the partner repository:</p>
<pre class="brush: plain; title: ; notranslate">deb http://archive.canonical.com/ubuntu maverick partner
deb-src http://archive.canonical.com/ubuntu maverick partner</pre>
<p>Then install the JRE:</p>
<pre class="brush: bash; title: ; notranslate">apt-get install sun-java6-jre</pre>
<p>Check which version of java we&#8217;ve got selected:</p>
<pre class="brush: plain; title: ; notranslate">root@caleb:~# java -version
java version &quot;1.6.0_22&quot;
OpenJDK Runtime Environment (IcedTea6 1.10.1) (6b22-1.10.1-0ubuntu1)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)</pre>
<p>From that we can see that I still have OpenJDK selected, so we change that:</p>
<pre class="brush: plain; title: ; notranslate">root@caleb:~# update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                      Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      auto mode
  1            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-6-sun/jre/bin/java       63        manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-6-sun/jre/bin/java to provide /usr/bin/java (java) in manual mode.
root@caleb:~# java -version
java version &quot;1.6.0_24&quot;
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)</pre>
<p>Now that we have these prerequisites satisfied, we can <strong>install the relevant gridengine packages</strong>. Installing gridengine on Ubuntu systems is made simple by the packages. We can install the packages on the master node (in our case KWIAT22):</p>
<pre class="brush: bash; title: ; notranslate">apt-get install gridengine-client gridengine-qmon gridengine-exec gridengine-master</pre>
<p>Configure SGE automatically? Yes<br />
SGE cell name: default<br />
SGE master hostname: KWIAT22 (this should be the fully qualified domain name of the SGE master, not localhost)</p>
<p>Output will typically look something like this:</p>
<pre class="brush: plain; title: ; notranslate">Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  gridengine-common
The following NEW packages will be installed:
  gridengine-client gridengine-common gridengine-exec gridengine-master gridengine-qmon
0 upgraded, 5 newly installed, 0 to remove and 37 not upgraded.
Need to get 0 B/18.7 MB of archives.
After this operation, 44.8 MB of additional disk space will be used.
Do you want to continue [Y/n]?
Preconfiguring packages ...
Selecting previously deselected package gridengine-common.
(Reading database ... 372804 files and directories currently installed.)
Unpacking gridengine-common (from .../gridengine-common_6.2u5-1ubuntu1_all.deb) ...
Selecting previously deselected package gridengine-client.
Unpacking gridengine-client (from .../gridengine-client_6.2u5-1ubuntu1_amd64.deb) ...
Selecting previously deselected package gridengine-exec.
Unpacking gridengine-exec (from .../gridengine-exec_6.2u5-1ubuntu1_amd64.deb) ...
Selecting previously deselected package gridengine-master.
Unpacking gridengine-master (from .../gridengine-master_6.2u5-1ubuntu1_amd64.deb) ...
Selecting previously deselected package gridengine-qmon.
Unpacking gridengine-qmon (from .../gridengine-qmon_6.2u5-1ubuntu1_amd64.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
Setting up gridengine-common (6.2u5-1ubuntu1) ...

Creating config file /etc/default/gridengine with new version
Setting up gridengine-client (6.2u5-1ubuntu1) ...
Setting up gridengine-exec (6.2u5-1ubuntu1) ...
error: communication error for &quot;KWIAT22/execd/1&quot; running on port 6445: &quot;can't bind socket&quot;
error: commlib error: can't bind socket (no additional information available)
..........................
critical error: abort qmaster registration due to communication errors
daemonize error: child exited before sending daemonize state
Setting up gridengine-master (6.2u5-1ubuntu1) ...
Initializing cluster with the following parameters:
 =&gt; SGE_ROOT: /var/lib/gridengine
 =&gt; SGE_CELL: default
 =&gt; Spool directory: /var/spool/gridengine/spooldb
 =&gt; Initial manager user: sgeadmin
Initializing spool (/var/spool/gridengine/spooldb)
Initializing global configuration based on /usr/share/gridengine/default-configuration
Initializing complexes based on /usr/share/gridengine/centry
Initializing usersets based on /usr/share/gridengine/usersets
Adding user sgeadmin as a manager
Cluster creation complete
Setting up gridengine-qmon (6.2u5-1ubuntu1) ...</pre>
<p>Note that the execd cannot bind the socket. This occurs because of a left-over execd that failed to stop from a previous install. It also results if you don&#8217;t have java installed, as the execd won&#8217;t respond to /etc/init.d/gridengine-exec stop without java. Also, if you&#8217;re doing an apt-get purge gridengine-* to get back to a fresh slate, typically the execd will not be stopped properly, despite being removed from the system. This can be fixed by:</p>
<pre class="brush: plain; title: ; notranslate">root@KWIAT22:~# ps aux |grep sge
sgeadmin 22244 0.0 0.0 135172 4940 ? Sl 17:42 0:00 /usr/lib/gridengine/sge_qmaster
sgeadmin 24272 0.0 0.0  58688 2500 ? Sl May16 0:22 /usr/lib/gridengine/sge_execd
root@KWIAT22:~# kill 24272
root@KWIAT22:~# /etc/init.d/gridengine-exec start
root@KWIAT22:~# /etc/init.d/gridengine-master restart
 * Restarting Sun Grid Engine Master Scheduler sge_qmaster</pre>
<p>The logfiles we can use for tracking down problems in communication between the qmaster and execd processes are not in the standard debian/ubuntu locations. Instead, they are stored in /var/spool/gridengine/execd/messages for the qmaster and /tmp/execd_messages.[pid] or /var/spool/gridengine/execd/messages for the execd processes. The log messages for our previous socket problem look like this (/tmp/execd_messages.24107):</p>
<pre class="brush: plain; title: ; notranslate">05/16/2011 20:17:16|  main|KWIAT22|E|communication error for &quot;KWIAT22/execd/1&quot; running on port 6445: &quot;can't bind socket&quot;
05/16/2011 20:17:17|  main|KWIAT22|E|commlib error: can't bind socket (no additional information available)
05/16/2011 20:17:45|  main|KWIAT22|C|abort qmaster registration due to communication errors
05/16/2011 20:17:47|  main|KWIAT22|W|daemonize error: child exited before sending daemonize state</pre>
<p>If you see any lines containing |E| then you have an error that must be addressed. Any lines with |W| are warnings, and it&#8217;s probably wise to fix those too.</p>
<p>On the exec nodes:</p>
<pre class="brush: bash; title: ; notranslate">apt-get install gridengine-exec</pre>
<p>Configure SGE automatically? yes<br />
SGE cell name: default<br />
SGE master hostname: KWIAT22</p>
<p>After installing, you will see the following error in the /tmp/exed_messages.[pid] file and the process will exit:</p>
<pre class="brush: plain; title: ; notranslate">05/18/2011 17:53:00|  main|caleb|E|getting configuration: denied: host &quot;caleb&quot; is neither submit nor admin host
05/18/2011 17:53:05|  main|caleb|C|can't get configuration qmaster - terminating</pre>
<p>This occurs because the master doesn&#8217;t yet know about the exec node. We need to set up a basic configuration on the master. We will use the documentation in /usr/share/doc/gridengine-common/README.Debian, which I will duplicate here, to form the basis of our configuration:</p>
<pre class="brush: plain; title: ; notranslate">Once you've installed SGE, you'll need to do at least some minimal
cluster configuration.

Quickstart
==========

 * Install gridengine-master, gridengine-exec and gridengine-client
   on the appropriate hosts.

 * Initially, only the sgeadmin user has admin privileges

 * It is suggested that you add yourself as a manager and
   perform the rest of these tasks as your own user:
   + sudo -u sgeadmin qconf -am myuser

 * and to a userlist:
   + qconf -au myuser users

 * Add a submission host:
   + qconf -as myhost.mydomain

 * Add an execution host:
   + qconf -ae
   You will now be prompted for information about the execution host.

 * Add a new host group:
   + qconf -ahgrp @allhosts

 * Add the exec host to the @allhosts list:
   + qconf -aattr hostgroup hostlist myhost.mydomain @allhosts

 * Add a queue:
   + qconf -aq main.q

 * Add the host group to the queue:
   + qconf -aattr queue hostlist @allhosts main.q

 * Make sure there is a slot allocated to the execd:
   + qconf -aattr queue slots &quot;[myhost.mydomain=1]&quot; main.q

 * Running qstat -f should then show you the execd waiting for jobs</pre>
<p>The commands that I ran in my example:</p>
<pre class="brush: bash; title: ; notranslate">sudo su
sudo -u sgeadmin qconf -am rwh
exit
qconf -au rwh users
qconf -as KWIAT22
qconf -ahgrp @allhosts  # just save the file without modifying it
qconf -aattr hostgroup hostlist KWIAT22 @allhosts
qconf -aq main.q # just save the file without modifying it
qconf -aattr queue hostlist @allhosts main.q
qconf -aattr queue slots &quot;4, [KWIAT22=3]&quot; main.q # 4 by default for all nodes, 3 specifically for KWIAT22, which leaves 1 of the 4 cpus free for the master process</pre>
<p>we then add caleb as a submit and exec host:</p>
<pre class="brush: bash; title: ; notranslate">qconf -as caleb
qconf -ae # change the hostname entry to caleb
qconf -aattr hostgroup hostlist KWIAT22 @allhosts</pre>
<p>Once this is done, we need to start the execd on caleb</p>
<pre class="brush: bash; title: ; notranslate">/etc/init.d/gridengine-exec start</pre>
<p>Check that it doesn&#8217;t create a log file in /tmp/execd_messages.[pid]. If it doesn&#8217;t then it&#8217;s happy! Back on our master node, a qstat -f should now show us all set up. You can use the GUI qmon tool to get a better look at the setup. To use qmon, you must ssh to the master node with X11 forwarding enabled:</p>
<pre class="brush: bash; title: ; notranslate">ssh -X hostname
qmon</pre>
<p>Click the queue control button and then the Hosts tab. If the exec nodes are communicating properly with the master, you should see them listed there, and they should NOT have dashes for the information columns. If a node does show dashes, it&#8217;s not communicating correctly, and you&#8217;ll need to go look in the log files for the reason. Note that if java is not installed, the communication between nodes will not work, and this may or may not show up in the log files.</p>
<div id="attachment_174" class="wp-caption alignnone" style="width: 744px"><a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/06/qmon-fail-communication.png"><img class="size-full wp-image-174" title="qmon failing to communicate with the exec node" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/06/qmon-fail-communication.png" alt="" width="734" height="216" /></a><p class="wp-caption-text">Failure to communicate with the exec node, caleb</p></div>
<div id="attachment_175" class="wp-caption alignnone" style="width: 744px"><a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/06/qmon-success-communication.png"><img class="size-full wp-image-175" title="qmon successful communication" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/06/qmon-success-communication.png" alt="" width="734" height="216" /></a><p class="wp-caption-text">    Success communicating with the exec node, caleb, after installing and selecting Sun Java.</p></div>
<p>Next, we need to set up a <strong>parallel environment</strong>. This will allow gridengine to start processes on the remote exec nodes. We can do this with qmon, though it&#8217;s also possible with the CLI tools. In qmon, click the bottom left button, <strong>Parallel Environment Configuration</strong>. Click <strong>Add</strong>. In our example, we&#8217;re setting up the simplest form of parallel environment, which doesn&#8217;t include any message passing functionality. Set the Name to <strong>simple_pe</strong>. In our case, we have two 4-core machines, with one core reserved for the master process, so we have 7 slots. The rest we leave as default values, just click <strong>OK</strong>, then click <strong>done</strong>. Now click the top, second from the left, button <strong>Cluster Queues</strong>. On the Cluster Queues tab, click main.q, then click Modify. Click the parallel environment tab, then click simple_pe and move it over to the referenced PEs box. Click OK, and Done.</p>
<p>Lastly, you need to <strong>set up passwordless ssh access</strong> from the master node to the exec nodes for the users of the gridengine system. This is left as an exercise for the reader, but you might start with learning about <a title="OpenSSH key management" href="http://www.ibm.com/developerworks/library/l-keyc/index.html" target="_blank">OpenSSH key management</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://helms-deep.cable.nu/~rwh/blog/?feed=rss2&#038;p=159</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Scripting class, answers 1</title>
		<link>http://helms-deep.cable.nu/~rwh/blog/?p=134&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=scripting-class-answers-1</link>
		<comments>http://helms-deep.cable.nu/~rwh/blog/?p=134#comments</comments>
		<pubDate>Wed, 30 Mar 2011 16:42:20 +0000</pubDate>
		<dc:creator>rwh</dc:creator>
				<category><![CDATA[answers]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://helms-deep.cable.nu/~rwh/blog/?p=134</guid>
		<description><![CDATA[1. In firefox, right click on an image and do Copy link location. Then use that link in your script. {1..21} is shorthand for the space separated list from 1 to 21, i.e.: &#8220;1 2 3 4 5 6 7 &#8230; <a href="http://helms-deep.cable.nu/~rwh/blog/?p=134">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>1. In firefox, right click on an image and do Copy link location.  Then use that link in your script.  {1..21} is shorthand for the space separated list from 1 to 21, i.e.: &#8220;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21&#8243;.</p>
<p>[ $ii -le 21 ] is shorthand for &#8220;test $ii -le 21&#8243;</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># using a for loop</span>
<span style="color: #000000; font-weight: bold;">for</span> ii <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">1</span>..<span style="color: #000000;">21</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #ff0000;">&quot;http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img<span style="color: #007800;">${ii}</span>.jpg&quot;</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># using a while loop</span>
<span style="color: #007800;">ii</span>=<span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$ii</span> <span style="color: #660033;">-le</span> <span style="color: #000000;">21</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;"># spaces are required</span>
<span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #ff0000;">&quot;http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img<span style="color: #007800;">${ii}</span>.jpg&quot;</span>
        <span style="color: #007800;">ii</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$ii</span> + <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #666666; font-style: italic;"># spaces are required</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>For an interesting discussion: why did I use ii for my incrementer instead of i?</p>
<p>2. Note the double quotes, which are required to escape the filenames which contain special characters (spaces and parentheses).  It is always good practice to wrap variables that contain filenames in double quotes for this reason.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #000000; font-weight: bold;">in</span> img<span style="color: #000000; font-weight: bold;">*</span>.jpg
<span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #780078;">`basename &quot;$file&quot; .jpg`</span> (modified).jpg&quot;</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>3. First, make sure imagemagick is installed:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> imagemagick</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #000000; font-weight: bold;">in</span> img<span style="color: #000000; font-weight: bold;">*</span>\ \<span style="color: #7a0874; font-weight: bold;">&#40;</span>modified\<span style="color: #7a0874; font-weight: bold;">&#41;</span>.jpg 
<span style="color: #000000; font-weight: bold;">do</span> 
        convert <span style="color: #660033;">-resize</span> <span style="color: #000000;">50</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #780078;">`basename &quot;$file&quot; .jpg`</span> (small).jpg&quot;</span> 
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>4. First, we install the software we need:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> vorbis-tools
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">lame</span></pre></div></div>

<p>Then we convert the files:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>helms-deep.cable.nu<span style="color: #000000; font-weight: bold;">/</span>~rwh<span style="color: #000000; font-weight: bold;">/</span>files<span style="color: #000000; font-weight: bold;">/</span>lara_st_john.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> xvzf lara_st_john.tar.gz
<span style="color: #7a0874; font-weight: bold;">cd</span> lara_st_john<span style="color: #000000; font-weight: bold;">/</span>bach_violin_concertos
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">*</span>.ogg
<span style="color: #000000; font-weight: bold;">do</span>
        oggdec <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span>
        <span style="color: #c20cb9; font-weight: bold;">lame</span> <span style="color: #660033;">--vbr-new</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span> .ogg<span style="color: #000000; font-weight: bold;">`</span>.wav <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span> .ogg<span style="color: #000000; font-weight: bold;">`</span>.mp3
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p><a name=script_ans_5>5. First, we extract the track information from the ogg file using the vorbiscomment command and save it in a temporary file.  Then we use grep and sed to select each datum and save it in a shell variable.  Once we have all this info ready, we can decode the ogg file to wav, then encode the wav to mp3, passing in the shell variables which contain the track information.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">*</span>.ogg
<span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #007800;">base</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span> .ogg<span style="color: #000000; font-weight: bold;">`</span>
        vorbiscomment <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$base</span>.comment&quot;</span>
        <span style="color: #007800;">tt</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;^title&quot;</span>  <span style="color: #ff0000;">&quot;<span style="color: #007800;">$base</span>.comment&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/title=\(.*\)$/\1/'</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #007800;">ta</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;^artist&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$base</span>.comment&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/artist=\(.*\)$/\1/'</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #007800;">tg</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;^genre&quot;</span>  <span style="color: #ff0000;">&quot;<span style="color: #007800;">$base</span>.comment&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/genre=\(.*\)$/\1/'</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #007800;">ty</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;^date&quot;</span>   <span style="color: #ff0000;">&quot;<span style="color: #007800;">$base</span>.comment&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/date=\(.*\)$/\1/'</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #007800;">tl</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;^album&quot;</span>  <span style="color: #ff0000;">&quot;<span style="color: #007800;">$base</span>.comment&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/album=\(.*\)$/\1/'</span><span style="color: #000000; font-weight: bold;">`</span>
        oggdec <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span>
        <span style="color: #c20cb9; font-weight: bold;">lame</span> <span style="color: #660033;">--vbr-new</span> <span style="color: #660033;">--tt</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$tt</span>&quot;</span> <span style="color: #660033;">--ta</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$ta</span>&quot;</span> <span style="color: #660033;">--tg</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$tg</span>&quot;</span> <span style="color: #660033;">--ty</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$ty</span>&quot;</span> <span style="color: #660033;">--tl</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$tl</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$base</span>.wav&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$base</span>.mp3&quot;</span>
        <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$base</span>.comment&quot;</span>
        <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$base</span>.wav&quot;</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://helms-deep.cable.nu/~rwh/blog/?feed=rss2&#038;p=134</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scripting class questions 1</title>
		<link>http://helms-deep.cable.nu/~rwh/blog/?p=105&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=scripting-class-questions-1</link>
		<comments>http://helms-deep.cable.nu/~rwh/blog/?p=105#comments</comments>
		<pubDate>Mon, 28 Mar 2011 23:49:45 +0000</pubDate>
		<dc:creator>rwh</dc:creator>
				<category><![CDATA[questions]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://helms-deep.cable.nu/~rwh/blog/?p=105</guid>
		<description><![CDATA[Loops 1. using wget or curl, and a for loop, download all of the following images: 2. using a loop, backticks (`) and the basename command, rename all of the images, adding &#8220;(modified)&#8221; to their filenames 3. using a loop, &#8230; <a href="http://helms-deep.cable.nu/~rwh/blog/?p=105">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><strong>Loops</strong></p>
<p>1. using wget or curl, and a for loop, download all of the following images:</p>
<p><a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img1.jpg"> <img class="alignnone size-thumbnail wp-image-109" title="img1" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img1-150x150.jpg" alt="" width="150" height="150" /></a> <a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img2.jpg"><img class="alignnone size-thumbnail wp-image-111" title="img2" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img2-150x150.jpg" alt="" width="150" height="150" /></a> <a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img3.jpg"><img class="alignnone size-thumbnail wp-image-112" title="img3" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img3-150x150.jpg" alt="" width="150" height="150" /></a> <a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img4.jpg"><img class="alignnone size-thumbnail wp-image-113" title="img4" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img4-150x150.jpg" alt="" width="150" height="150" /></a> <a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img5.jpg"><img class="alignnone size-thumbnail wp-image-114" title="img5" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img5-150x150.jpg" alt="" width="150" height="150" /></a> <a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img6.jpg"><img class="alignnone size-thumbnail wp-image-115" title="img6" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img6-150x150.jpg" alt="" width="150" height="150" /></a> <a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img7.jpg"><img class="alignnone size-thumbnail wp-image-116" title="img7" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img7-150x150.jpg" alt="" width="150" height="150" /></a> <a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img8.jpg"><img class="alignnone size-thumbnail wp-image-117" title="img8" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img8-150x150.jpg" alt="" width="150" height="150" /></a> <a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img9.jpg"><img class="alignnone size-thumbnail wp-image-118" title="img9" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img9-150x150.jpg" alt="" width="150" height="150" /></a> <a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img10.jpg"><img class="alignnone size-thumbnail wp-image-119" title="img10" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img10-150x150.jpg" alt="" width="150" height="150" /></a> <a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img11.jpg"><img class="alignnone size-thumbnail wp-image-120" title="img11" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img11-150x150.jpg" alt="" width="150" height="150" /></a> <a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img12.jpg"><img class="alignnone size-thumbnail wp-image-121" title="img12" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img12-150x150.jpg" alt="" width="150" height="150" /></a> <a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img13.jpg"><img class="alignnone size-thumbnail wp-image-122" title="img13" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img13-150x150.jpg" alt="" width="150" height="150" /></a> <a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img14.jpg"><img class="alignnone size-thumbnail wp-image-123" title="img14" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img14-150x150.jpg" alt="" width="150" height="150" /></a> <a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img15.jpg"><img class="alignnone size-thumbnail wp-image-124" title="img15" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img15-150x150.jpg" alt="" width="150" height="150" /></a> <a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img16.jpg"><img class="alignnone size-thumbnail wp-image-125" title="img16" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img16-150x150.jpg" alt="" width="150" height="150" /></a> <a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img17.jpg"><img class="alignnone size-thumbnail wp-image-126" title="img17" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img17-150x150.jpg" alt="" width="150" height="150" /></a> <a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img18.jpg"><img class="alignnone size-thumbnail wp-image-127" title="img18" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img18-150x150.jpg" alt="" width="150" height="150" /></a> <a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img19.jpg"><img class="alignnone size-thumbnail wp-image-128" title="img19" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img19-150x150.jpg" alt="" width="150" height="150" /></a> <a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img20.jpg"><img class="alignnone size-thumbnail wp-image-129" title="img20" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img20-150x150.jpg" alt="" width="150" height="150" /></a> <a href="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img21.jpg"><img class="alignnone size-thumbnail wp-image-130" title="img21" src="http://helms-deep.cable.nu/~rwh/blog/wp-content/uploads/2011/03/img21-150x150.jpg" alt="" width="150" height="150" /></a></p>
<p>2. using a loop<strong></strong>, backticks (`) and the basename command, rename all of the images, adding &#8220;(modified)&#8221; to their filenames</p>
<p>3. using a loop, backticks, basename, and the convert command (part of the imagemagick image processing suite), resize all of the images to 50% of their original size</p>
<p>4. using wget or curl,tar, a loop, oggdec and lame, convert the following files into mp3s:</p>
<p><a href="http://helms-deep.cable.nu/~rwh/files/lara_st_john.tar.gz">http://helms-deep.cable.nu/~rwh/files/lara_st_john.tar.gz</a></p>
<p>5. (hard) repeat question 4, but retain all ID3 tag information.</p>
<p>6. Use a loop and the &#8220;uptime&#8221; and &#8220;free&#8221; commands to record the system load once a minute for the duration of the class.  Store the information in CSV format.  Use a spreadsheet to draw graphs of this information.</p>
<p><strong>File management</strong></p>
<p>1. Download the following tar.gz, and extract it using the tar command.  In the resulting directory, find the newest file that matches name-asdf*.</p>
<p><strong>System commands</strong></p>
<p>1. Write a cron job that will email you the free space on your hard disk once per hour.  Its output should be:</p>
<p>Hello, your hard disk has X% of hard drive space remaining!</p>
<p>2. Using the &#8220;du&#8221; command, find out which of the directories in the root directory of your hard drive is using the most hard disk space.  Suggest some files you might delete if you were running out of space.</p>
<p>3. Use the find command to return a list of the files in your home directory that you have modified in the last week.  Exclude anything that is not a regular file.</p>
<p><strong>Regular expressions</strong></p>
<p><strong>VIM</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://helms-deep.cable.nu/~rwh/blog/?feed=rss2&#038;p=105</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
