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!

Bristol Wireless News

People & Planet News Headlines

Followers