Subversion hosting, CVS hosting, Trac hosting, Bugzilla hosting and software collaboration Providing hosted Subversion, CVS, Trac and Bugzilla repositories

March 20, 2008

Loading The Laptop With DesktopBSD

Filed under: Operating Systems — Tags: , — Greg Larkin @ 6:21 pm

Hi everyone,

As you may have noticed, I’m a pretty big proponent of FreeBSD. Lately, I’ve been interested in building a laptop that is light, has long battery life, can do basic email checking/web site browsing/remote server admin over SSH/etc. A bonus would be if I could run FreeBSD in a VMware VM and work on my ports if I’m stuck on a long plane ride.

Wait a minute – forget the VM! I’ll just run DesktopBSD directly on the laptop and have everything I need:

  • Email – check (Thunderbird)
  • Web browsing – check (FF, natch)
  • SSH – check
  • Full /usr/ports tree – check!

I’ve got version 1.6 loaded up on my venerable IBM Thinkpad 600x that had been mothballed for a couple of years, and after replacing the CMOS battery (go away nasty POST 161/163 errors!), and replacing the first-gen wireless PCMCIA card with a Linksys WPC54G, things are humming along nicely.

I did have to wrestle with the drivers for the Linksys card, guided largely by a helpful post on TaoSecurity, but eventually I got it working.

I’m currently in building the OpenOffice 2.x port so I can really get things done remotely, but it has been compiling for 2+ days now (!), and there’s no indication when it will finish!

I’ll post more about DesktopBSD as I get further into it.

Bookmark and Share

Keep in touch,
Greg, LLC

Call me - Greg Larkin: error

March 18, 2008

FreeBSD 7.0 VMware Image Available

Filed under: Operating Systems — Tags: , , — Greg Larkin @ 12:18 pm

Hi everyone,

Since FreeBSD 7.0 was recently released, I figured it’s a good time to put a VMware image together and have a look. Probably one of the most interesting new enhancements is the addition of the ZFS filesystem. I can’t wait to try that out, and it should make managing disk space a lot easier in the context of the service.

You can find the zipped image on the BitTorrent tracker. Some notes about the image:

  • The VM has been configured with 768Mb of memory. You can reduce it to 512Mb, but the ZFS documentation says “Me want more memory!
  • The root password is “password”
  • ZFS is enabled by default
  • The /usr/ports filesystem is located in a ZFS pool
  • The Ethernet interface is bridged to the host and uses DHCP

I tested this VM in VMware Server and VMware Player, and it seems to work fine. If you have any questions or problems, feel free to post comments here.

Bookmark and Share

Keep in touch,
Greg, LLC

Call me - Greg Larkin: error

March 17, 2008

Setting Up Outbound Connections on a VMware Host-Only Network

Filed under: Operating Systems — Tags: , — Greg Larkin @ 9:23 am

Hi everyone,

I was recently reminded of a problem I ran into when I first set up the service on VMware Server. The VMware technology has the concept of virtual networks, including a host-only network. The host-only network enables several VMs on the same host to communicate on their own private Ethernet switch. This is a great way to simulate a real-world, production environment.

However, what if you want resources on the host-only network, such as private servers without routable public IP addresses, to be able to make outbound connections to the outside world? That’s where it gets a bit tricky! The service assigns a FreeBSD jail to each client, and these servers each have an IP address on the host-only network. They need to make connections to the public Internet, so after some digging around, I found a solution.

The first thing to do is assign a host-only network gateway address to your VMware Server host. In my case, the host-only network is addressed as The physical server’s gateway address is therefore

Each VM has 2 NICs defined, one with a routable Internet address and one with a host-only address, perhaps A FreeBSD jail running inside a VM will have a host-only IP address aliased to the 2nd NIC, such as Somehow, a packet originating in the jail must pass out through the VM, then the physical host to the destination and back again.

The FreeBSD VM can easily send its packets out to the host-only address on the physical host by using this directive in its /etc/rc.conf file:


Since the jail IP addresses are aliased to the host-only NIC in the VM, packets originating from a jail will also use as their default router.

At the physical host level, in order for packets to pass from its host-only interface to its external interface, it must be configured as a router. That’s done by adding the following directive to the /etc/sysctl.conf file (on RHEL 4 and other flavors of Linux):

