Geek Out

Geeky things. Expect things about blog configuration, firewall stuff, computer hardware, geek jokes, Linux, e-mail, and other stuff.

I am currently running Fedora in a few places. Fedora 9 was recently released and I decided it was time to upgrade.

It is a pretty simple process using RPM and yum.

First make sure the repository is up to date and clean.
yum update
yum clean all

Next download the Fedora 9 core packages:
wget http://download.fedora.redhat.com/pub/fedora/linux/releases/9/Fedora/x86_64/os/Packages/fedora-release-9-2.noarch.rpm
wget http://download.fedora.redhat.com/pub/fedora/linux/releases/9/Fedora/x86_64/os/Packages/fedora-release-notes-9.0.0-1.noarch.rpm

Now just install the two packages you just downloaded:
rpm -Uvh fedora-release-9-2.noarch.rpm fedora-release-notes-9.0.0-1.noarch.rpm

Then I ran a check-update to see what was going to be updated:
yum check-update

Lot and lots of packages need to be updated, so time to update
yum update -y

Unfortunately there was a conflict during the transaction test with compat-db and passwd. It looks like this:
file /usr/include/db4.2.52/db.h from install of compat-db-4.5.20-5.fc9.x86_64 conflicts with file from package compat-db-4.5.20-3.fc8.i386
I cleaned up passwd manually by removing the older version and then upgrading the existing one.
rpm -e -vv passwd-0.73-1.i386
yum update passwd

Between those two, I made sure files from the newer package still existed and they did. So I moved onto compat-db:
rpm -e -vv compat-db-4.5.20-3.fc8.i386
yum update compat-db

This update does get 11 packages, but worked like a charm.

Now one (hopefully) last time with the full update:
yum update -y
Complete!

Check the version by catting the redhat-release file:
cat /etc/redhat-release
Fedora release 9 (Sulphur)

Because I am running in XEN, I don’t technically need a reboot- but I am doing one anyway to make sure.

The only thing not working was my webmail which needed Perl’s Iconv package. Simple CPAN install required:
perl -MCPAN -e 'install Text::Iconv'

Everything is running smoothly and on Fedora 9. Fantastic.

One of the my yearly goals is to run 700 miles in 2008. I have a Garmin Forerunner 301 to keep track of times, routes, distance of individual workouts, lap times, and thinks like that. I also built a Google Spreadsheet with a block for every day of the year that sums up my results. The export of that can be found here. I wanted something that would remind me every day that I need to go run. Since I hit the front page of my blog every morning to check stats and see if any of my 4 readers posted a comment (they never do), I figured putting it on the front page was the way to go.

My first method was just editing the template and putting the values in. P.I.T.A. to do every day. No fun.

The next step was to invest some time in a WordPress plugin. I am fairly adept at PHP and WP makes a pretty easy system to put new plugins into your site. I’m happy to say version 0.1 is complete. You can download it at my WordPress download page– yes, there is only one for now. Here is a happy screen shot from this morning:

WP Running Record

How does it work? It is pretty simple. When you activate the plugin, it creates a table in the database and defaults it with zeroed out data. When you use the plugin admin page located under the Options tab you can update you goal and progress. The new data is saved in the database.

To display this data to your end users, you need to call a function from within your template. My theme has a left_sidebar.php that I wanted to locate the box in. I created the box and populated the data with this code:

<h3>2008 Running</h3>
<ul>
<center>
<?php running_record(); ?>
</center>
</ul>

That is it! Pretty simple huh?

This is still a version 0.1, so it has some quirks. The “Miles Remaining” area on the data entry page looks like a form, and even though it is not edit-able it does not auto update. There is no uninstall feature yet (the database does not get cleaned up if you de-activate the plugin). I’m not sure I like located the console under the Options section. Minor gripes for sure, but it works pretty darn well for what it was intended to do.

Want to use it? Feel free! Enjoy!

Let me know if you have any suggestions. I might spend some more time polishing the plugin. Once I get it pretty nice I might even submit it to the main WordPress plugin repository site.

I have been looking for a good PuTTY colour scheme (yes I used the spelling of ‘color’ they use in the program) for awhile. Years in fact.

This is the default PuTTY colors. Anyone who uses it knows this one:

PuTTY Default

Today with some GoogleFu I found two that I like. One is pretty simple to implement. This one I am calling Lime Sherbet, mainly because it looks like lime sherbet. I got the instructions from Michael Crowley at Mt. Holyoke College. This is his putty setup page. This is what it looks like for me:

PuTTY Lime Sherbet

To do this, you need to set or verify 6 settings in PuTTY listed here with R/G/B numbers:

  • Default Forground: 0/0/0
  • Default Bold Forground: 0/0/255
  • Default Background: 206/255/221
  • Default Bold Background: 255/0/0
  • Cursor Text: 0/0/0
  • Cursor Colour: 0/255/0

