March 2007

Vista on Ubuntu Using VirtualBox

Check out the new guide to installing VirtualBox 1.4.0 from a repository. This is a guide to installing Microsoft Windows Vista on a Ubuntu Edgy machine using VirtualBox. Note that Feisty is not yet fully supported by VirtualBox, but the edgy package is reported to work in feisty. Certain versions of Vista may be illegal to run in a virtual machine, according to the EULA, namely the Home flavors of Vista.

Get Ready

I like to keep stuff clean, so I am going to download everything to a folder. Adjust according if you decide to not make this folder. At the terminal:

mkdir ~/install_files

Install VirtualBox

Get VirtualBox and the necessary libraries.

cd ~/install_files
sudo apt-get install libxalan110 libxerces27
wget http://www.virtualbox.org/download/1.3.8/VirtualBox_1.3.8_Ubuntu_edgy_i386.deb
sudo dpkg -i VirtualBox_1.3.8_Ubuntu_edgy_i386.deb

If you have any dependancy issues:

sudo apt-get -f install

Add yourself to the vboxusers group. System > Adminstration > Users and Groups > Manage Groups > vboxusers > Properties, click the box next to your user's name. Make sure to restart. If you get an error "VirtualBox kernel driver not accessible, permission problem ...", make sure you are in the vboxusers group and restart your computer. (Logging in and out, did not work for me).

Set Up VirtualBox

From the terminal:

VirtualBox

Go through the steps to make a new virtual machine (Click "New"). Remember that Vista has a minimum requirement of 512 MB RAM and 15 GB HD (if you have a powerful system, consider using 1 GB RAM and 20 GB HD, with a dynamic disk). ubuntugeek.com has a screen by screen guide for making a new virtual machine On the settings tab, mount your Vista DVD (or ISO if you have it and want a speedy install). Now just start the virtual machine, and wait about an hour as Vista installs. You won't get any Aero fanciness with a virtual machine (but you should already be running Beryl ...right?)

Install the VirtualBox Additions

From the Devices menu, click "Install Guest Additions"

Get the Missing Network Driver

