Category: Technology

Ubuntu 8.10 vs. Fedora 10

 I have used Linux regularly for about 4 years. I that time, I have, for the most part, used Ubuntu Linux, but I have on many occasions tried other flavours of Linux, including Fedora. So, how do the latest editions of Ubuntu and Fedora compare?

It is fair to say that Ubuntu generally has the edge on Fedora in my experience. I have tried Fedora Core 4 and Fedora Core 6 before, with little success, Fedora Core 4 suffered from dependency problems when installing programs, and Fedora Core 6 just wouldn't install. I also tried Fedora 9, which ran very nicely from a Live CD, but didn't install properly.

On the other hand, I have used every version of Ubuntu since the first, 4.10 (Warty Warhog). It is fair to say that I have generally been impressed with it - no installation problems at all. The early versions I used - 4.10 (Warty), 5.04 (Hoary) and 5.10 (Breezy) were solid, but unspectacular.

This changed with Dapper Drake, (6.06, LTS), the first long-term support release. It was accompanied with a much more integrated feel, and generally just worked out of the box, with few changes required. All the releases since then have carried on building upon this release, none of them being spectacular, but all solidly pushing forward. So, how would Fedora 10 and Ubuntu 8.10 fare?

The fairest test is to run a clean install of both. For both, I used a Live CD, with my desktop PC, which is a 2.8 Ghz Intel Processor with HT technology (the most over-rated technology of the last 5 years, if you ask me), 512Mb RAM and a 128Mb nVidia GeForce 6600GT. So, not slow, but not about to set the world on fire either. Hardware support shouldn't be an issue.

I tried Fedora 10 first. It booted without a problem, and quite quickly. It has quite a slick desktop, but I really wanted an installed system, so I installed the OS to the hard drive straight away. Everything was fine, and I re-booted. Now, in the past, Fedora has forgotten to add itself to the bootloader when installing, which is a fairly major error, but there were no major problems like that this time.

I selected Fedora 10 from the GRUB menu and watched as Fedora booted. It then came to a screen where I could finish the setup of my system. Error. My mouse didn't work. My keyboard didn't work. I tried using USB and PS/2, but neither worked. I was stuck.

I tried installing the whole system again (the Live CD recognises the keyboard and mouse without any problem), and booting again, but the problem re-appeared. Given my previous bad experiences with the Fedora installer, I cut my losses and gave up.

Next, I tried the Ubuntu 8.10 installer. I had previously upgraded an install from 8.04 to 8.10, but this test is for a clean install - and clean installs are generally better anyway. I booted the Live CD - no problems. I ran the installer - no problems. The graphical installer is very slick, and the partitioning tool that Ubuntu uses is very impressive - Ubuntu manages to make partioning a joy, whereas Fedora has, in my experience, made it a very complicated affair, despite using the same base package. Anyway, I answered a few questions, the whole thing installed and it asked me to reboot.

At this point, I would like to mention something. When Fedora finishes installing, it just gives you a button to press to reboot. This is fine, but it leaves the CD is the drive, and if you don't take it out, you can end up booting from CD again when you reboot. Ubuntu automatically rejects the CD from the drive, tells you to remove it from the drive and to then press the "enter" key, thus eliminating this annoyance. It's a very small matter, but it saves a lot of hassle. Big thumbs up to Ubuntu on that one.

I then rebooted and logged in. No problems. The desktop is very slick. The background wallpaper looks fabulous. I was quickly prompted to install my updates, which I always like. The user panel at the top of the screen has been integrated fantastically to enable you to lock the screen, log out and reboot with the minimum of hassle. You can even start a guest session within your own session, giving someone else access to your computer, but without giving them the ability to log you out or accidentally shut your computer down. It even saves where your music was in the middle of playing and starts playing it back instantly when you end the session to go back to your previous session.

There are many more neat touches that impress. Pidgin integrates fanastically into the user applet to set your availability status. The codec finder works wonderfully so you don't have to worry about having to download the correct codec yourself. You can even buy licenced codecs if you want.

Pulseaudio now seems to work fantastically. I can play music in Rhythmbox and watch videos in Firefox without then having to kill pulseaudio in a terminal afterwards. Olive - the GTK frontend to bzr, has now evolved into a much friendlier program. The only slight disappointment is that OpenOffice 3 isn't included by default, although it is easy enough to add. Overall, very impressive. So, what's the verdict?

Software: Ubuntu 8/10, Fedora 9/10. They have virtually identical programs, but Fedora includes OpenOffice 3, so it shades this area.

Desktop Integration: Ubuntu 9/10, Fedora 7/10. Fedora's looks good, but Ubuntu's integration of user sessions, Pidgin and hardware drivers puts it out ahead.

Speed: Ubuntu 8/10, Fedora 8/10. Both are nifty, even on a machine that's starting to struggle slightly for raw power in an age where RAM is key.

Installer: Ubuntu 10/10, Fedora 6/10. Fedora's installer is quite slow, whereas Ubuntu's is fast, asks very few questions and has the best partition editor I've seen anywhere, ever. I'd use it over proprietary software any day.

