These Things Matter to Me
Wednesday, July 16, 2008
  Custom boot messages for your Redhat Linux or CentOS-based virtual appliance
Upon boot, many virtual appliances automagically start services, log users in, or display helpful messages beyond what a normal OS would.
After all, a primary use-case of virtual appliances is to act more like an application than a full OS, and ideally would like the user to feel like they're only interacting with an application.

One virtual appliance that I use is MindTouch's open source Dekiwiki appliance (btw, I fully recommend Dekiwiki, my favorite wiki software at the moment.).

The DekiWiki appliance, upon boot, without any user interaction or required login, will display something like this:
This is extremely handy. No login to Linux necessary. Just go to any web browser on your network, and go.

How to recreate the magic in CentOS/Redhat/(probably) Fedora

I'm currently making two virtual appliances based on CentOS Linux (A clone of RedHat Enterprise Linux ). I pretty much copied DekiWiki's rc.local, to identify and print out the current IP, whatever it may be, and direct the user to browse there, without having to login. This was partially successful. But after printing the URL and instruction to the user, the console tty was cleared prior to login prompt appeared, making it so all the helpful info was removed.
Where'd my helpful message go? It was cleared by mgetty.

I had no idea why this was working fine in the Debian-based DekiWiki appliance, and less so in my CentOS-based (Piwik, coming soon!) appliance. After a bit of side-by-side comparison, I noticed that Debian's /etc/inittab calls up /sbin/getty, but CentOS (and Redhat)'s /etc/inittab calls up /sbin/mingetty. mingetty apparently clears the screen, and getty does not.

By adding the --noclear option to mingetty, CentOS will stop clearing the screen, and allow your custom boot message to live on.

Notes.

Here's what to edit in /etc/inittab:

BEFORE

# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

AFTER

# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty --noclear tty1
2:2345:respawn:/sbin/mingetty --noclear tty2
3:2345:respawn:/sbin/mingetty --noclear tty3
4:2345:respawn:/sbin/mingetty --noclear tty4
5:2345:respawn:/sbin/mingetty --noclear tty5
6:2345:respawn:/sbin/mingetty --noclear tty6


Original rc.local that finds and prints IP in helpful message (thanks Mindtouch!):

IP=`ifconfig eth0 | grep "inet addr"|awk -F ' ' '{print $2}' | awk -F ':' '{print $2}'`
echo
echo -e "\033[1mTo access Deki Wiki, please launch a web browser and go to:"
echo
echo " http://$IP"
echo -e "\033[0m"

exit 0
 




<< Home
probably a little too much

About
Linux sysadmin. I cry when make fails. And during the Oscars. Every year.
Contact
andy: andiacts [at] gmail.com
Archives
September 2005 / October 2005 / November 2005 / December 2005 / January 2006 / February 2006 / March 2006 / April 2006 / May 2006 / June 2006 / July 2006 / August 2006 / November 2006 / December 2006 / January 2007 / February 2007 / March 2007 / April 2007 / May 2007 / June 2007 / July 2007 / August 2007 / September 2007 / October 2007 / November 2007 / December 2007 / January 2008 / February 2008 / March 2008 / April 2008 / May 2008 / June 2008 / July 2008 / August 2008 / September 2008 / January 2009 / February 2009 /




Powered by Blogger

Subscribe to
Posts [Atom]