The 2nd Option I found is a bit more advanced. It is called Desert color scheme, which is similar to a vim color scheme. I found instructions on the vim.org website: Tip #1291. It is a bit more advanced in that you override the ANSI colors. Have a look:

[Edit: This color scheme is known as “Zenburn“, and I still like using it]

PuTTY Desert

I did not use the registry file, so here are the colors listed manually:

  • Default Foreground: 255/255/255
  • Default Background: 51/51/51
  • ANSI Black: 77/77/77
  • ANSI Green: 152/251/152
  • ANSI Yellow: 240/230/140
  • ANSI Blue: 205/133/63
  • ANSI Blue Bold 135/206/235
  • ANSI Magenta: 255/222/173 or 205/92/92
  • ANSI Cyan: 255/160/160
  • ANSI Cyan Bold: 255/215/0
  • ANSI White: 245/222/179

I am going to use both for awhile and see if I like either. I still might make some tweaks, but they are both better than the default- at least for me.

Anyone have any schemes they are particularly happy with?

One of the Word Press plugins I use is wp-shortstat. It is a handy stat tracker that allows me to look at keyword searches and referrers right at the Dashboard level within WP.

One of the drawbacks of this stats system is the country code lookups. For my setup it was not working at all, so I was getting a lot of unknown countries. That does not make it very useful. I did a bunch of research and decided that rolling my own lookup into wp-shortstat and using a free data source was the way to go.

Being the holiday season and being a fairly generous guy (don’t laugh, please), I am going to make the changes available to my reading public. All three of you. I can say that because I now have working stats 🙂

In order to do this update/upgrade you will have to be comfortable with your database, editing PHP files, and some basic UNIX text processing commands. There are no expert tasks here, by any stretch.

First step, download some data. I got my data from Software77. It is a ZIP file that contains a CSV file. Unfortunately, a small amount of conversion needs to be done on the CSV file. The first is to strip off the comment lines. Every comment line they use starts with a “#” so it is pretty easy to do:
[stevet@argon]$ grep -v "^#" IpToCountry.csv > IpToCountry.nohash.csv

Next, I needed to remove all of the quotes from the CSV file. If I tried to import with the quotes, the data in MySQL would not be in the right format- the quotes get imported along with the data I wanted. Easy enough to strip them off:
[stevet@argon]$ sed "s/"//g" IpToCountry.nohash.csv > IpToCountry.clean.csv

Now we have a bunch of data (about 4.5 meg) that is ready for the database.

