For some of my LXC containers, I'm allocating a reserved private IP and need to generate a reasonably unique MAC address that's calculated from the container's hostname. As is LXC's default, I'm using the OUI that belongs to Xensource, Inc (00:16:3e).

Here's a Bash function I'm using:

  if [ -n "$1" ]; then
    RAND=$(echo $1 | md5sum | sed 's/\(..\)\(..\)\(..\).*/\1:\2:\3/')
    echo "$OID:$RAND"
    echo "ERROR: please supply hostname to create MAC address from, e.g.:"
    echo "       $FUNCNAME myhost"

Code in action:

$ GetMAC myhost

Useful references:

Remembering the correct openssl syntax for fetching certificate from a remote host or parsing a local certificate file for useful information is a chore, so I finally took my notes and combined into an easy to use shell script.

The script is mostly useful for not having to remember cryptic syntax, but in some cases will also parse and present information in a more readable format than the default openssl output.

It's also easy to add parsing and formatting as needed.

Read the rest of this entry...

Here's an updated version of a previously posted shell script that uses awk to convert a delimited file (where delimiter can be any character) to HTML tables.

For a little automation project I did, the script needed to process input from a pipe, instead of file. So this updated version adds an "-f" option to get delimited data from a file, or "-" option to get it from STDIN.

Read the rest of this entry...

A shell wrapper script that uses awk to convert a delimited file (where delimiter can be any character) to HTML tables.

Read the rest of this entry...

To export Chrome (or Chromium) browsing history on Linux in a more flexible format than what Settings > History displays, could extract it from the History file, which is an SQLite database.

Read the rest of this entry...

I had a fresh Debian 7 (Wheezy) install on a new server. Some months later, on Dec 21 2013, ran "sudo apt-get update && sudo apt-get dist-upgrade", after reboot, system wouldn't boot, instead dropping me to a "grub> " prompt.

Read the rest of this entry...

The specific use case is that I didn't have Postfix properly configured on some machine to send mail, and it was delivered locally to "/var/spool/mail/root". I fixed the problem by adding my actual email address in "/etc/aliases" such that mail sent to root will now be sent to my email, but would also like the old messages sent there as well.

Read the rest of this entry...

For security, troubleshooting and client billing reasons went to turn on Varnish Cache logging today.

On Debian (should be the same in Ubuntu), with varnish 3.0.4 packages installed from, it's all done in /etc/default/varnishncsa.

Uncommented VARNISHNCSA_ENABLED=1, added a custom LOG_FORMAT line with fields I wanted my logs to contain, using the varnishncsa manual page as my guide. Started up varnishncsa with sudo service varnishncsa start, only to find just the first field from my custom log format logged (remote host, or %h, in my case).

Read the rest of this entry...

After all these years of managing crontab entries, I made an error the other day, causing a job to run on a wrong day. Oops.

I used to have a handy cheat sheet I'd insert at the top of /etc/crontab, but a while back stopped, thinking I've graduated past it. Clearly not, but my web searches for one didn't turn up any I liked. So made my own. Here it is in case anyone else needs handholding:

#+--------------- minute (0-59)
#| +------------- hour (0-23)
#| | +----------- day of month (1-31)
#| | | +--------- month (1-12)
#| | | | +------- day of week (0-7), 0=Sunday
#| | | | |     user    command
17 * * * *     root    cd / && run-parts --report /etc/cron.hourly
25 6 * * *     root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7     root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * *     root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
# your custom jobs here...

Needed a way to tile web browser windows for a system monitoring thing I'm working on. Came across this great tool called wmctrl that allows programmatic control of application windows. Wrote a script to automate launching a bunch of separate Chromium web browser windows, then resize them and arrange in a grid. See also this post on launching multiple Chromium browser windows from the command line.

Here's a video of the script in action:

Read the rest of this entry...