net.ipv4.ip_forward = 1

So far, so good. Now here’s where the craziness, errr magic, happens! The following firewall script is added to /etc/rc.local:

IF_PUB1=eth0              # Public Ethernet interface of VMware Server host
IP_PUB1=AAA.BBB.CCC.11    # Public IP of VMware Server host
NET_PRV1=   # VMware Server host-only network
$IPT -F -t nat
$IPT -F -t mangle
$IPT -F -t filter
$IPT -t nat -A POSTROUTING -s $NET_PRV1 -o $IF_PUB1 -j SNAT –to $IP_PUB1

The most important bit of this script is the last line. The rest of it defines some variables and cleans up the firewall rules to a known state. Since a hardware firewall is doing all of the heavy lifting in front of this server, the iptables software firewall is going to serve simply as a source address packet mangler. Hmm, “packet mangling” – that sounds nasty! But it’s actually a good thing here, because it ensures that packets get from point A to B and back again.

We also need to look at the routing table to figure out how source address mangling will change how the packet behaves:

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
AAA.BBB.CCC.12  AAA.BBB.CCC.11 UGH       0 0          0 eth0
AAA.BBB.CCC.8 U         0 0          0 eth0   U         0 0          0 vmnet1         AAA.BBB.CCC.9         UG        0 0          0 eth0