Next we need to get the data into the database which requires two things: a new table in the wordpress database and running an import command. To create the needed table, connect to you blog’s database. Remember I am using MySQL, you will need to season these commands to taste if you are using Postgres or Oracle or whatever else. Here is the SQL to create table I used. It has the same naming convention as the other WordPress tables:
DROP TABLE IF EXISTS `wp_hostip`;
CREATE TABLE `wp_hostip` (
`ip_from` bigint(20) default NULL,
`ip_to` bigint(20) default NULL,
`registry` varchar(50) default NULL,
`assigned` int(11) default NULL,
`ctry` char(2) default NULL,
`cntry` varchar(10) default NULL,
`country` varchar(256) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Simple enough. Now you need to import the data into that table. Luckily MySQL has a really simple import from CSV command called LOAD. Here is the usage:
LOAD DATA LOCAL INFILE 'IpToCountry.clean.csv'
INTO TABLE wp_hostip
FIELDS TERMINATED BY ','
LINES TERMINATED BY 'n'
(ip_from, ip_to, registry, assigned, ctry, cntry, country);

Now you have all of the data you could possible need (for awhile anyway). The trick is getting wp-shortstat to use it. Time to modify some PHP code. You only need to modify one function in one file.

Find your wp-shortstat.php file, it is in the wp-content/plugins directory. Open that file in your favorite editor and find the determineCountry function. Modify the function to look like the following. You can comment out the current code if you don’t feel comfortable deleting it.
function determineCountry($ip) {
global $wpdb;
list($a,$b,$c,$d) = split ('[.]', $ip);
$calc_ip = $d + ($c * 256) + ($b * 256 * 256) + ($a * 256 * 256 * 256);
$query = "SELECT ctry FROM wp_hostip where $calc_ip >= ip_from AND $calc_ip <= ip_to"; $country = $wpdb->get_var($query);
return $country;
}

That is it. Once the file is saved, the next time a non-admin connects to your blog wp-shortstat will log their arrival with the country code working.

I tested it by firing up the dusty IE on my box and connecting to my blog. I then looked in the wp_ss_stats table to see the newest entries and sure enough the stats are being updated with complete data. Sweet.

That is Part 1. If you got some value out of this let me know. I like to be complimented 🙂

Part 2: Automating the update of the wp_hostip data. The download site claims data should only need be updated every week at the most. I won’t even say it needs to be updated that often. I am going to update it monthly. Part 2 will explain how I go about doing that. Part 2 will also show how to fix the country data in wp_ss_stats that is currently marked as “unknown”.

Happy Holidays Everyone!

I was asked to upgrade/dogfood Office 2007 today. This annoys me for a lot of reasons; but I will limit my list of peeves to technical ones here.

  • Instant Search. I don’t give a flying leap though a rolling donut about Instant Search. But there is an very annoying flyover bar asking me to install it. If I click on the bar it, correctly, asks if I want to connect to Microsoft and download it. There is no checkbox for “don’t ask me again”. You have to go to Tools->Options->Other->Advanced Options and un-check “Show prompts to enable Instant Search”. Dumb. But at least it works.
  • I like the LookOut plugin. It indexes your mailbox and PSTs and allows for complex and quick searches. According to Microsoft: “Windows Desktop Search 3.0 disables the MSN Toolbar and LookOut in Outlook. LookOut and the MSN Toolbar are now considered to be old versions of Microsoft products. To offer users the clearest and most integrated search experience for Outlook 2007, Outlook disables these add-ins when Outlook starts.” F-That. So it leaves the toolbar there in Outlook- it is just empty.
  • My company has a plug-in for Outlook, that is part of the reason for this dogfood. I didn’t want to upgrade to 2007, but it is a good thing to do a responsible member of the development organization. However- Why do I need to upgrade *all* of Office. Outlook I get. But apparently Word 2003 does not work with Outlook 2007.

Not a big fan at all at this point. Total time of use: 20 minutes. I was never of a fan before, this pretty much seals the deal.

The next step is Lightning which integrates Thunderbird and Sunbird. Maybe I will be happier then. Doubt It.

Fry’s has the Airlink101 AGIGA32PCI cards for $5 each (limit 2, normal $20). Offer expired tomorrow.

I am going to be building a linux based router at the house and wanted to go 1000Mbps for the network so I picked two up. They use a Realtek chipset and claim they are Linux 2.4.x and 2.6.x compatible along with the standard Windows versions.

I’ll let you know how well they work when I start building out my new router.

I also picked up a 10/100/1000Mbps 8 port switch, but that was not as good a deal.

Finally cashed in a SnG yesterday when I got hit with the deck early (and played smart- shocking I know). I ended up 3rd when my 8-9 could not out kick a 8-10 on a 8-8-x flop. I may play the Mookie tonight, depends how I feel. It is going to be huge with the BBTwo going on.

I am looking at using XEN to virtualize all of our test and development boxes at work. The newest versions of XEN along with the newest versions of Intel and AMD systems can handles Windows along with Linux. My plan is to start with Linux only to start and move on to Windows once this system is stable and makes people happy.

To do the initial testing I am using a personal machine running CentOS 4.4. It won’t be quick and will only handle one or two XEN instances but it will certainly get me the knowledge to get this into some sort of production run.

The Steps

  • Check out the install guide
  • Realize that CentOS 4.4 will not work. Download CentOS 5. Reinstall the server box with that version (thanks to kickstart and easy task)
  • XEN is now a yum package. yum install xen (this installs 10 packages)
  • Now for the kernel. yum install kernel-xen (just one package)
  • Update GRUB; the yum install added the correct version to menu.lst, but the default boot needs to be changed to match (‘0’ in this case).
  • Reboot and make sure xen is loaded (kernel and init.d process)
  • XEN will start automagically after the reboot because of init scripts, run xm list to see Domain0 running – this is the host server
  • Now the fun parts. These next couple of steps took me days off and on to get working. I, unfortunately, did not see this post by lyz until *after* I figured out these steps.
  • Create a new initrd image. Use something like the command: mkinitrd -f –with=xennet –builtin=aic7xxx –builtin=serverworks –preload=xenblk –omit-raid-modules –omit-lvm-modules –fstab=/mnt/etc/fstab /boot/xen-initrd.img 2.6.18-8.1.1.el5xen Obviously you need to match your kernel version for the last argument. You can keep this file for any of the systems that are going to use this kernel as part of your guest XEN installs.
  • Download the CentOS 4.4 base images from Jailtime.org. They are small and have very few things installed, but they work- and can be expanded to any size you need. The package includes a sample swap file as well.
  • Create a xen config file for your installation. I created a script that will help me create custom images by mounting the img file from Jailtime and editing the network config and anything else I need customized. Here is a sample xen config file I am using:
    kernel = "/boot/vmlinuz-2.6.18-8.1.1.el5xen"
    ramdisk = "/boot/xen-initrd.img"
    memory = 256
    name = "fast-mc-1"
    vif = [ '' ]
    disk = ['file:/var/lib/xen/images/fast-mc-1.img,sda1,w', 'file:/var/lib/xen/images/fast-mc-1.swap.img,sda2,w']
    root = "/dev/sda1 ro"
  • Now start the image: xm create -c newxen.cfg
  • The image should start but it will look like the console hung. You should be able to connect remotely via SSH. However- remote root login is not enabled. We need to fix console login and enable remote root via SSH (if that is wanted)
  • Break the attached console: CTRL – ] then run xm shutdown guest-domain-name
  • Mount the OS image: mount -o loop imagefile.img /mnt
  • Change to the images dev directory (/mnt/dev)
  • Use the host’s MAKEDEV to create some devices: /dev/MAKEDEV null zero random urandom console tty pty hda xvd loop
  • Set the systems console to listen to xvc0 rather than tty2. This is located in /mnt/etc/inittab in the gettys section. I replaced the tty2 line with the following: 2:2345:respawn:/sbin/mingetty xvc0
  • If you want to allow remote root SSH, edit /mnt/etc/ssh/sshd_config and set PermitRootLogin to yes
  • If you could login when the system first came up, you would notice that nash-hotplug was taking up 100% CPU. This is not cool. You can fix that problem by adding a line to the end of /mnt/etc/rc.sysinit. The line I added was: /usr/bin/killall nash-hotplug
  • Now unmount the image file and rerun xm create -c newxen.cfg
  • The console should be up, the root login for the Jailtime images is ‘password’. Try both console and SSH login (if enabled). Everything should be good to go.

