From 4447cb13948c0a891931c7ca7d6e1d8f292b8cf2 Mon Sep 17 00:00:00 2001 From: lissav Date: Fri, 20 Nov 2009 16:33:44 +0000 Subject: [PATCH] cleanup interface git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4629 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-client/bin/genimage | 61 ++++++++++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 12 deletions(-) diff --git a/xCAT-client/bin/genimage b/xCAT-client/bin/genimage index 9940829a9..a2d4ed509 100755 --- a/xCAT-client/bin/genimage +++ b/xCAT-client/bin/genimage @@ -1,8 +1,20 @@ #!/usr/bin/perl +BEGIN +{ + $::XCATROOT = + $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} + : -d '/opt/xcat' ? '/opt/xcat' + : '/usr'; +} +use lib "$::XCATROOT/lib/perl"; use strict; + +use Getopt::Long; +require xCAT::MsgUtils; +require xCAT::DSHCLI; +use xCAT::Utils; use Term::ANSIColor; use File::Basename; -use Getopt::Long; # genimage is a wrapper to the genimages located in # /opt/xcat/share/xcat/netboot// # put tab completion @@ -12,6 +24,7 @@ $::XCATROOT = "/opt/xcat"; my $os = ""; my $profile = ""; my $interface = ""; +my $version; my $drivers = ""; my $otherInterfaces = ""; my $kernel = ""; @@ -21,26 +34,50 @@ my $profDir; # root where you do ./genimage from my $help; my $match = 0; -GetOptions( +#----------------------------------------------------------------------------- + +=head3 print_usage - usage message + +=cut + +#----------------------------------------------------------------------------- +sub print_usage +{ + print "Usage: genimage -h\n"; + print " genimage -v\n"; + print " genimage [-i ] [-n ] [-r ]\n [-o ] [-p ] [-k ]\n"; + print "Examples:\n"; + print " genimage -i eth0 -n igb,e1000e,bnx2 -o centos5.4 -p compute\n"; + print " genimage -o suse11\n"; + print " genimage\n"; + return; +} +if (!GetOptions( 'o=s' => \$os, 'i=s' => \$interface, 'p=s' => \$profile, 'n=s' => \$drivers, 'k=s' => \$kernel, 'r=s' => \$otherInterfaces, - 'h|help' => \$help -); - -if($help){ - print 'genimage is a shell for the genimage located in /opt/xcat/share/xcat/netboot//\n'; - print 'Usage: genimage [-i ] [-n ] [-r ] [-o ] [-p ] [-k ]'."\n"; - print "Examples:\n"; - print " genimage -i eth0 -n igb,e1000e,bnx2 -o centos5.4 -p compute\n"; - print " genimage -o suse11\n"; - print " genimage\n"; + 'h|help' => \$help, + 'v|version' => \$version +)) { + &print_usage; exit 1; } +if($help){ + print "genimage is a shell for the genimage located in /opt/xcat/share/xcat/netboot/.\n"; + &print_usage; + exit 0; +} + +if ($version){ + my $version = xCAT::Utils->Version(); + xCAT::MsgUtils->message("N", $version); + exit 0; + +} unless($os){ # get the install directory my $installdir = `gettab key=installdir site.value`;