Microsoft decided to not include the network driver that VirtualBox uses in Vista, so you will have to install it yourself. (Doesn't Microsoft claim that Windows has better driver support than Linux ... ?)

cd ~/install_files
wget http://www.amd.com/us-en/assets/content_type/utilities/V4.51.zip
unzip V4.51.zip -d driver
mkisofs -o driver.iso -R -J driver

In the VirtualBox window, mount driver.iso . Then go to: Control Panel > Hardware and Sound > Device Manager. Right click on Ethernet Controller > Update Driver Software > Browser my computer... Navigate to the CDROM drive, and click ok. Wait a minute... and congratulations, you have installed Vista

Troubleshooting

I did upgrade to Feisty, but had an issue when upgrading. There seemed to be an issue of upgrading the kernel. I was told to run /etc/init.d/vboxdrv setup, however, this kept on erroring out, which showed a compilation error in /var/lib/vbox-install.log . To rectify the situation, find out what version of the kernel you are running:

uname -r

This should give you what version of the Ubuntu linux kernel you are running. In my case it was "2.6.20-13-386". Now you want to install the kernel headers for your specific version of the kernel. In my case:

sudo apt-get install linux-headers-2.6.20-13-386

Modify the numbers of the end of the apt-get command to match what uname -r tells you! Now, just reinstall the VirtualBox package (I had to do it twice, until I got no errors) that you downloaded earlier,

cd ~/install_files
sudo dpkg -i VirtualBox_1.3.8_Ubuntu_edgy_i386.deb

Now everything should work nicely! If you have any further issues, post them in the comments and I will try to help.

Upgrade to Feisty Fawn from Edgy

Ubuntu 7.04, Feisty Fawn, has just been released, so why not upgrade your machine. To replace all your repositories, at the terminal:

sudo sed -e 's/edgy/feisty/g' -i /etc/apt/sources.list

System Message: WARNING/2 (<string>, line 13)

Explicit markup ends without a blank line; unexpected unindent.

not tried this, directly. I have upgrade from Dapper to Edgy using this method before. So you could upgrade to Edgy first, or go straight to Feisty (if you are brave):

Now update:

sudo apt-get update

If you get any error messages, comment those lines out of /etc/apt/sources.list (make sure you sudo to edit the file). Certain repositories, such as automatix are not ready for Feisty yet. Now upgrade:

sudo apt-get upgrade

You will be asked to keep certain configuration files, it is up to you (I am not responsible if you overwrite your perfectly crafted configuration files). I was only asked for a handful of packages. I may take a while to download and setup (several hours). You can likely let apt download for an hour or two, but then you should be around to answer the configuration questions. I haven't noticed any problems just keeping the old versions... One more command:

sudo apt-get dist-upgrade

This command should be quicker than the plain upgrade, but will still likely take an hour. You likely will have to restart your computer. You should run the update, upgrade, and dist-upgrade apt commands regularly. I have noticed that there are changes almost daily to the packages. You could add something like the following to your crontab. Make sure to get root's crontab, via sudo crontab -e

0 4 * * * apt-get -y update && apt-get -y upgrade && apt-get -y dist-upgrade && apt-get -y clean

This will update your system every night. Congratulations, you are running the latest and greatest version of Ubuntu.

RSS Alarm Clock

I finally managed to get a sound card for an old computer. Now, I can make my Ubuntu Alarm Clock! What better way to wake up each morning, than to have your friendly linux box read the news to you? The techniques that I am using are nothing new (Hak5 did it and some people at the Ubuntu Forums have talked about it). It is pretty simple, just download and install the rss2html.pl file and the necessary perl libaries, then create a bash script and add it to the crontab.

Get the programs

You will need festival and perl. You will also need mplayer if you want to play music. You can do the standard "sudo apt-get install ..." to get these (they were all installed in my basic`edgy <http://www.ubuntu.com/>`_ installation).

I am going to use cpan to install the perl modules. cpan is like apt for perl. You might have to set up cpan if this is your first time using it. If you are asked to set it up, I recommend typing "no" on the first question, and cpan will autoconfigure.

At the terminal:

sudo cpan

This is the cpan terminal, autoconfigure if necessary. It may take a while to install each package. If it says it requires other modules, install them as well.

install XML::RSS
install XML::Parser
install DateTime::Format::Mail
install DateTime::Format::W3CDTF

Create a file called "rss2html.pl" in ~/alarm and put this in it:

rss2html.pl

#!/usr/bin/perl -w
# rss2html - converts an RSS file to HTML
# It take one argument, either a file on the local system,
# or an HTTP URL like http://slashdot.org/slashdot.rdf
# by Jonathan Eisenzopf. v1.0 19990901
# Copyright (c) 1999 Jupitermedia Corp. All Rights Reserved.
# See http://www.webreference.com/perl for more information
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

#  ~~~P1mped 0ut l33t hax0r s7yle by d1gital~~~

# INCLUDES
use strict;
use XML::RSS;
use LWP::Simple;

# Declare variables
my $content;
my $file;

# MAIN
# check for command-line argument
die "Usage: rss2html.pl <lines> (<RSS file> | <URL>)\n" unless @ARGV == 2;

# get the command-line argument
my $arg = shift;

my $lines = $arg;
$arg = shift;
# create new instance of XML::RSS
my $rss = new XML::RSS;

# argument is a URL
if ($arg=~ /http:/i) {
    $content = get($arg);
    die "Could not retrieve $arg" unless $content;
    # parse the RSS content
    $rss->parse($content);

# argument is a file
} else {
    $file = $arg;
    die "File \"$file\" does't exist.\n" unless -e $file;
    # parse the RSS file
    $rss->parsefile($file);
}

# print the HTML channel
&print_html($rss);

# SUBROUTINES
sub print_html {
    my $rss = shift;
    print <<HTML;
HTML

    # print the channel items
    my $i = 0;
    foreach my $item (@{$rss->{'items'}})
    {
      next unless defined($item->{'title'});
      print "$item->{'title'}... ... ... ... ...\n";
      if($i==$lines - 1){
         last;
      }
       $i = $i + 1;
    }

    print <<HTML;
HTML
}

Play a Random Song

You don't have to do this, but I want to hear a song after the news, so make a file, music.sh in ~/alarm From the Ubuntu Forum

music.sh

#!/bin/bash
#made by rusl modifying file
#from http://www.macosxhints.com/article.p...51108193636341

# File locations
WritingsPath=/home/<USERNAME>/<pathtomp3s>/
TempLog=/tmp/random-alarm-music.log

# Create a temporary logfile of all matches
find $WritingsPath -iregex ".*.mp3" > $TempLog
find $WritingsPath -iregex ".*.ogg" >> $TempLog
find $WritingsPath -iregex ".*.wav" >> $TempLog

# Choose a random line number (any number from 1 to the length of the file)
LowerBound=1
RandomMax=32767
UpperBound=$(cat $TempLog | wc -l)
RandomLine=$(( $LowerBound + ($UpperBound * $RANDOM) / ($RandomMax + 1) ))

# Use sed to grab the random line
Command=$(sed -n "$RandomLine{p;q;}" "$TempLog")

# open the random line in TextEdit
mplayer "$Command"

Make Your Alarm File

Make a file alarm.sh in ~/alarm

alarm.sh

rm -rf alarm.txt
echo "good morning , today is" >> alarm.txt
date >> alarm.txt
echo "From Digg" >> alarm.txt
~/alarm/rss2html.pl 6 http://digg.com/rss/index.xml >> alarm.txt

echo "From Slashdot" >> alarm.txt
~/alarm/rss2html.pl 6 http://rss.slashdot.org/Slashdot/slashdot >> alarm.txt

festival --tts alarm.txt
rm -rf alarm.txt

~/alarm/music.sh

You can add any number of news sources.

Set Permissions

cd ~/alarm
chmod +x rss2html.pl
chmod +x alarm.sh

Set Your Alarm

Use the crontab to set your alarm. From the terminal:

crontab -e

And paste this into the file:

0 7 * * * /home/USERNAME/alarm/alarm.sh

Further Additions

Hak5 has a script to get the weather.

ClamAV Email Checking on a Shared Host

This guide is designed for users who have a shared hosting account (no root access), namely on DreamHost. We will make use of ClamAV, procmail, and ClamAssassin.

If you add a ~/.procmailrc file to DreamHost, you will likely be unable to use the DreamHost Control Panel's Junk Filtering. Therefore, it is recommended that you check out this excellent SpamAssassin guide and the Dreamhost wiki.

Note that I have installed everything in a ~/packages folder, which the previously mentioned guide does not do, so you should adjust accordingly. I also installed a more recent version of SpamAssassin than the previous guide (3.1.8 vs 3.1.0).

Install ClamAV

mkdir ~/install_files
mkdir ~/packages
cd ~/install_files
wget http://freshmeat.net/redir/clamav/29355/url_tgz/clamav-0.90.1.tar.gz
tar xvzf clamav-0.90.1.tar.gz
cd clamav-0.90.1
./configure --prefix=$HOME/packages --disable-clamav
make
make install

The --disable-clamav flag allows the package to be installed without a special user for clamav.

Modify Your Environment Variables

In your ~/.bash_profile, add the

export PATH="$HOME/packages/bin:$PATH"

At the console enter:

source ~/.bash_profile

Set up ClamAV

In ~/packages/etc/clamd.conf, comment out the line "Example". In ~/packages/etc/freshclam.conf, comment out the line "Example".

Install ClamAssassin

ClamAssassin is a wrapper for ClamAV for use in procmail.

cd ~/install_files
wget http://drivel.com/clamassassin/clamassassin-1.2.4.tar.gz
tar xvzf clamassassin-1.2.4.tar.gz
cd clamassassin-1.2.4
./configure --prefix=$HOME/packages --disable-clamdscan --enable-subject-rewrite
make install

The --disable-clamdscan flag forces ClamAssassin to use clamscan rather than clamd (you don't have to open any ports for a daemon). The --enable-subject-rewrite[=message] flag prepends an alert[=message] to the subject line of the email. Add an entry to ~/.procmailrc to call ClamAssassin and move the email if a virus is found

# Scan for virii with clamassassin
:0fw
| $HOME/packages/bin/clamassassin

# Send virus email to special folder
:0:
* ^X-Virus-Status: Yes
.virus/

Update ClamAV

Update with FreshClam in your crontab

freshclam
crontab -e

Add this line, to update the virus definitions at 1 AM everyday:

0 1 * * * /home//packages/bin/freshclam

Test

Send an email to yourself, you should see the X-Virus-Status header (view all the headers). On thunderbird, go to View > Headers > All. You should see

http://cdn.johnpaulett.com/upload/clam-headers.png

(Optional) Clean up the install dir

cd ~/install_files
rm -rf *

MediaWiki Markup for WordPress

Just found a nice tool for using MediaWiki's markup inside of Wordpress at Zech's Blog. The WYSIWYG editor is Wordpress is nice, but staying at the keyboard with the wiki markup is nice (without the clutter of XHTML). I have started to become a fan of the MediaWiki markup, because it leaves the text of document less cluttered than XHTML. I have recently been working quite a bit on wiki's (RadLex and several Trac installations). I originally coded the RadLex wiki text in XHTML, before I learned about MediaWiki's markup. But picking up the wiki markup was quick and I found reformatting the RadLex page in wiki markup to be much quicker than my first attempt with XHTML (which I have years of experience with).

Update: The plugin does not play well with WP-FLV.