I hope someone who reads/found this entry gets some value out of it. Using this entry, lynema.com link above, and the xen install guide you should be able to get enough knowledge to get XEN working in your environment. As I expand my test lab (only two XEN hosts right now) I will have more details on customizing images and auto-loading them. The plan is to let Dev and QA create and destroy images on their own without having to rely on my hands on customization. It is a *long* way off, but this is a major step in the right direction.

You have read that one of the packages for Linux that I really like is FireHol. I still use it and it works really well. I have recently made two changes to my config that people might find handy.

First I started to blacklist people who repeatedly try and login via SSH. I get a daily email telling me when people try and where they are from. The line to add to the firehol.conf looks like this:

blacklist this 10.10.10.10 # where 10.10.10.10 is the IP address of the offender

Yeah, these bastards probably won’t try again and it is usually a DSL or Cable user; but they are still blocked.

The other change is to reduce iptables logging. Before this change pretty much every blocked connection was printed to the console. Annoying if you are trying to actually *use* the console. This takes two changes. The first is also in firehol.conf add the line:

FIREHOL_LOG_LEVEL=3

Second, modify the /etc/sysconfig/syslog file and change the KLOGD_OPTIONS to include a “-c 3” line. You will need to restart the syslog service (and the firehol configuration of course). This sets the logging to the ERROR level rather than the WARNING level. Much nicer.

In my next geekout post I will get all xen on you. As in xen virtualization for linux.

[ Edit: dumb wordpress interpeting my ‘_’ to make things bold or italic; now fixed ]

I am officially done at IBM. I signed my last rights away an hour or so ago and can now collect unemployment. Well, for one day anyway 🙂 I start my new job Monday.

I am in the process of moving this blog (and other darkrune.org stuff) to my SliceHost hosting environment. Hopefully everything will go well and it will be up and running today.

-ST

Website Hosting

I am going to move to a new hosting environment in the near future. Currently I am using GoDaddy hosting for about $4 a month. This is great for just hosting the blog and my GPS tracking tool- but not for anything else.

I am using SliceHost with a test domain currently. I was able to get a bone stock Fedora Core 6 install for $20 a month. This includes 10GB of storage, 256MB of RAM, and 100GB of bandwidth.

So far I have installed apache, postfix, firehol, mutt, and a bunch of other utilities and I am at 10% disk space. As I migrate my databases, web content, and other utilities I expect that number to climb, but I am safely within the margin. I have email working (in and out), web working, and all of the normal system things I wanted. Pretty sweet for a couple of hours work total.

My current hosting runs until July but I will be fully migrated in the next month or so. I will likely migrate in pieces. DNS then email then web content; but I will have to see how busy I am over the next month or so. The database used for this blog will certainly be tricky to export and import to my host and will likely take up most of the migration time.

I think, so far, the best part of having this host up and running is that I get a Linux box without having to run hardware. I do have a box at the house installed, but I can’t really host off of my cable modem and I don’t want to leave it running all the time just because I *might* use it. This way, I have full time access to a machine and don’t have to worry about pretty much anything.