A new home

I’ve moved the blog again!

I got fed up with it being under hasnbang0.com/blog, I decided to move it to it’s own subdomain.  The reason it was bugging me was that it was mixed in with all of my other files.  I needed to make scripts test to make sure it didn’t touch the blog files, and that was a nuisance (simple, but a nuisance).

So, here we are: blog.hashbang0.com

Please update any links, and your RSS/Atom feeds, here are the updated feed links:

  • RSS 2.0
  • RSS .92
  • Atom 0.3 I’ve no plans to move from now on, and I’m going to do a bit of trickery to make hashbang0.com/blog still work for anyone who really doesn’t want to update their links.

Apple releases new iTunes and OS X v10.6.4, another release predicted prior to iPhone 4 release?

Yesterday Apple released iTunes 9.2 touting the following enhancements:

  • Sync with iPhone 4 to enjoy your favorite music, movies, TV shows, books and more on-the-go
  • Sync and read books with iPhone or iPod touch with iOS 4 and iBooks 1.1
  • Organize and sync PDF documents as books. Read PDFs with iBooks 1.1 on iPad and any iPhone or iPod touch with iOS 4
  • Organize your apps on your iOS 4 home screens into folders using iTunes
  • Faster back-ups while syncing an iPhone or iPod touch with iOS 4
  • Album artwork improvements make artwork appear more quickly when exploring your library I got excited about the first point there, not because I’ve ordered an iPhone, but because if my Mac can sync with one, I should have the iPhone 4 icon.  However, I don’t…

Looking in /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources reveals the old iPhone icons and plenty of Mac and iPod Touch/iPad icons, but no iPhone 4 icon.

I think this means Apple will be releasing either a ‘point’ update for iTunes (perhaps 9.2.1) or another small update somewhere else along the way.

Can Apple see a time when they no longer produce the Mac?

Ars Technica published this article the other day which says how Apple are not awarding Mac applications the Apple Design Award this year and are instead focussing on the iPhone and the iPad.

It’s true that Apple have been pumping out some great mobile devices since 2007, but each year at WWDC we see more and more iPhone and iPhone OS stuff than we do Mac hardware and OS X development.  Since the iPhone launched back in 2007 we’ve had two revisions of OS X in the form of Leopard and Snow Leopard (while there has been three (almost four) releases of the iPhone OS), and these have been treated somewhat like an afterthought to the big iPhone/iPod Touch news.

Even in the Mac hardware we’ve seen Apple take a very mobile attitude since the turn of the century.  Look at TV, you’ll see MacBook Pros and PowerBooks and TiBooks all over the place.  All the while the iMac has really taken over as Apple’s main desktop system, even that came with a handle when it was first introduced in 1998 and now the iMac is so slim that it’s very portable in itself (OK fine, you couldn’t sling it in your rucksack, but slinging it in the car is a hell of a lot easier than slinging a Mac Pro in the car!).

In January Apple announced the iPad, and in less than 60 days it has sold 2,000,000 of them!

I’ve just been watching some of the videos from the D8 conference and Steve Jobs was asked this questions by Walk Mossberg: > “Is the tablet going to eventually replace the PC?” This was Steve’s reply: > “PC’s are going to be like trucks, they’re still going to be around, they’re still going to have a lot of value. But they’re going to be used by one out of X people.  And this transformation is going to make some people uneasy, people from the PC world like you and me, it’s going to make us uneasy because the PC has taken us a long way, it’s brilliant.  And we like to talk about the post-PC era, but when it really starts to happen, I think it’s uncomfortable for a lot of people.  And because it’s change, and a** lot of vested interests are going to change** and it’s going different.” Check out the video here, the question pops up around 3:53

So, Steve at least can see a time when the PC is going to be less important.  He is reluctant to give an estimation, but could we see Apple starting to roll the ball now?

With the increased attention on Apple’s mobile devices such as the iPod, iPhone, and now the iPad, increased portability of the Mac platform, the mobile hardware, and dropping the Apple Design Awards for Mac applications, I think Apple are stating their position for the future: Computing is going mobile, and we’re here to lead it.

The End of an Era...

