Building a Linux-Based Appliance

For both ease of development and cost-effectiveness, Linux offers a perfect platform for building a robust, standalone appliance.
Designing the User Interface (Wizard)

It seems to us that user interface design and construction is always harder than it appears. As soon as you get more than three or four basic options on the screen, you have to figure out how to organize them in a way that really works and makes sense to the user.

We have found that many Linux tools do not make use of a commonly available but often overlooked capability: color. The use of colors is important to help differentiate the information you are trying to convey to the user. In a terminal window, use of only a few ASCII color codes can mean the difference between lots of hard-to-read text and an easy-to-use menu system.

Rather than trying to use the ASCII color codes each time you want to change your output colors, it is easier to assign common color selections to variables in your scripts. This will save time and makes colors much easier to work with. Here is an example:

my $white = "\033[97m";
my $nocolor = "\033[0m\033[39m\033[49m";

To output a line with multiple colors, you would simply print out the corresponding variable to create a simple menu:

print "$white 1: $nocolor Menu Item 1\n";
print "$white 2: $nocolor Menu Item 2\n\n";     
print "Please choose a valid menu item from above
($white 1/2/C $nocolor ancle):";

The result appears as follows:

1: Menu Item 1
2: Menu Item 2
Please choose a valid menu item from above

In another part of our product, the user must choose from a list with over 200 options. To address this issue of multiple options in a terminal-based environment, we came up with the idea of matching on a part of the word to search for. Although we do allow the user to display the entire list, enabling a partial string search made it significantly easier to locate desired services. The following code demonstrates searching for text in an array within Perl to support this functionality.

The @printobjectoutput file contains the entire list of services available. For each element in the array, we strip out all unnecessary characters and display modifiers (such as tabs) and compare that to the search string entered by the user. We then display the list of matching services for the user to select and include in the rule they want to add. We identify each service with a number to make item selection easy.

print "What would you like to search for?: ";
chomp($match = <STDIN>);
print "\n";
                foreach $element (@printobjectoutput) {
                        $element =~ s/^\s+|\s+$//g;
                        if ($element =~ /$match/)   # returns true if
$match is in $element
                        print "$white $printobjectcounter";
                        print "$nocolor  $element\n";                               
print "\nWhich service do you wish to apply to the
rule?: ";                       
chomp($pickedservice = <STDIN>);

Here is some sample output generated by the code above:

What would you like to search for?: timestamp
 229    timestamp
 230    timestamp-reply
Which service do you wish to apply to the rule?: 230

Our product supports three types of backup/restore/undo capabilities:

  1. Full backup and restore via disk imaging

  2. Manual/scheduled backup of critical system and firewall configuration files

  3. An iterative undo capability

As you may recall, a unique aspect of our hardware platform is it includes two complete systems in a single box. We utilized PartitionImage because it allowed us to make an exact copy of the first machine in this two-machine box. We were then able to create an image file that could be heavily compressed and stored on the second machine. Even if there is a total failure of one of the machines, the user doesn't need to have a boot disk, CD and so on. Instead, they can simply boot up the other machine and get the whole system back up and running. We also support a Restore CD for a worst-case scenario, although this tends to be confusing to the end user. Both the hard disk-based restore and the bootable Restore CD make use of PartitionImage.

To use PartitionImage, we booted from a Linux boot disk that loads the necessary drivers and other utilities necessary to access the drive you want to make an image of. It also can load your network drivers if you want to store the image across the network, which was one of the benefits of the tool. You can then choose to make an image of the drive on any other partition of that machine or across a remote networked filesystem (e.g., to another machine or storage device). PartitionImage makes an exact copy of the disk, sector by sector; it doesn't simple copy the files. PartitionImage has floppy disk images available on their web site that make it easy to create the boot disk.

Using PartitionImage also was critical during the development phase of the product. In some cases, we would make so many configuration changes to the system, it would be unclear whether we had really gotten back to the original state. And there was no way to get back to the original setup and know for sure that it was a "clean" version.

The key was to create an image once we had installed the operating system to the state that we wanted, plus the application software, and performed the initial configuration. Otherwise, if we had had to reload the OS from scratch, install the application, then load any patches or updates, it would have been hours versus minutes. Your development time is also much better spent, because you can hit restore, go work on something else and come back when it is done.

Restoring is as easy as backing up. You can restore either from the local hard disk's other partition (the one you saved the partition to) or from the remote machine.

In summary, PartitionImage is easy to use. It's an open-source tool that is constantly being updated and that is well supported, and it's available free-of-charge. It was a complete and supported tool that met our needs and withstood our testing.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Ruby on Rails Appliance

MichaelByrd's picture

Great info! Myself and a coworker recently built a remote backup appliance using a standard linux distro and ruby on rails. We've thought about turning it into a kit complete with source code to help give others a springboard to develop from. Any interest out there for something like this?