Sunday, December 21, 2008

One-liner to back process old Apache log files using AWStats

I had the issue of going back and wanting to process all the old Apache log files using AWStats when the web server had already been running for a while and logrotated had been busy archiving them. This particular server runs the site http://portal.bristolwireless.net on a server running Debian and Apache2.

I used this one-liner to deal with all the archived gzip files:

% cd /var/log/apache2
% for i in `ls -tr access.log*.gz`; do gunzip $i; /usr/lib/cgi-bin/awstats.pl -LogFile=/var/log/apache2/`echo $i | replace '.gz' ''` -config=portal.bristolwireless.net -update; gzip `echo $i | replace '.gz' ''`; done

Now there's just the one uncompressed file to do:

% /usr/lib/cgi-bin/awstats.pl -LogFile=/var/log/apache2/access.log.1 -config=portal.bristolwireless.net -update

And then run it as normal (which defaults to /var/log/apache2/access.log in this case):

% /usr/lib/cgi-bin/awstats.pl -config=portal.bristolwireless.net -update



Et voila!

Tuesday, December 16, 2008

Migrating Thunderbird files from OS X to Linux and vice-versa

I have a MacBook and can never work out whether I prefer OS X or a Linux distro, well actually I prefer the latter, just that the former has up until very recently always worked better :P

Now with the packaged Ubuntu 8.10 all under the Linux side of my dual boot using rEFIt seems to be rosy, so I've moved back to it. I use Thunderbird for my email, and the files are in a slightly different location on the different OS versions:
  • Under Linux both the profile directories and the profiles.ini file live in ~/.mozilla-thunderbird
  • Whereas under OS X the profiles.ini file lives in ~/Library/Thunderbird/ and the actual profiles are then stored in ~/Library/Thunderbird/Profiles/
Therefore a small amount of mangling needs to be done to move from one to the other. Follow these steps:

Moving Thunderbird from OS X to Linux:
  1. First take a back-up copy of ~/Library/Thunderbird from OS X (you probably will want to back up all of your home directory) and then once in Linux, copy this into your home directory.
  2. Now change the name of this directory using 'mv ~/Library/Thunderbird ~/.mozilla-thunderbird' - note that the dot between the slash and the m is important.
  3. Change to the new directory with 'cd ~/.mozilla-thunderbird'
  4. Move the profiles with 'mv Profiles/* .' and then remove this directory with 'rm -rf Profiles'
  5. Now use your favourite text editor to edit the file called 'profiles.ini', for example 'nano profiles.ini' and then find the entry for your profile, it may look something like this:
    [Profile0]
    Name=default
    IsRelative=1
    Path=Profiles/mzsbzfk5.default
    Change the entry for 'Path' by removing the 'Profiles/' part, e.g. if I did that for the above, it would then read:
    [Profile0]

    Name=default
    IsRelative=1
    Path=mzsbzfk5.defa
  6. Save the file and exit your editor (in Nano this would be ^O ^X (control-O, control-X) and start Thurndebird. Et voila!
  7. P.S. They're be some files kicking around from OS X that you now do not need, to tidy these up do 'rm ~/.mozilla-thunderbird/Application\ Registry;rm -rf ~/Library/Thunderbird'
Moving Thunderbird from Linux to OS X:
  1. First take a back-up copy of ~/.mozilla-thunderbird from OS X (you probably will want to back up all of your home directory) and then once in OS X, copy this into your home directory.
  2. Now change the name of this directory using 'mv ~/.mozilla-thunderbird ~/Library/Thunderbird ' - note that the dot between the slash and the m is important.
  3. Change to the new directory with 'cd ~/Library/Thunderbird'.
  4. Make a subdirectory for the profiles with 'mkdir Profiles'.
  5. Move the profiles to this new directory. One of the easiest ways to do this is the following 'mv * Profiles;mv Profiles/profiles.ini .'.
  6. Now use Text Editor to edit the file called 'Library/Thunderbird/profiles.ini', it may look something like this:
    [Profile0]
    Name=default
    IsRelative=1
    Path=mzsbzfk5.default
    Change the entry for 'Path' by removing the 'Profiles/' part, e.g. if I did that for the above, it would then read:
    [Profile0]

    Name=default
    IsRelative=1
    Path=Profiles/mzsbzfk5.defa
  7. Save the file, quit Text Edit and start Thunderbird. Et voila!

Friday, October 24, 2008

Getting Spanish keyboard layout working well on a MacBook running Ubuntu

When I started learning Spanish I decided that I would run a lot of my computing environment in Spanish in order to familarise myself with the language, especially the terms used in computing and IT. When I moved to Spain I also started to use the Spanish keyboard layout frequently, which is very useful for writing Spanish and other Latin based languages because it contains keys for easily accenting characters.

So for example, some accented characters require a single keystroke or simple use of the shift key (ñ,Ñ,ç,Ç,º,ª) and some can obtained with a two-key compose sequence (à, á, â, ä, è, é, ê, ë, ò, ó, ô, ö, ù, ú, û, ü, ý, ÿ, ì, í, î, ï, ŕ, ń, ź, ć ś, ĺ) and some using a third-modifier key like right-apple-key / alt-gr (æ, ł, €, ø, þ, ß, ð, đ, ŋ, ħ, ĸ, µ). It's even possible to get some useful symbols easily using just one modifier key («, », º, ª, ·, ¦, ¿, ¡) and also the accents on their tod with the compose key followed by the space bar (^, `, ', ", ~).

Anyway great for all those weirdy European language characters, as I'm sure you'll agree - although I can't seem to get the Welsh language's 'w' with a caret/circumflex (^) over it very easily. In HTML you can get others from this URL http://www.computertorture.com/xhtml/character.xhtml but not this one. Weird as it's an important letter in Welsh and there must be a way to do it??

I was having trouble getting the layout to work under Ubuntu 8.04, but here's how I did it:

First go to Preferences -> Keyboard Shoutcuts and reassign to 'Switch to workspace to the left' to be Control-Shift-Left and likewise 'Switch to workspace to the right' to be Control-Shift-Right (both of these are right at the bottom of the list, so scroll down!).

This frees up the Alt (also known as Command) key for use as the third-level-modifier.

Then go to Preferences->Keyboard and the Layouts tab. Once here, select the 'Keyboard model' to be 'MacBook/MacBook Pro (Intl)' and then add the layout by clicking the 'Add' button. Here you want to select 'Spain' as the layout and 'Spain Macintosh' as the variant.

Then choose 'Layout options' button and here you need to expand 'Third level choosers' and choose the option 'Press Left Alt key to choose 3rd level'.

That's it.

Bristol Wireless News

People & Planet News Headlines

Followers