Overall: Strictly speaking, Ubuntu 35/40, Fedora 30/40. However, I think I have to disqualify Fedora and give it a big fat 0/40.

It might seem harsh, but at the end of the day, my Fedora installation isn't useable - and not for the first time. It's not like I'm using cutting edge hardware. The keyboard is a fricking Cheery Linux keyboard for goodness sake! There's clearly a problem with the Fedora installer somewhere. And yes, I know I could spend hours on the Fedora forums trying to find an answer, but I shouldn't have to - not when every other Linux distro has no such problems. Linux Format may have had Fedora 10 down as beating Ubuntu 8.10, but there's no such judgement here. Ubuntu wins an easy knockout.

CPU Frequency Scaling In Ubuntu 8.04

I hope you have a nice cup of tea at hand. This is one long post, but oh, is it good! If you're not interested in CPU frequency scaling, then firstly, why not, and secondly, this probably isn't for you...

Please note: this is a first draft and is liable to change after feedback, but it works! Please report any mistakes! This guide is also available as a downloadable pdf.

I am writing this guide to scaling CPU speeds not because there isn't any documentation out there already – there is, although it can be hard to find – and not because I am a technical genius – I know a fair bit, I guess, but I'm no Einstein. No, I'm writing this because it's something that I wanted to do but had to look in a number of places in order to find out how to do it. Furthermore, some of the documentation that I found was a little muddled and probably not easy enough for some people to follow. Thus, I am going to try and explain how to scale CPU speeds in Ubuntu's latest release, 8.04 (Hardy Heron). If you're not using Ubuntu 8.04, you may need to change a few things, but this guide should still be helpful as long as you are using a 2.6 kernel.

Before we start, a little disclaimer. Some of this guide will have you executing powerful commands and you could accidentally wreck your system. If you do this, it's not my fault. I'm not forcing you to do this, nor am I there to make sure you do it correctly. If you wreck your system, you've likely done something wrong. If so, you're best off going somewhere like the Ubuntu Forums for help, not here. If, however, you follow this guide and it just doesn't work, feel free to leave a comment or contact me and I can see if I can help this work for you, and perhaps update the guide. Like I said, I'm no expert, but I have, after some study, made CPU scaling work very nicely on both my laptop and my desktop, which are very different machines.

So, before we actually start doing anything, what exactly is CPU speed scaling, or as it is more technically known, CPU frequency scaling? It's quite simple really. A CPU is a central processing unit – it processes everything as computer does. The faster the processor, the quicker it can executer commands – although it can, of course, be constrained by other elements of your hardware, like insufficient RAM. CPUs have a speed rating – my laptop has a Core2Duo T7300 rated at 2.00Ghz, so basically, it has 2 CPU cores, and they run at 2.00Ghz. My rather ageing desktop has a Pentium 4 HT processor running rated at 2.8Ghz, meaning it has 1 core, running at 2.8Ghz. However, whilst this is what these processors are rated at, this does not mean to say that the processors must run at this speed. Far from it. My laptop CPU can also run at 1.6Ghz,  1.2Ghz and 800Mhz. My desktop CPU can run at all sorts of speeds down to 350Mhz. This is known as speed stepping. Please note, this is not the same as overclocking (or underclocking)!  I will explain later about how overclocking fits in with speed stepping. One final note before moving on to the "why" - CPUs do not have to run at a set speed – they can dynamically change speeds. This can be very useful, as will be explained next...

So why might you actually want to speed step your CPU? You might want to save power. This would be a good way to do that. You may not need all the processing power your CPU has, and thus not want to use it unnecessarily. Neither of these are particularly likely reasons, but there are two more likely reasons for speed stepping. Firstly, if you have a problem with overheating, turning the processor's speed down will reduce the effect of overheating. Secondly, you may be using a laptop and trying to save power to extend battery life. Speed stepping can, when used correctly, save power and extend battery life. Considering laptops can often overheat because of their compact nature and people's lack of care for them, the reduced heat could potentially prolong the life of the laptop too, whilst still leaving you with processing power when required. So, enough of the background, let's get on with actually implementing speed stepping on our Ubuntu system!

The first thing we need to do is make sure that we have a couple of packages installed. One of these is "powernowd", and the other is "cpufrequtils". To see if these two packages are installed, go to System → Administration → Synaptic Package Manager and type in the package names.

Once you have made sure that these two packages are installed, go to Applications → Accessories → Terminal. In the terminal, type "/sys/devices/system/cpu/". Then press the "tab" button twice. If you have two processors, or a multi-core processor, you should see "cpu0" and "cpu1". If you have more than two cores or processors, you will see more (one for each that you have); if you have just the one processor with one core, you should just see "cpu0". If you still have the command on the line, type "cpu0/cpufreq". Hopefully, it should find a cpufreq/directory. If it does, press the "tab" button twice again. A whole list of new options should be available, such as "scaling_driver", "scaling_governor", "scaling_max_freq", "cpu_max_freq", etc... I have 13 options on my system. We will use these later to probe the processor and to change our speed step settings.