Graduating on the 15th of July means that I am no longer tied to the Aberystwyth University, legally no longer a student, and at the end of my 18 year ‘career’ in education…

Coming to Aberystwyth back in 2006, I recall moving into my house in PJM (91, room C) with my family, Mum fussing about unpacking everything in my room, and my sister shoving all of my kitchen stuff in my cupboard (I never knew exactly what I had in that cupboard until I moved out the following summer).  I recall them leaving and being terrified to go downstairs, when I had plucked up the courage to go downstairs to meet my new housemates I was greeted by a friendly face offering me a cup of tea.  This friendly face was, of course, Faye’s and we spent many hours sitting in that kitchen drinking tea. The year went on and I met new people, learnt new things, and had some wonderful times.  Perhaps most memorable is the ‘snow day’ in late February 2007, the revision sessions with seven of us crammed into my PJM room and generally ended up with Street Fighter being played on my SNES, and the long summer days playing frisbee on the University grounds.

After a long summer working, second year was upon me.  New lessons to be learnt, both in University (computer architecture, network programming, data structures and more) and in life (managing bills and other household issues).  Shortly into my second year Faye and I started going out, meaning we’ve been together just over two and a half years as I write this. The second year saw me get an interview with Sun Microsystems and after an exam in January 2008, I was offered the job.  Revisions sessions got bigger and moved to lecture halls with projectors and elaborate slide shows. The most memorable events of second year has to include mine and Faye’s “one month anniversary” dinner (after spending all day working, we were just about to get ready to go out when a friend knocked on the door and had us talking for three hours.  After getting ready and finding a restaurant that was still serving, we managed to order lots of tapas, but they refused to make us paella), and going to see Bill Bailey perform Tinselworm in Birmingham.

As soon as second year finished, I was plunged into yet new situations.  Moving from Aberystwyth to Camberley, I started work at Sun Microsystems.  Rather than go into any sort of detail here, I’ll direct you to my various postings of which there was one a week detailing what I was up to in Sun. Sun gave me a lot of new skills, and made me realise what I was interested in and that what I learnt at University might actually not be much use in the big wide world… I loved being at Sun, everything about working, and working for a company that did what I wanted to do, and in a way in which I wanted to do it.  I hope that I have a similar employer in the future.

After spending the summer working for the MOD, I entered my final year of University.  It was difficult to get back into lectures, and I found coursework terribly difficult to get on with.  I was constantly pining to be back at Sun, back at my desk in GMP03 collecting tickets, tinkering with servers, and having a chat and a laught with the great people around me. Of course, I had to go on.  The first semester didn’t hold much for me, apart from an overly crowded timetable.  After a terrible Christmas, I was back to do terribly in my exams (all passes, but not great ones). Semester two came and went.  It was filled with loathing for my degree and a want to break out of the formalities and just learn things that would be relevant to me.

So would I do it again?  If I knew then what I do now, well, I wouldn’t do a computer science degree would I?  I’d already know it all :P Seriously, University itself hasn’t always been a happy experience, and of late it’s been the cause of much anger.  But the people I have met and the relationships I have gained have been so great, how could I turn that down?

So, after four years, it comes to a rather awkward end: I’m still here in Aberystwyth, I will be for the next 24-30 months as Faye finishes her masters in fine art.  I am looking for work, hopefully something IT based, but I’ve just got to pay the bills. If you are thinking of coming to Aberystwyth University, I’d advise that you have made the correct choice.  If you want to email me about it, I’d be happy to answer your email, and if you have an interest in anything you see on my blog or on my website, I would be thrilled to meet up and share a quiet pint chatting about it with you!  Drop me a line to arrange a time.

If you know me and are reading this, now, in six months time, or six years time, send me an email and say hi, I’d love to hear from you too :)

Remote Volume, the Geeky Way

Today I was sitting in the chair watching a film playing on my Mac Pro.  After much getting up and sitting back down to turn the light off, tilt the screen, etc. I found that the sound was too quiet, and I was darned if I was going to get up again! I had my MacBook sitting on my lap, and was sure I could change the volume from that.

After some searching, I found some magic AppleScript to do the job for me!  After some remembering, I managed to execute that AppleScript on the command line.  Here’s what I did:

The first command showed me what the current settings were, and the second command allowed me to change the volume to 50%.

Dissertation is over...

I meant to blog about this ages ago!  Better late than never I suppose…

Back in April (April 22nd to be precise) I handed in two copies of my 72 page document which outlines everything about my project.  I wanted to blog about my dissertation while I was doing it, but the thought was always pushed back by other thoughts of actually doing the project.

The project investigated how one could use virtualisation techniques of today and use them to virtualise every application on a machine.  Here’s a copy of my abstract: > In computing, occasionally an application can cause a whole system to be brought down. This wastes valuable time for users and has the potential to lose unsaved data. This project sets out to create a concept whereby applications are virtualised for overall system stability and which appears completely transparent to the end user. The project attempts to create a system based on this concept using OpenSolaris 2009.06 and a number of its technologies, most notably: Zones.

The project discovers that the choice of technologies used are not yet mature enough to implement the concept, though they are very close to maturing. As the abstract says, I used OpenSolaris Zones to implement the concept.  I created a script which wraps around the OpenSolaris `pkg` command which is used to install applications.  My script creates a new Zone and installs the new application into that Zone.  The application is now basically in it’s own operating system, to better describe it, it’s as if the application has been installed onto a whole new machine.  The application is accessed using SSH and tunneling X11 over it, this worked quite well after I had set up the infrastructure, but the user had to input their password when they wanted to launch an application.

The project was really fun, I really enjoyed it and learnt so much.  Now it’s finished I’m rather lost as to what to do with myself…

If anyone would like to read my Dissertation or try implementing my project (with is licensed under the BSD licence), please don’t hesitate to contact me.  At the end of it all, the documentation consisted of 72 pages in PDF form (that was 1086 lines of LaTeX, excluding comments and blank lines), and the project consisted of 1494 lines of Bash script and 1393 comments!

Changes to the site

So, over the last week and last night I have been working on a script to automagically generate galleries, not that that is finished I have a brand new gallery up and running.

I have also created a breadcrumb script, in the status bar of the window you should see a new breadcrumb trail :)

The following browsers are supported 100%:

  • Camino 2.0.3
  • Firefox 3.5.8
  • Opera 10.10
  • Safari 4.0.5
  • Chrome 5.0.375.55
  • Lynx 2.8.7rel.1 (Yes, that’s right, it works very well in a text browser too!)

Please send me any feedback on the new design :)

Sun VirtualBox becomes Oracle VirtualBox and grows into version 3.2

So Oracle had Sun for a fair while now, all of the sites have been rebranded, and finally, as of Tuesday, the stable release of VirtualBox was also rebranded.

The icon has finally changed, see below for the old and new:

[][2]

With the update comes a raft of new features including:

  • Latest Intel hardware support
  • Large Page support
  • In-hypervisor Networking
  • Storage I/O subsystem
  • Remote Video Acceleration
  • Page Fusion
  • Memory Ballooning
  • Hot-plug CPU’s
  • Virtual SAS Controller
  • Online Snapshot Merging
  • OVF Enhancements
  • Guest Automation
  • USB Keyboard and Mouse
  • Oracle Enterprise Linux 5.5
  • Ubuntu 10.04 (“Lucid Lynx”)
  • Mac OS X – On Apple hardware only

[2]:

Robust Bash Scripts - Part Four

This is part of a series of posts which should aid anyone writing Bash scripts to make them more robust.

This post describes how you can use traps to help your code fail more gracefully.

Sometimes you write a script, it fails, and leaves a shed load of temporary files over your file system.  Or perhaps (like in part two) some stuff gets set up, your script fails and leaves a network half set up or a naming service half completed.  Whatever the problem, we can trap them (well, almost all of them…).

For my example, I’m going to use a section of my dissertation.  I have a script which is called “INSTALL.sh”, this sets some stuff up itself, and also delegates some tasks to other scripts.  Here is the general gist:

Check for root permissions - If no permissions, exit with status 1 Move some files about Create some directories and move files to those directories Call a script to set up the network Install NIS (A.K.A. YP) Set up NIS Set up ability to share home directories Call a script to set up a Solaris Zone (virtual machine) Move a customised file over a system file Call a cleanup function

