05 January 2016

I’ve moved the blog to a static site generated by JBake. The source for the content lives in my techblog project in Github, so I have a full versioning of my content for the small price of a git workflow.

I installed JBake using the familiar SDKMan that I already use to manage my Grails and Groovy installations. I initialized it with the Groovy templating engine and have started customizing the templates.

To make sure this thing is easy to update, I keep a local clone of the repo, so I can update it any time and push whenever I’m ready. I have a shell script scheduled to run on the server which basically does:

cd techblog
git fetch
git merge | grep "Already" > /dev/null || jbake

That little bit of code only runs jbake if the git pull doesn’t say "Already up-to-date". That provided me a simple little "continuous integration" hook that polls git for changes to trigger the build. I’ll probably use this trick in other places.

I brought all my old content from my old database into the new platform using a quick little Groovy script to dump out an HTML file for each article including the header of metadata for JBake’s use. While most of these old articles will remain HTML, I intend to use AsciiDoctor format for all the new stuff.

I’ve been collecting a long list of (mostly technical) articles to write, but replacing the old platform kept trumping my attempts to write. Hopefully, this move can open the flood gates, and eventually, I’ll break out another instance of it for the photography blog. JBake should make it easy and interesting to continue the blogs.

Replacing a Drive in the Software RAID

13 December 2012

I realized upon trying to replace a drive in my Linux software RAID, that I had never previously documented this process.

The power failed a couple days ago, and sitting around for 10 hours not spinning was bad for my one Western Digital 500GB drive, so it never came back online, but the computer booted up just fine with 2 of the 3 drives. I ordered a new 1GB drive to replace it within 2 hours of the problem.

When the new drive arrived, I shutdown the computer, unplugged the failing SATA drive, and replaced it with the new one. Linux again booted up with only 2 drives active.

To ensure that the partitions matched, I did an sfdisk -d /dev/sda | sfdisk /dev/sdb. cfdisk was unhappy with the drive initially, but fdisk was happy to read the table and write it back cleanly. Then I could open it again in cfdisk and add one more primary partition to use the extra non-redundant 500G on the new drive.

With the partitions in place, it was time to insert the new partitions back into the RAID devices: mdadm /dev/md0 --add /dev/sdb1, mdadm /dev/md2 --add /dev/sdb5, etc, until all the drives were re-established. Watching /proc/mdstat, I could see that the RAID started recovering the devices, and I could go to bed.

I did manage to do something wrong at one point, so a quick mdadm /dev/md0 --fail /dev/sdb1 and mdadm /dev/md0 --remove /dev/sdb1 allowed me to fail and remove a partition, fix it up, then add it back when I was done. All this could be done with the system up and running—that's pretty convenient.

Desktop Luddite

27 October 2011

get off my lawn!

I've been happily kicking along in Gnome 2.x-whatever on my Debian and Ubuntu machines for quite sometime. When Ubuntu tried to push me over into Unity back in April, I gave it half a day, then reverted back to Gnome 2 for familiarity and more workspaces.

Well, it's October now, and Ubuntu made the push again, but this time, it also pushed Gnome up to 3.2, which is drastically different as well. With no solace in Gnome, I've had to just sort of try to figure out the Unity-way with no controls and their "it's for your own good" mentality. (It feels a lot like that other OS that I wiped off a Mac Book Pro.)

A couple more days passed, and my Debian unstable machine upgraded to Gnome 3.0, and my good ol' Gnome 2.x was gone. So I'm trying Unity on my Ubuntu netbook, and I'm trying Gnome 3.0 on my photo workstation/server. They're similar enough, but it's still disorienting bouncing between the 2 environments -- while Unity hasn't offered any absolute show-stoppers, I may land on Gnome for consistency. It might also be time to look into KDE or XFCE -- somehow, I think they probably still offer me all the knobs and buttons I've used previously to customize my desktop.

If I wanted to give up my choices, I could just run a Mac -- they have nice hardware and a Unixy OS.

Quick and Easy Groovy for the Web

22 June 2011

Groovy can be used pretty easily to spin up some simple web pages in almost the same way one would hack out some PHP or JSP without going to the trouble to do an all-out Grails project.

The Groovy Servlet allows you to pack up the groovy-all-*.jar, a simple web.xml, and whatever *.groovy scripts you want and deploy it right into Tomcat as a plain WAR file. The Groovy Servlet page

Here's a bit of a script I put together to jump start a simple Groovlet project by packaging a WAR file from a directory of scripts. This isn't Groovy Servlet code itself, but just a command-line tool. (The Groovy Servlet page linked previously has examples for writing your own servlets.) This script will copy in the Groovy JAR and generate the basic web.xml to wire up the GroovyServlet to dynamically execute your scripts. I also have a downloadable copy of package_groovlet.groovy.

#!/usr/bin/env groovy

if (args.size() < 1) {
    print """\
        |Usage: package_groovlet.groovy <war-name>
        |Package the current directory into a Groovy Servlet war.

def war = args[0]
def embed = "${System.getenv()['GROOVY_HOME']}/embeddable"

def ant = new AntBuilder()

ant.sequential {
    delete(dir: 'build')
    mkdir(dir: 'build/WEB-INF/lib')
    copy(toDir: 'build/WEB-INF/lib') {
        fileset(dir: embed) {
            include(name: 'groovy-all-*.jar')
    copy(toDir: 'build') {
        fileset(dir: '.') {
            exclude(name: 'build/**')

new FileOutputStream('build/WEB-INF/web.xml').withWriter { webxml ->
    webxml.print """\
        <!DOCTYPE web-app PUBLIC
          "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
          "http://java.sun.com/dtd/web-app_2_3.dtd" >

ant.jar(destfile: "build/${war}", basedir: 'build')
println "Created build/${war}"

All the Posts

January 2016

December 2012

October 2011

June 2011

December 2010

September 2010

June 2010

May 2010

February 2010

January 2010

August 2009

March 2009

February 2009

November 2008

October 2008

June 2008

March 2008

January 2008

December 2007

October 2007

September 2007

August 2007

July 2007

June 2007

May 2007

April 2007

March 2007

February 2007

January 2007

December 2006

November 2006

October 2006

September 2006

August 2006

July 2006

June 2006

May 2006

April 2006

March 2006

February 2006

January 2006

December 2005

November 2005

October 2005

September 2005

August 2005

July 2005

June 2005

May 2005

April 2005

March 2005

February 2005

January 2005

December 2004

November 2004

October 2004

September 2004

August 2004

July 2004

June 2004

May 2004

April 2004

March 2004

February 2004

January 2004

December 2003

November 2003

October 2003

September 2003

August 2003