From the Canyon Edge -- :-Dustin

Wednesday, July 20, 2011

Introducing bootmail!

I have a handful of remote Ubuntu Servers floating around the Cloud, and even a couple of co-lo's at friends' houses.  All of these machines are very much "unattended", and I really don't like it when they get rebooted (unless I pulled that trigger)!

For this reason, I often added a cronjob to these systems to email me when they get rebooted.  It used to look something like this:

@reboot echo "$(hostname) rebooted on $(date)" | \
  mail -s "reboot notice [$(hostname)]"

Of course, I don't like duplicating code all over the place, and I love providing fun little utilities to all of you, so I improved upon this and just uploaded a new package to Ubuntu called bootmail.

You can already install it in Ubuntu 11.10 (Oneiric) with:

sudo apt-get install bootmail

Or you can install it on any older Ubuntu release with:

sudo apt-add-repository ppa:bootmail/ppa
sudo apt-get update
sudo apt-get install bootmail

Note that you'll be prompted by debconf to enter your email address, where bootmail will contact you when your system boots.

And now, each time I boot, I get an email that looks like this:

Subject: bootmail: [mirror] booted on [Tue Jul 19 19:19:44 CDT 2011]
Message-Id: ...
Date: Tue, 19 Jul 2011 19:19:53 -0500 (CDT)
From: noreply@mirror (Bootmail)

Hash: SHA1

bootmail: [mirror] booted on [Tue Jul 19 19:19:44 CDT 2011]

fsck from util-linux-ng 2.17.2
fsck from util-linux-ng 2.17.2
fsck from util-linux-ng 2.17.2
/dev/sda5 has been mounted 26 times without being checked, check forced.
/dev/sda6 has been mounted 26 times without being checked, check forced.
/dev/sda1: clean, 286/61312 files, 61620/244983 blocks
/dev/sda5: 222672/610800 files (0.1% non-contiguous), 1564984/2441872 blocks
/dev/sda6: 153602/29859840 files (1.3% non-contiguous), 67313156/119409129 blocks
init: ureadahead-other main process (880) terminated with status 4
/var/lib/tftpboot missing, aborting.
init: tftpd-hpa main process (907) terminated with status 1
init: tftpd-hpa main process ended, respawning
squid[931]: Squid Parent: child process 941 started
 * Starting AppArmor profiles       [80G [74G[ OK ]
 * Setting sensors limits       [80G [74G[ OK ]
 * Exporting directories for NFS kernel daemon...       [80G [74G[ OK ]
 * Starting NFS kernel daemon       [80G [74G[ OK ]
 * Not starting internet superserver: no services enabled
 * Starting Postfix Mail Transport Agent postfix       [80G [74G[ OK ]
 * Starting the landscape-client daemon       [80G [74G[ OK ]
 * Starting web server apache2       [80G apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName
[74G[ OK ]

Linux mirror 2.6.32-33-server #70-Ubuntu SMP Thu Jul 7 22:28:30 UTC 2011 x86_64 GNU/Linux
Ubuntu 10.04.3 LTS

Welcome to the Ubuntu Server!
 * Documentation:

  System information as of Tue Jul 19 19:19:44 CDT 2011

  System load:  1.06              Processes:           150
  Usage of /:   63.5% of 9.17GB   Users logged in:     0
  Memory usage: 12%               IP address for eth1:
  Swap usage:   0%

  Graph this data and manage this system at


Version: GnuPG v1.4.10 (GNU/Linux)


So I get a date and timestamp, the hostname of the system that booted, and a couple of log files (which are configurable in /etc/bootmail/logs) every time the system boots (thanks for the suggestion, Clint) -- pure awesome for my unattended servers!

I also get a cryptographic signature of the entire message, signed by a GPG key uniquely generated for this local root user.  That piece is handled by another new utility that I've written for Ubuntu, called rootsign.  More about rootsign in my next post ;-)

Is there anyone out there that would use bootmail?

I was thinking about adding some support for bootmail in cloud-init, so that you could pass an email address to your instance through metadata, and it would email you as soon as its up.  What do you think?