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?



  1. I really like your tools!

    I wonder what you use for managing startup services since sysv-rc-conf does not work anymore, at least for some things now managed with upstart? (e.g. tftp)

    I have changed /etc/init/tftpd-hpa.conf to:
    start on runlevel [!12345]
    so that it will only start if I manually:
    /etc/init.d/tftpd-hpa start
    Which is what I want, but this does not seem like a best practice. Looked for some better solution or documentation, but have not found anything.

  2. I think this is a great idea. I don't have servers like you do, but I'm soon to get one, and than I sure would like to know when and why it reboots. I would definitely use this. Some more settings and perhaps a nifty GUI (for KDE too) and it would kick ass!

  3. This is really cool. I would definitely use it. Can I do this on my work computer as well? I rarely ever reboot it and I often access if from home. What do I need to do so that mail can deliver to external addresses like my personal email address? I think by default sending out mail is blocked but I dont know at what level that happens and how to enable it. It would be great if you could forward me to the right direction. Again thanks for this awesome utility!

  4. Looks nice. But isn't asking for configuration information from debconf a bit against Ubuntu's general style?

  5. As a new customer of unmanaged Linodes. This script is just what every Linode customer needs.

  6. Dustin,

    Cool tool. Currently, I know that my server rebooted through logwatch when it shows me the entire dmesg upon a reboot.

  7. Aras, just apt-get install bootmail and it should be ready to send email. All of the necessary tools are installed.


  8. Amit,

    Yeah, logwatch is neat. To get this behavior out of bootmail, you'd simply 'echo /var/log/dmesg >> /etc/bootmail/logs' and it would email you dmesg too. Good idea ;-)


  9. mbp,

    As far as I'm aware, it's only really frowned upon in packages that are installed by default in the debian-installer. Otherwise, debconf questions are very much encouraged to help make packages usable by default. In this case, knowing the email where to send bootmail output is absolutely essential for this package to work properly at all, which is why I've set the debconf priority to "high".


  10. Hi,

    I've installed bootmail on my ubuntu 11.04 server and works like a charm!. At first I didn't have the 'apt-add-repository' tool, but after googling I found out I had to install the following:

    sudo apt-get install python-software-properties

    Thanks for this nice tool!

  11. Hi Dustin,

    Thanks for this, I've been looking for this sort utility for quite some time.

    I just installed it on two servers each running 11.04 or 10.04. If I run `sudo bootmail`, I do indeed get the email. However, when I reboot, I don't get the email. Do I have to do something to turn on this setting??? Thanks.

  12. Regarding my previous inquiry, I just had to set up my mail for the root user. I only had it set up for me before. Thanks for the useful utility!

  13. @Vinh probably your smtp server (exim4, postfix,etc) is configured to only send mails locally. Just run:

    sudo dpkg-reconfigure exim4-config

    and reconfigure it.

    @Dustin another great tool, i am using it on all of my servers. Keep the good work!

  14. I just upgraded my server from Lucid to Oneiric. Bootmail was working for me before. However, I'm not getting the bootmail after upgrade. I note that a manual run of bootmail does indeed send the email, just not at startup.

    $ sudo bootmail
    [sudo] password for vinh:
    gpg: WARNING: unsafe ownership on configuration file `/home/vinh/.gnupg/gpg.conf'
    gpg: WARNING: unsafe ownership on configuration file `/home/vinh/.gnupg/gpg.conf'
    gpg: WARNING: unsafe ownership on configuration file `/home/vinh/.gnupg/gpg.conf'

  15. are there any plans to get this to other distros? Besides my many ubuntu servers, there are also centos servers on which I have to keep an eye on

  16. Hi there!

    I have no intentions on maintaining bootmail for anything other than Ubuntu.

    Someone else is certainly welcome to package it for Debian, CentOS or other distros.

    Sorry! I just brew the beer. It's up to someone else to distribute it :-)



Please do not use blog comments for support requests! Blog comments do not scale well to this effect.

Instead, please use Launchpad for Bugs and StackExchange for Questions.