Now, if any part of that script goes wrong, the script will fail (it will because I’ve used the “set -e” option).  If the script exists half of the configuration is done, and if you try to run the script again, it will fail because some of the setup is already complete.

To get out of this horrible situation, I have used a trap.  If the script exists with an exit status of 1 or greater, or if it is interrupted by a HUP, INT, QUIT or TERM signal, it will be trapped and run a function called “abort”.  Here is my trap statement:

trap ‘abort’ 1 2 3 15

My “about” method looks something like this:

abort(){

echo “ABORTING!  Please take note of any warnings!” #If pkg-manage exists, rename it to pkg if [[ -a /usr/bin/pkg-manage ]]; then rm /usr/bin/pkg mv /usr/bin/pkg-manage /usr/bin/pkg fi #Call cleanup to clear away temp files cleanup #Remove contents of /var/vaes rm -rf /var/vaes #Remove config file rm $CONFIG_FILE #Uninstall NIS & related things pkg uninstall SUNWyp domainname "" rm /etc/defaultdomain cp /etc/nsswitch.files /etc/nsswitch.conf zfs set sharenfs=off rpool/export/home cat /etc/auto_home | grep -v "`hostname`:/export/home" > /tmp/auto_home mv /tmp/auto_home /etc/auto_home #Delete zones dir POOL=`zfs list | awk '{ print $1 }' | grep "export" | sed 's/([a-zA-Z]*)/.*/1/g' | head -1` zfs destroy -Rf $POOL/export/vaes-zones #Undo zones bash /tmp/zone_setup.sh abort #Undo networking bash /tmp/network_setup.sh abort }

By using the trap statement, you can clean up after your failed script in the majority of cases.  A word of warning though: You cannot trap the KILL (or 9) signal, if your script fails because it has received a KILL signal, it will just exit.

Robust Bash Scripts - Part Three

This is part of a series of posts which should aid anyone writing Bash scripts to make them more robust.

This post offers some advice on how to Bash script defensively.

Be Prepared is the old Scout motto, and never is it more relevant then when scripting in Bash (or any language come to think of it).

Missing files and directories

If you are going to be working with files and directories in Bash (and you probably will be 99.9% of the time) you should test to see if they exist.

You can do a very generic test like this:

MYFILE=/tmp/test

if [[ -e $MYFILE ]]; then #Do something else #Do something else #Perhaps create file/directory fi

The “-e” will test for the existence of ANY file, including directories.  You will probably be better off using “-d” for directories though, and “-f” for regular files, see the man page for more information about test (use the command “man test” or “help test”).

If you are creating a directory somewhere like “/opt/local/share/lib/foo/bar”, you should either test for the existence of each folder, or you can simple used the “-p” flag on the “mkdir” command, this will create any folders that aren’t created.

Spaces

Sometimes your script will deal with text that has spaces in it, and you need to be prepared for that, even if you are sure it will never need to handle spaces, there will always be one occasion somewhere down the line.

If we take this example:

for EACH in $@;

do echo $EACH done

Say the input to the script reads something like this: bash myscript.sh hashbang0 “Ben Lavery” Aberystwyth The for loop shown previously would print out the output like this: hashbang0 Ben Lavery Aberystwyth

If we quote the $@ like this:

for EACH in "$@";

do echo $EACH done

The output now becomes:

hashbang0 Ben Lavery Aberystwyth

Failing Gracefully

If you are updating a lot of files in a directory, what happens if your script fails halfway through?  Half of your files are unmodified, and the other half are modified.  This could be disastrous, especially in something like a directory full of web documents.

One solution is to copy the contents of the folder before you start working on them, do the work, move the copied files over the old files.  Something a bit like this:

cp -a /tmp/mydir /tmp/mydir-temp

#modify files in /tmp/mydir-temp mv /tmp/mydir /tmp/mydir-BAK #backup mv /tmp/mydir-temp /tmp/mydir

As long as you do the relevant testing and exit the script if anything goes wrong, the script will never overwrite /tmp/mydir, and if it does, you have a backup!