Now, you need to copy and paste the following command into the terminal and press "enter":

ls /lib/modules/$(uname -r)/kernel/drivers/cpufreq/ \
/lib/modules/$(uname -r)/kernel\
/arch/x86/kernel/cpu/cpufreq/

Please note: if you are using an earlier version of Ubuntu, you may need to replace the "x86" in the last line with "i386". If you get an error message in the output from the above text, try replacing the text. Unfortunately, I don't know when that changed in the kernel – I just know it did. Anyway, what we're interested in is the output. The first output lists the available speed step drivers we can use to speed step the CPU. The second output lists the governors, which I will talk about later. The first list will consist of drivers such as "acpi-cpufreq.ko", "speedstep-centrino.ko", "p4-clockmod.ko" and "powernow-k8.ko". Hopefully, one of these drivers is the one we need – we just need to find out which one. With some logical thinking, and by paying attention to the terminal's output, we can actually do this quite easily. The format we need to use is the following:

sudo modprobe driver

Please note, although the drivers in the previous output had the extension ".ko", we do not add that extension in the modprobe! So, if we are trying to add the p4-clockmod driver, we enter the following:

sudo modprobe p4-clockmod

If I accidentally add the ".ko" extension, I will get the following error:

FATAL: Module p4_clockmod.ko not found.

So the next question is, how do we know if we have loaded the correct driver? If we load the correct driver, there will be no output from the terminal. If we load the incorrect driver, however, we will see a message that says something along the lines of "Device not found". And so, having evaded simple errors, we come to the million-dollar question: which driver is the right driver?