Normally, if a packet originates from the vmnet1 interface (VMware host-only network) with a source address of and bound for (, it will be handled by the default route and sent out the eth0 interface. That’s all well and good, but when Google tries to reply, a router somewhere along the way sees a source address of and drops the packet.

Enter POSTROUTING and SNAT! Here is the expanded iptables command from our script above:

/sbin/iptables -t nat -A POSTROUTING -s -o eth0 -j SNAT –to AAA.BBB.CCC.11

Ok, let’s break it down:

  1. Add a rule to the nat table (“-t nat”)
  2. Append the rule to the POSTROUTING chain (“-A POSTROUTING”) – i.e. apply rule after deciding which route will handle the packet
  3. Process the packet when its source address originates on the host-only network (“-s”) and it’s bound for the eth0 interface (“-o eth0”) – normally a bad thing!
  4. Jump to the SNAT target for source address modification (“-j SNAT”)
  5. Change the source address to AAA.BBB.CCC.11 and send the packet on its merry way (“--to AAA.BBB.CCC.11”)

This means that when the packet reaches the Google server, it contains the valid source address of AAA.BBB.CCC.11 that maps to our VMware Server host. Reply packets flow back to the host, and then iptables remaps the destination address from AAA.BBB.CCC.11 to the proper host-only network originating address, according to the stored connection information.

Iptables is an incredibly flexible tool that performs many useful packet modification tasks, as well as firewall functions. If you have any favorites uses for it, feel free to post comments and feedback!

Bookmark and Share

Keep in touch,
Greg, LLC

Call me - Greg Larkin: error

March 10, 2008

Installing VMware Tools In A FreeBSD 7.0 Guest

Filed under: Operating Systems — Tags: , — Greg Larkin @ 7:35 pm

Hi everyone,

I’ve got FreeBSD 7.0 downloaded and running as a VMware Server virtual machine so I can start checking it out and get a feel for how it works. Once ZFS is deemed stable for production, I’ll plan to migrate to the 7.x series.

The first thing I generally do after setting up a new VM is install VMware Tools. Wait – scratch that. The first thing I have to do before installing VMware Tools is install Perl, since it’s not part of the FreeBSD base system. That’s easy enough:

cd /usr/ports/lang/perl5.8 && make WITH_GDBM=yes install clean

Ok, on to the VMware Tools installer! After starting the script, I answered a bunch of questions (used all default responses), and finally was met with this somewhat odd message:

VMware Tools Installation Failure Under FreeBSD 7.0 Guest

Wait a minute – I’m pretty sure I’m installing in a virtual machine here! Initially, I pored through the installation Perl script and discovered that it executes vmware-checkvm to determine if it’s running inside a VM or not. Ok, let’s try that by hand:

vmware-checkvm Failure Under FreeBSD 7.0 Guest

That’s a problem! vmware-checkvm is a statically-linked binary, and to get it working, the FreeBSD compat6x port needs to be installed. The compat6x port installs a variety of libraries that were found in FreeBSD 6.x but have had their versions bumped for FreeBSD 7.0.

cd /usr/ports/misc/compat6x && make install clean

Hmm, still no joy after doing that – vmware-checkvm is still core dumping. After more Googling and nosing about in the VMware Tools installation script, I learned that VMware expects the library installed by compat6x to be in /lib. However, all compat{3,4,5,6}x ports install their libraries in /usr/local/lib/compat to avoid messing with the base system.

A simple symbolic link gets in place for VMware:

ln -s /usr/local/lib/compat/ /lib

And now success, right? Wrong!

VMware Tools Installation Fails Again

I’m not logged in over the network, so why am I getting this message? It turns out that tcsh (root shell in FreeBSD) is setting the REMOTEHOST environment variable, even though I’m logged in at the VM’s console.

The solution is a simple command:


Start up the VMware Tool installer one more time, and now it works!

Maybe the newest version of VMware Server supports FreeBSD 7.0 natively, so I’ll have to test that out soon. Details will be posted here when I do!

Bookmark and Share

Keep in touch,
Greg, LLC

Call me - Greg Larkin: error

March 7, 2008

Basic Views In CodeIgniter

Filed under: Software Development — Tags: , , , , — Greg Larkin @ 3:24 pm

Hi everyone,

A while back, I hooked up my CodeIgniter sample application to a MySQL database. That was easy, and now I’ll show how to move your presentation code into separate view files, instead of echo’ing HTML from inside a controller file.

According to the CodeIgniter manual, views are stored in the /views (hmm, that makes sense!) directory of your application, and they can be divided up across functional areas with subdirectories. Since it’s possible to create page snippets and load them in sequence, you might have a directory structure like this:


Then when you want to render a particular page, say the “add user” page of your web app’s administrative interface, the code would look like this:


I haven’t gotten that complex yet, but I did move the code to display my user count into a view and set the value in the controller like so:

function count_users()
        $numUsers = $this->user->count_users();
        $data = array(‘num_users’ => $numUsers);
        $this->load->view(‘user/showcount’, $data);

The file /views/user/showcount.php is pretty simple:

<head><title>Welcome to the User Area!</title></head>
This page is rendered by the file: <?php echo __FILE__; ?>
<p>There are <?php echo $num_users; ?> users defined in the database.
<p><?php echo anchor(‘user’, ‘Go back’); ?>

Ok, this all seems to be pretty easy. Of course, there’s a bunch more functionality in the CodeIgniter framework, but I think what I’ll do for my next post is shift gears and go through the same basic exercises using CakePHP, Prado, and the Zend Framework.

It will be interesting to see if there’s any similarity to the way the classic “Hello, world.” program varies in complexity based on implementation language!

Bookmark and Share

Keep in touch,
Greg, LLC

Call me - Greg Larkin: error

March 6, 2008

FreeBSD Port For CodeIgniter Upgraded to 1.6.1

Filed under: Software Development — Tags: , , , , , — Greg Larkin @ 7:01 pm

Hi everyone,

I’ve submitted some new FreeBSD port upgrades over the past week, including new support for CodeIgniter 1.6.1. In addition to the version bump of the upstream distribution, I also added some new bits to allow customization of certain CI files. The port is also careful to avoid removing those modified files when a new port upgrade comes along.

The reference for how to handle user-configurable files installed as part of a port can be found in the excellent FreeBSD Porter’s Handbook in the Configuration Files section.

In the new CodeIgniter port, the following user-configurable files are installed:


What this does is install a reference copy of each file (*.sample) that is not expected to be edited by the user. The actual file that CodeIgniter uses to render pages (no .sample suffix) is user-configurable as needed.

Then some crazy-looking shell code in the pkg-plist file makes sure that any edited files are not removed if the port is deinstalled or upgraded (reformatted for readability):

@unexec if cmp -s %D/%%WWWDIR%%/%%CI_CONF_DIR%%/autoload.php.sample \

    %D/%%WWWDIR%/%%CI_CONF_DIR%%/autoload.php; then \

    rm -f %D/%%WWWDIR%%/%%CI_CONF_DIR%%/autoload.php; else \

    %%ECHO_MSG%% "===> Customized %D/%%WWWDIR%%/%%CI_CONF_DIR%%/autoload.php \

    has not been removed"; fi


@exec if [ ! -f %D/%%WWWDIR%%/%%CI_CONF_DIR%%/autoload.php ]; then \

    cp -p %D/%F %B/autoload.php; fi

This concept needs to be implemented in several of the other ports that I maintain, including CakePHP and Prado. If anyone has a list of files that are user-configurable in each of those frameworks, please send it along!

Bookmark and Share

Keep in touch,
Greg, LLC

Call me - Greg Larkin: error

March 3, 2008

A Slight Detour

Filed under: Misc — Tags: — Greg Larkin @ 10:04 pm

Hi everyone,

I’m a bit late on posting to the blog, but I can explain! I took a vacation to Sedona, AZ last week (reason: here!) and didn’t have too much time to get online between marathon mountain-biking and hiking trips. I am planning some new posts for later this week, though.

In the mean time, I can show you a few pictures from the Sedona area. If you get a chance, definitely put this place on the list to visit. It is simply awe-inspiring!

Here’s a nice shot of the unnamed butte next to Soldier Pass that was lit with the evening sun as we climbed up to Devil’s Bridge:

Power Thumbnail (Topo map reference)

Hiking to the summit of Bear Mountain is an absolute must if you visit Sedona. This trip is the longest 5 mile hike I think I’ve ever been on. Bring tons of water and sunscreen, and make absolutely sure you follow the trail closely on the way down. Luckily, if you do get off-trail, it’s fairly easy to see where you should be going, i.e. not along the edge of Fay Canyon!

Power Thumbnail (Topo map reference)

Bookmark and Share

Keep in touch,
Greg, LLC

Call me - Greg Larkin: error

February 29, 2008

This Is Getting Ridiculous!

Filed under: Business — Tags: , — Greg Larkin @ 3:57 pm

Hi everyone, is still attracting a fair number of confused folks who think they’ve landed on the CVS pharmacy corporate site. This all started when we launched some new Google AdWords campaigns. Apparently, the folks viewing the ads on the Google AdWords Content Network aren’t terribly aware of what they’re clicking. Here are some recent sample inquiries:

<span style="width: 500px">*** *** ***
I have a CVS <span class="hl">Blood</span> <span class="hl">Pressure</span> Monitor and it keeps showing Full before the reading </span>

<span style="width: 500px">appears. How do I get rid of that word?.
*** *** ***</span>

Umm, reboot the monitor?
*** *** ***
I picked up a perscription [sic] at ny [sic] CVS store today and on the bottom of

the receipt there is a message:

" Your Extracare Accounr [sic] Information is incomplete. Please visit "

Well, here I am........What does the mesage [sic] mean ??????
*** *** ***

I love this – “Well, here I am…” and the actual web site URL is included. If you really were “here”, I wouldn’t have received this message!

Ok, I guess the ads need to be configured with some negative keywords. Interestingly, the negative keywords “pharmacy” and “extracare” were already in the campaign, but I just added some more like “pharmacy” and “drugs”. Next step – turn off the ad delivery on the content network.

Bookmark and Share

Keep in touch,
Greg, LLC

Call me - Greg Larkin: error

February 22, 2008

Super-Configurable Subversion Notifications

Filed under: Source Code Control — Tags: , , , — Greg Larkin @ 8:13 pm

Hi everyone,

Are you using the Perl SVN::Notify module to generate your Subversion commit notification emails yet? If not, go install it, and try out svnnotify. It generates very nice-looking text or HTML-formatted emails, and it has loads of options to make it do just what you want. Place as many svnnotify commands as you like in your Subversion post-commit hook script, and off you go.

Unfortunately, with a large number of developers and many different projects in your repository, your post-commit script may start to look like this:

svnnotify -r $2 -d -P "SVN Commit " -O -H HTML::ColorDiff -p $1 -t
svnnotify -r $2 -H  Mirror::Rsync -p $1 --rsync-host \
    --to /usr/local/www/htdocs --rsync-delete=yes
svnnotify -r $2 -d -P "SVN Tag Creation " -O -H HTML::ColorDiff -p $1 \
svnnotify -r $2 -d -P "SVN Branch Creation " -O -H HTML::ColorDiff -p $1 \
svnnotify -r $2 -d -P "SVN Vendor Drop " -O -H HTML::ColorDiff -p $1 \
svnnotify -r $2 -d -P "ClientA Special Version Commit " -O -H HTML::ColorDiff \
    -p $1 -x

Yikes -that’s bound to keep any Subversion administrator up nights! However, help is on the way from Perl developer John Peacock.

John has created a nice wrapper around SVN::Notify named SVN::Notify::Config. This Perl module transforms the mess of command lines above to a cleaner, easily-editable form using YAML to express the desired svnnotify options.

The equivalent post-commit hook using SVN::Notify::Config is now:

#!/usr/bin/perl -MSVN::Notify::Config=$0
 --- #YAML:1.0
   PATH: "/usr/bin:/usr/local/bin"
   handler: HTML::ColorDiff
   subject-prefix: "SVN Commit "
   handler: Mirror::Rsync
   to: /usr/local/www/htdocs
   rsync-delete: yes
   handler: HTML::ColorDiff
   subject-prefix: "SVN Tag Creation "
   handler: HTML::ColorDiff
   subject-prefix: "SVN Branch Creation "
   handler: HTML::ColorDiff
   subject-prefix: "SVN Vendor Drop "
   handler: HTML::ColorDiff
   subject-prefix: "ClientA Special Version Commit "

That’s a lot more readable, and I expect it will be easier to maintain, even though there are more lines in the file. I’m still boning up on the YAML syntax and how this module uses it, so there may be some optimizations to be made. Feel free to send corrections!

The other thing I like about using YAML this way is it lends itself well to hooking into a notification management web interface, and that makes it even easier to keep those emails flowing where they should.

Bookmark and Share

Keep in touch,
Greg, LLC

Call me - Greg Larkin: error

February 20, 2008

Pssst… Hey Kid, Wanna Free Hard Drive?

Filed under: Misc — Tags: , — Greg Larkin @ 8:17 pm

Hi everyone,

Here’s a little trick I’ve been using for quick deployment of additional virtual disk space to the VMware VMs that comprise the service. The VMware Server installation includes the vmware-vdiskmanager tool for creating, renaming, expanding and generally messing about with virtual hard drives.

However, I don’t like running this tool to create a new 50Gb virtual disk in the middle of the day because it just slams the disk I/O channel. To get around the problem, I’ve created several disks of different sizes during off-hours and compressed them down for easy storage. Then when I need to provision a disk, I expand it, rename it and hook it to the virtual machine in Virtual Center:

VirtualCenter Add Hardware Wizard

So here are some compressed disk images for you (SCSI format):

  • 10Gb (8391 byte download)
  • 20Gb (16415 byte download)
  • 50Gb (40373 byte download)
  • 100Gb (80373 byte download)

Once downloaded, extract them as follows:

nice -19 bzcat xxxGb.tar.bz2 | tar xvfB -

CAUTION: The resulting extracted files will be the actual size represented in the filename. They compress down so well because they are mostly empty space until they are hooked to a VM and a filesystem is created.

After I extract the files, I typically rename the virtual disk to something more meaningful, like the name of the mount point in my VM. This way, I can easily tell which virtual disk is used for what without consulting the VM config file. The disk rename command looks like this:

# vmware-vdiskmanager -n 10GbDisk.vmdk UsrSrc.vmdk
Using log file /tmp/vmware-root/vdiskmanager.log
Renaming completed successfully.
# ls *.vmdk
UsrSrc-f001.vmdk  UsrSrc-f003.vmdk  UsrSrc-f005.vmdk  UsrSrc.vmdk
UsrSrc-f002.vmdk  UsrSrc-f004.vmdk  UsrSrc-f006.vmdk


Bookmark and Share

Keep in touch,
Greg, LLC

Call me - Greg Larkin: error
Pages: Prev 1 2 3 4 5 6 Next

Powered by WordPress