From 4ef1c14883c471f5378238ede30b07ae5d3b490c Mon Sep 17 00:00:00 2001 From: nott Date: Tue, 1 Dec 2009 18:17:15 +0000 Subject: [PATCH] Handle -M input. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4702 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT/postscripts/xcataixpost | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/xCAT/postscripts/xcataixpost b/xCAT/postscripts/xcataixpost index 6e42ebb8e..dd78749a3 100755 --- a/xCAT/postscripts/xcataixpost +++ b/xCAT/postscripts/xcataixpost @@ -57,7 +57,9 @@ unless ($useSocketSSL) { # Process the command line... # # the -c means redo the copy of scripts from the server -if (!GetOptions('copy|c' => \$::opt_c, 'm=s' => \$::opt_m)) +Getopt::Long::Configure("no_pass_through"); +$Getopt::Long::ignorecase = 0; +if (!GetOptions('copy|c' => \$::opt_c, 'm=s' => \$::opt_m, 'M=s' => \$::opt_M)) { # Gather options exit 1; } @@ -69,9 +71,8 @@ chomp $::shorthost; my $foundxcatinfo=0; my $servnode; -# create new xcatinfo file if -m value is provided -if ($::opt_m) { - +# create new xcatinfo file if -M value is provided +if ($::opt_M) { if(-f "/etc/xcatinfo") { # backup the old file - or remove ??? my $cpcmd = "cp /etc/xcatinfo /etc/xcatinfo.orig 2>/dev/null"; @@ -84,7 +85,7 @@ if ($::opt_m) { # put the new server in the file my $xcatinfo="/etc/xcatinfo"; open(XCATINFO,">",$xcatinfo); - print XCATINFO "XCATSERVER=$::opt_m\n"; + print XCATINFO "XCATSERVER=$::opt_M\n"; close(XCATINFO); } @@ -122,14 +123,24 @@ if (!$foundxcatinfo) { } } else { print "$::sdate xcataixpost: Could not find /etc/niminfo file.\n"; - print $::LOG_FILE "$::sdate xcataixpost: Could not find /etc/niminfo file.\n"; + print $::LOG_FILE "$::sdate xcataixpost: Could not find /etc/niminfo file.\n"; } } +# do ping test on server and use -m value if provides +my $pcmd = "ping -c 2 -w 2 $servnode"; +if (&runcmd($pcmd) != 0) { + $servnode = ""; + if ($::opt_m) { + chomp $::opt_m; + $servnode = $::opt_m; + } +} + unless ($servnode) { - print "$::sdate xcataixpost: Could not determine server name.\n"; + print "$::sdate xcataixpost: Could not determine server name.\n"; print $::LOG_FILE "$::sdate xcataixpost: Could not determine server name.\n"; - exit 0; + exit 0; } # if the /xcatpost dir has not been populated or the -c option is