Good question! The simply answer is, "I don't know"! However, with some logical thinking, we can get somewhere. The best driver to try first is "acpi-cpufreq" as it is the most likely to work. This is the driver I use for my Core2Duo. If you have an nforce2 chipset, try "cpufreq-nforce2". If you have a Centrino processor, try "speedstep-centrino". If you have p4, like my desktop, try "p4-clockmod". If you have an AMD processor, try one of the "powernow-6/7/8" drivers (use the number that's most appropriate, if you know which one that is).

But what if you don't know what kind of processor you have? That's not a position I'm familiar with, but I can still help you. For more information about your processor, type in the following command in the terminal:

cat /proc/cpuinfo

This will tell you lots of information you don't need, and a little that's helpful. Take a look at "vendor_id" and "model name" - these two labels will tell you what you need to know about your processor. Also look at "cpu Mhz" - this tells you the speed your processor is currently running at. Please note: it does not display the speed it is supposed to run at, or can run at, but the speed that it is currently running at.

Anyway, once you have successfully loaded a driver, you need set the speed or set a governor to automatically govern the speed. These are two very different things. Setting the speed is, in effect, manually throttling the CPU – especially effective if you're trying to stop the CPU from overheating. Setting a governor is a dynamic way of changing the speed of the CPU in accordance with the amount of power it needs at a given time – more effective for saving power on laptops. Decide which of these methods you want to take – for now – as they take different approaches (although we will be able to alter both later).

First, I'm going to go through how to manually set the speed of the CPU to a set level. Before we can set the level, however, we need to know what speeds the CPU is capable of running at. We do this by executing the following command:
$cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
This command will output a series of numbers, separated by spaces. These are the speeds (in hertz, Hz), that the CPU is capable of running at. On my laptop, the CPU can run at 2Ghz, 1.6Ghz, 1.2Ghz and 0.8Ghz. Make sure you count the number of 0's! Decide which of the available frequencies you want to run the CPU at, and then execute it with the following command:

sudo cpufreq-selector -f value

Remember, 1Ghz == 1000000! The "-f" argument simply tells the program to set the frequency. You can select a particular CPU by using "-c" followed by the CPU number. That's it, if you were just wanting to set a new, constant CPU frequency! And, just to check the new frequency has been applied, we can issue the following command:

cpufreq-info

This will output a fair amount of information, one piece of which will be "current CPU frequency Is..." If, however, you want *just* the current CPU frequency, you can issue a more long-winded command that will just output the frequency in hertz (Hz):

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq

If, however, you are wanting to set a governor, it's a little more long-winded, but not complicated. First, we want to go to the cpufreq/ driectory:

cd /sys/devices/system/cpu/cpu0/cpufreq/

Now that we're here, we want to see which governor is currently set:

cat scaling_governor

The output will almost certainly be "userspace", which basically means that the CPU has been set to a particular, constant speed. If you're reading this, I'm assuming that speed is full speed! Anyway, what we want to do next is to find out the scaling_governors we are able to set, which we query using the following command:

cat scaling_available_governors

The output will hopefully be "ondemand", "userspace", "conservative", "powersave" and "performance". "Userspace" allows the user to set the CPU frequency manually, "powersave" runs the CPU at the lowest frequency, "performance" sets it to the maximum frequency. "Ondemand" and "conservative" are very similar – they both set the CPU frequency quite low where possible, and then raise the frequency as necessary to run commands. The difference, however, is that the "conservative" governor gradually steps up the speed, whereas the "ondemand" governor is capable of jumping straight to the fastest frequency step. Depending upon what you are doing, either of the two methods could save more or less power than the other, and it is probably in part down to personal taste. So, now you're an expert in the options, pick one and execute it in the terminal! I'm going to execute the "ondemand" governor.

sudo sh -c "echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"

The "sh -c" bit is telling bash to run the command in a shell. This is needed because the command is run as a superuser. You can run the command as root, but I really wouldn't advise it when you can do it like this. Because the command has to be run through a shell, the actual command has to be run within quotation marks. Anyway, once this has been successfully run, your system will be running the "ondemand" governor! But you can't see that yet, and you want to be able to see that this is working, right? Yes, you do. Read on. We're almost there!

Apologies to all non-GNOME users out there, but the following section is applicable to GNOME (but there's more after this section to interest you!). I don't use KDE or any other desktop, so I can't help you when it comes to a graphical utility for CPU frequency and governors outside of GNOME. However, if you do use the GNOME desktop, there is an applet for the GNOME panel that can help us. However, first of all, we need to reconfigure the "gnome-applets" package so as to give it superuser privileges. We do this using the following command:

sudo dpkg-reconfigure gnome-applets

You will be asked a question, to which you need to answer "yes". Then, right-click on the GNOME panel, click "add to panel" and select "CPU Frequency Scaling Monitor". Once you have placed it in the panel, you can left-click on the applet and select either a frequency, or a scaling governor. We're done!

However, for your piece of mind, I have added a few notes on the bottom here to explain a few other things. Take a quick look here if you experience any difficulties.
The command "cat cpuinfo_cur_freq" and "cat scaling_cur_freq" output the same information, but the former requires superuser privileges whereas the latter doesn't. The commands "cat cpuinfo_max_freq" and "cat scaling_max_freq", and "cat_cpuinfo_min_freq" and "cat scaling_min_freq" give the same relative output, but in this case, none of the commands require superuser privileges. No, I don't know why either!

If you want to find out which driver you are currently using, use the command "cat scaling_driver". To check the current governor, use the command "cat scaling_governor". To check how long your computer has been in each CPU frequency state, execute the command "cat stats/time_in_state".

You can artificially set a minimum and maximum CPU frequency state using these commands too. To check the current maximum state, execute the command "cat scaling_max_freq", and for the minimum, execute "cat scaling_min_freq". If you wanted to set the minimum frequency to 1.2Ghz, you would execute the following command:

sudo sh -c "echo 1200000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq"

And to set the maximum frequency at, say, 1.6Ghz, you would execute the following command:

sudo sh -c "echo 1600000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq"

Easy! I don't know what happens if you accidentally set the maximum frequency to a lower value than the minimum – you'll probably get an error message though.
As far as I am aware, that is everything and this tour through CPU frequency scaling is complete! If you use this and it works, please leave a comment to let me know. If you tried and it didn't, leave a comment and let me know. If you don't understand, or you find a mistake, leave a comment and let me know! If you're still reading, you're a committed reader. Leave a comment and let me know. Maybe I'll buy you a drink sometime!

The Disappointment Of Fedora

I have, a few times before, tried out different versions of the Linux operating system. I generally use Ubuntu, but have also been known to use Puppy Linux, Damn Small Linux, Knoppix and Fedora.

I quite often use Puppy Linux and Damn Small Linux to run a simple operating system from a USB device, and Knoppix if I want a full system. However, I have often tried Fedora as an alternative to Ubuntu. Unfotunately, I have never been very successful with Fedora. I frist tried Fedora Core 4, which was ok, but took half a dozen attempts to successfully install to a hard drive due to conflicts. Then, every time I tried to install programs, it told me about more conflicts and explained that the software couldn't be installed. Sadly, that meant that it wasn't really very practical. Never mind, eh? Well, I then tried Fedora Core 5, which had the same problem, as did Fedora Core 6. So I gave up, admitted defeat. Until now.

Yesterday, I tried installing Fedora 9. I downloaded the DVD image and burned it to a DVD. I then installed it on my desktop seemingly successfully (albeit slowly), and went to bed to come back to this morning. Unfortunately, it hangs at the loading screen. Not helpful. So, I have now tried four versions of Fedora, and none of them have been successful. It doesn't give me a great impression of the project!

One difference with my setup this time around was that I installed the Fedora on to an XFS partition, whereas beforehand, I had always used ext3. However, Fedora is supposed to support XFS, so it shouldn't be a problem.

Annoyingly, this failed installation has also stopped my installation of Ubuntu from working, as it reinstalled GRUB and insisted upon formatting my boot/ partition, so I now need to reinstall this too. This is also a problem Fedora has had in the past, although now with a marked improvement. In the past, Fedora didn't install itself on the boot partition, let alone anything else, so at least it's got that far...

Should I try Fedora 10 later in the year? Or should I admit defeat and just try Linux From Scratch again?

Another Small Project

Following on from the small project I showed off last night, I thought I would draw a little attention to one more little project I've been working on - my recent links. I have, for a while now, had some recent links shown in my sidebar, but the sidebar only shows the most recent 5, and they have, until now, then faced oblivion. Not any more! I have a page devoted to showing them now.

I will, at some point soon, split them into monthly and yearly archives, although there's little point in doing this whilst there's only one month of such links to archive. I will also add an RSS feed and set up a monthly, automatic post containing that month's links. Aren't you all lucky!

Well, I am now off to the wonderful event that is LUGRadio Live 2008, which I'm sure I will post about later tonight or during the week!

Writing Functions In Sassenach CMS

I am currently carrying out a little more cleaning up of the Sassenach CMS codebase, starting with themes. At the moment, Sassenach CMS themes are fairly complicated and easy to break if you don't know what all the code does. This may seem an obvious point, but the average person designing a template doesn't necessarily want to deal with the entire codebase - they just want to style their website. In order to take away most of the complicated code, I have set about writing functions that call the code from elsewhere.

This, unfortunately, took much longer than I was expecting. In fact, it took 6 hours last night just to get one function working. It was, of course, all my own fault. So, before I explain the functions, two quick tips: firstly, if your function doesn't appear to work, make sure you've called it properly. Let's say we have the following function:

function my_new_function {

}

That's fine, as long as it is declared within PHP. However, when it comes to calling the function, don't make the mistake of doing this:

my_new_function; // This will not work!

Instead, make sure you call it like this:

my_new_function(); // This will work!

Basically, I forgot to include the parentheses when calling my function. Silly. Anyway, there was a further problem which manifested itselfwhen including other external files within my function. I was trying to do this:

include $file;

This wasn't working, however. So, I tried the actual file I wanted to include on this occasion:

 include 'file.php';

No problem. As far as I was concerned, $file == 'file.php', so it should all work. I couldn't work it out. It didn't make sense. It should work - but it doesn't. I checked my PHP and MySQL book, but it didn't give me an answer. I Googled for 3 hours, with no result. I checked the PHP website, Tizag, DevShed, everywhere else I could possibly think of, but no, nothing.

I chatted to someone on the phone about it. We decided Greek made more sense. Then, one of my housemates came back. We chatted for a bit. I rambled on about the problem for a few minutes. They listened politely, but I may as well have been talking Chinese.

Then, I went back to it. It still didn't work, so I copied a snippet of code from the PHP website. It worked. I adapted it. It still worked. I didn't understand at all. And then it hit me like a concrete block. It was obvious. Talke a look:

$file = "'functions/'.$function.'php'"; // Do you see the problem here?

include $file;

I am a muppet. I had double quotes that were completely unwarranted and broke the script. No amount of Googling would come up with that answer.

So, having exposed my blatant error to the world, hopefully I have saved others from the same mistake - and we can move on to Sassenach CMS functions. I didn't want the functions to all come from the database, because that puts unnecessary load on the database. Similarly, I didn't want to include every function at the top of every script when they weren't always needed. Thus, I have written a function that is designed to call other  functions as required. Here it is:

function get_sassenach_function($function) {

$sassenach_function = 'functions/'.$function.'.php';

include $sassenach_function;

}

 Thus, if you called the function like this:

 get_sassenach_function(links);

Then Sassenach CMS would, ultimately, run the script at 'functions/links.php', which then executes the code that no-one should really need to deal with.

However, there is a chance that people may want to use their own custom functions. What happens then? There is, of course, the option to hack the scripts, but I wouldn't advise this, especially as any upgrade would likely overwrite them again. Instead, we will have a directory within which people can place their own modified scripts and run them. So, that might look like this:

function get_sassenach_user_function($function) {

$sassenach_user_function = 'functions/user/'.$function.'.php';

include $sassenach_user_function;

}

 Thus, users can define their own functions and call those without having to worry about having their custom functions overwritten. More importantly, they can call their own custom functions easily.

There is, however, one other possibility. What if a particular theme wants to call its own functions? Well, the same kind of principle applies, except that the functions would be stored in a functions directory in that themes folder, and would use another slightly different call, yet to be written, which would be get_sassenach_theme_function($function). This will need to be a little different in design as it requires knowledge of which directory the theme is found in, but it will still wirk without too much trouble.

There is one more problem to overcome - what if you need to call a function more than once? This is actually quite easy to overcome, and it is done like so:

if (!function_exists('example_function')) {

function example_function() {

// The function is defined here

}

}

example_function(); ?>

So, each time the function is called, the top of the function file checks to see whether the function has been defined before. If it has, there is a problem - that functions can only be defined once. So, if the function has already been defined, it just calls the function. Otherwise, it defines the function and then calls it.

And so there you have it, a guide to functions in Sassenach CMS. What a fun post. Does anyone still have the will to live? If so, feel free to comment. Comments should now be working - if they're not, you should let me know!

Firefox 3: Another View

Following Cheezy's review of Firefox 3, I thought I'd get in on the act. I've used Firefox for a long time and, quite frankly, there's no better browser out there. Opera is over-rated; I.E. is best ignored. Konqueror has always been very fast, but not widely compatible with all websites, is KDE-baed and has a file manager that gets in the way; Epiphany is a great GNOME-based lightweight browser, but isn't available on other platforms. Safari is a very good browser, but it takes an age to start up and doesn't use standard buttons, which is frustrating when you aren't using OSX.

Firefox. on the other hand, has always been very reliable, fast, if needing a lot of memory, compatible with most of the Internet since it started to get more widely adopted and is generally very good, with the slight drawbacks of an on-going memory leak and a tendency to crash. However, with version 3, these issues have been rectified.

The first thing I notice about Firefox 3 is that it runs incredibly fast. It starts almost instantly and is much more responsive. It looks a little different, but that's no real problem - you can alwayd theme it yourself. The new folders for your most visited links are not a great help to me, but I'm sure they are to lots of people. However, like Cheezy, the new form the address bar takes is a real disappointment. I don't want Firefox to start searching everything when I'm clearly typing in the start of an address. It makes the rest of the address impossible to find when you don't know the exact address and there are 50 other very similar addresses that Firefox has found. There should be an option to turn that off.

Other than that, Firefox 3 is very good. It's certainly more sturdy than it has been before, and its speed evokes more confidence, but that fricking address bar is incredibly frustrating.

In Praise Of Proxy Servers

To be honest, I've never really known much about proxy servers. I've never really needed them. I don't need to get around any Intrernet filters, I don't live in China and, to the best of my knowledge, don't have a great deal to hide. Thus, what's the need for a proxy server, eh?

Well, today I found a good use for one. I was transferring a website across to a new server and the nameservers were causing me hassle, making it hard for me to edit the website. The problem was, I was looking at the old website, as seen below:

The old BUSY website

There's even a nice wee message to tell you it's the wrong one! But that's done me no good, of course, so I needed to take some action. I had a few options:

  1. Wait. Not my strongpoint;
  2. Try to access through an I.P. address. This is probably not possible;
  3. Guess that what I'm doing will work. This is always a bad assumption;
  4. Set up the website on my local server. Unfortunately, this would take a while;
  5. Use a proxy server. It was the quickest option and clearly worth a try.

It's not something that was guaranteed to work, but it did, as you can see from the picture below:

The BUSY website through a proxy

Obviously, the advert was added by the proxy server - they need to make money somehow, I guess. I was then able to edit to my heart's content. See, proxy servers can serve legitimate purposes!

Progress Is Good

Although I've done little on my little project today, I have spent three whole days working on it this week, rather than spending my time on my dissertation like I probably should have. Still, I managed a few significant things yesterday, so I thought I'd provide another short update.

My nice to-do list can now be updated without a problem, which has helped me keep track of things nicely. I was very excited on Tuesday to find the first two bugs in the code I'd written: there were two scripts which used the $_GET() function, and were meant to perform certain actions like delete things from the database when given certain variables in the url. I had, however, mistakenly allowed the script to delete as long as something was appended to the url, regardless of what this command was. Here's an example:

http://www.noelinho.org

That's the web address.

?action=delete&post=21

Those are the variables. When put together, we get this:

http://www.noelinho.org?action=delete&post=21

Assuming the action "delete" does what it says on the tin (and it does), then it will look in the database for post 21, and delete it. Unfortunately, my carelessness meant that it would have done the same if action was equal to "create", "modify", or even "" (blank). Still, it's on my to-do list to be fixed...

However, I have, much more excitedly, managed to implement that two things I thought would be hardest: RSS feeds and nice permalinks, using mod_rewrite. The RSS feeds were quite simple once I'd realised that certain html entities break XML, and then used the necessary PHP function to strip them from strings. It probably needs a little more work, but it's functional at the very least right now. I was even more satisfied to get mod_rewrite working. For some reason, I couldn't get it to work on my local server, but once I'd uploaded the scripts to this website, I managed to get them working. Thus, I can now start with an address such as:

http://www.noelinho.org?year=2008&month=01&title=noels-first-attempt

And I end up with:

http://www.noelinho.org/alpha/2008/01/noels-first-attempt/

Awesome! mod_rewrite is brilliant... but complicated. Like, nigh-on impossible. But not quite.

Another Noelinho CMS Update

I've been continuing to use whatever time I can to work on my little CMS project which I have mentioned before. Just over a month has passed since then, and I have managed to progress a little further, especially in the last week. Given that a few people have asked about it recently, I thought I'd post a little update.

I'm still only working on the back-end of the system at the moment - the front-end can be sorted out afterwards. The basic structure of thre back-end has remained the same, but I've decided to split many of the pages in the different sections into two or three pages. The idea of this is to make the whole thing easier for people to understand, and to make each page a master of its domain, so to speak, rather than to make it a lengthy complexion of 'if' statements for five different tasks. It makes working out bugs much easier too!

One significant change is in the way 'categories' are stored on the system. They were stored in a set' field on the 'posts' table, but I've now created a 'categories' table, and each category is a row on that table. It enables categories to have parent categories, but also means I can have one table for both link and post categories. There are problems with creating arrays from this at the moment, so I've decided I'll come back to it another time. I have kept my previous 'set' system just in case it doesn't work in the end, but I was more disappointed that I no longer had a use for my wonderful explode() code, which I did rather enjoy...

I have managed to adapt TinyMCE to fit better in the back-end now, but also to use a more complicated theme that didn't previously work. It still needs a little tweaking, but it would probably work fine just as it is at the moment.

Many of the other things I mentioned in my previous post have not yet been worked on, but there are other things which have progressed. Submitting new links now works well, as does submitting new categories for links, and distinguishing between post and link categories. Parent categories do not yet work, since that option hasn't yet been fully added to the database. The forms have all been nicely styled now too, making them both easier on the eye and clearer to use, as you can see from the image.

I haven't written any documentation yet (I expect this will be done last), but I have transferred my nice 'to-do' task list to the database. I originally developed this so that I could keep track of what I needed to be doing, but then realised it would actually be very useful for other people to keep track of all the things they wanted to do if they were using it too. Thus, the 'to-do' tab probably shows the most complete part of the software at the moment. It is split into three sections: 'implemented', 'in progress' and 'not yet started', with a form at the bottom for submitting tasks. In time, functionality will be added to alter task status and to delete tasks - but only completed ones. To delete uncompleted tasks, one will have to change their status to 'implemented', then delete them, so they can't delete them by mistake.

Making An Autorun CD/DVD

I grant you, most people have little reason to read this post. However, one day, some person will visit this post looking to do precisely what this post talks about! If you're just wanting to read about the autorun part of the post, it is explained towards the bottom - the first half of the post talks about the rest of the CD/DVD!

As part of the technical work that I do for the Baptist Union of Scotland Youth, I have, for the last two years, produced a mission review CD (last year) or DVD (this year) which is mainly full of photographs from missions, with a few other bits thrown in. The CD or DVD is based around an HTML browser through which you - guess what - browse through all the photos from the missions. Other bits thrown in might be a couple of small videos, an evaluation form, contact details, website links, etc... It's generally easier if you can make the CD/DVD run automatically since you then don't have to worry about making sure people know which files to run, etc... (although if they have disabled autorun, then you do, but it's their problem if they've done that). Anyway, my methodology for making the CD/DVD goes as follows:

This provides me with the base that I need to put everything together. However, there is then the small matter of one HTML file for each standard size picture. The DVD this year had 2,701 photographs on it, and I'm sure not going to write 2,701 HTML files to go with them! Thus, I need a script that does it for me. In steps galrey, a Linux command-line program. All I do is fill in a few variables and set it off to create all the files for me, and an index.html file for each folder. It does require some fiddling: as with most command-line programs I know, its HTML is pretty shoddy, but it does the scripting fantastically well. Having altered the HTML, cleaning it up and applying my template, all is fine and dandy. I am then left to add my extra pages manually and to put in an index.html file for the disk as a whole. Easy. At this point, I usually spot a mistake in my navigation bar and realise I need to repeat this step of the process, but never mind!

Thus, the CD/DVD is pretty much complete. The one bit left to do is to make the CD/DVD run automatically. I should, at this point, make two quick points. Firstly, it doesn't matter whether the medium is a CD, DVD, or even a USB storage device, the autorun method is the same - although all three require a PC which is set up to automatically run the medium if autorun is detected. Secondly, I'm not going to talk about Macs. I don't provide autorun support to Macs. It's just too much effort. Well, okay, so it's also to do with the fact that I don't have a Mac to test on, so I couldn't guarantee it would work!

Making the DVD run automatically on Windows and Linux is done separately. It's meant to be easiest to do on Windows, but I've found it easiest on Linux, partly because of a script I found as part of another autorun guide. Thus, I'll talk about autorun on Linux first.

Autorun on Linux

If you take a look at the script, which looks to execute an index.html file, you'll see it's a simple bash script, designed to look for a web browser through which it can execute the file index.html. Very simple really. Except, I found it didn't work. Thus, I set about modifying it. The first problem was that, when I ran the script from inside an existing terminal window, the terminal claimed no browser was available to execute index.html. This seemed a little odd, since I have Firefox installed, and the script includes both Mozilla and Netscape. However, a quick look at my system showed that Firefox is executed through the "firefox" command, so I added this to the script. (Firefox is launched through one of a few different commands depending upon a linux system: sometimes by the command "firefox", sometimes "mozilla-firefox", and occasionally by use of the command "mozilla". Confusing!)

The second problem I found was that when Firefox opened, I simply a tab which showed my homepage and a tab showing some folder on my Linux install. Not very helpful if you don't know where to find index.html! However, a closer inspection of the script explained to me why this was.

The script tries to set the first tab through autorun.inf (which I actually use to autorun for Windows, but I'll go into that later), but doesn't succeed, because autorun.inf doesn't contain this information! Therefore, it has ended up showing a directory it shouldn't be showing (I can't remember what it was, but the point is, it wasn't what I wanted, therefore it didn't work!).

A rush of common sense overtook my brain for a split second, and I decided that there was actually no point in processing anything through autorun.inf at all, when I could just specify index.html instead of autorun.inf. I also realised, however, that there was a problem in specifying "$BROWSER /media/cdrom", since /media/cdrom is completely pointless on my system - my two CD/DVD drives are /media/cdrom0 and /media/crdom1. Thus, it will never find the right folder. The solution? Easy, take out the absolute link and replace it with a relative one - index.html. Since we're already in the folder with the index.html file, there's little point in searching for it - we already know where it is!

Curiously, however, there is still the second tab, which shows the homepage. This is shown because the very bottom of the script tells the browser to open it. Since I'm not personally wanting anyone to look at their homepage (they can open it themselves if they want), I just deleted this part of the script. Now, the script works wonderfully on my Linux system. When I place the DVD in my drive, a pop-up alerts me that it has detected autorun, would I like to enable it? I click "confirm", to confirm that I am expecting it and it's not going to eat my computer, and it opens index.html in all its glory. Fantastic. If you want to see my modified script, you can. To use the script, rename it "autorun" (with no file extension!) and place it in what will be your CD/DVD/USB's root directory.

I should say that I suspect the bottom part of my script is unnecessarily bloated. At the bottom, my modified script reads:

HOMEPAGE=`grep homepage index.html | awk 'BEGIN {FS="="} {print $2}'`

if [ ! -f "$HOMEPAGE" ]; then

$BROWSER index.html &

fi

exit 0

It would probably work reading just:

$BROWSER index.html &

exit 0

However, I've not actually tried this to make sure. If it works, great. If it doesn't, just use it as it appears in the text file. So anyway, that was autorun on Linux.

Autorun on Windows

Autorun on Windows - supposedly easier, though not for me. The problem is that there are so many different ways of doing it. The way I've done it is by writing an autorun.inf file with this inside it:

[autorun]

shellexecute=index.html

shell=index.html

icon=favcon.ico

In theory, this should work. In practice, I've found it to work some of the time, but not all of the time. However, when it doesn't work, Windows Explorer seems to come up anyway, so as long as the user thinks to click on the index.html file, then they're fine.

However, ideally we need a workaround. There are plenty of programs out there that will do the job for you, but most are closed source, proprietary solutions. I want an open source solution. And I've found it. "What is it?", I hear you ask. Well, I'll tell you, as long as you promise to keep quiet about it. It's Firefox Portable. You see, Firefox Portable is set up to work from USB keys, using a relative path, and so it immediately gets around the problem of which browser to use. You simply include the browser on the CD, DVD or USB key and specify the autorun.inf file to launch, via a relative path, the executable file on startup. Thus, all you have to do is write the autorun.inf file. Easy!

Well, actually, that's not quite all. You see, if you do that, and burn it all to a CD or DVD, you'll run into a problem. The problem is that Firefox is not able to run from read-only media. The trouble is, that's exactly what we're trying to do! Well, there is a way around it. First, we must run FirefoxPortable so that the application creates all the files it needs in order to operate. Then, we need to go to the FirefoxPortable/Other/Source/ directory and copy the FirefoxPortable.ini file to the main FirefoxPortable directory.

This file is our friend. We want to open and edit the file, in a normal text editor. The crucial line in the file is the last line, where it says "RunLocally=false". We want to change this value to false, which forces Firefox to run in the RAM, and so means that it doesn't try to save anything to the hard drive, which is what caused our errors.

Next, we want to set the homepage for our users, using a relative path, specified half-way down the file in "LocalHomepage". This is most likely to be "../index.html", or similar (without the quotation marks - they're for your benefit). Once this is done, make sure you launch the browser to make sure it does what you want it to.

Please note, if you then want to make a change, you must change "RunLocally" back to "false", or your changes will not work. You can, if I remember correctly, install themes as you wish, and add-ons too, as long as they don't require writes to the CD, DVD or USB stick when used by the end-user. However, you cannot use relative bookmarks. I've tried this without success. Bookmarks require absolute paths, it would seem. You should probably attach a note to say that the attached browser should not be used for general Internet use. This is because you are not able to install security patches, and so computer security could be compromised. The risk is not a great one, but a cautionary note won't harm.

The autorun.inf file would read as follows:

[Autorun]

Open=FirefoxPortable\FirefoxPortable.exe

Action=Open BUSY Photo DVD 2007

Label=BUSY Photo DVD 2007

Icon=favicon.ico

Now that all this is done, you are ready to burn your media! Just make sure you didn't make a mistake...

I hope this tutorial has been helpful. I certainly had fun trying everything out, and it was a great help to be able to get around browser compatibility issues (well, Internet Explorer issues!) by simply distributing a browser with my work. Kudos especially to John Haller on that one.