From 3b4a7953d4859dbbe746dfeb91ed9b254c4df357 Mon Sep 17 00:00:00 2001 From: nott Date: Mon, 14 Apr 2008 12:20:34 +0000 Subject: [PATCH] Add generic postscript for xCAT diskless nodes. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1030 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT/postscripts/xcatdsklspost | 81 ++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 xCAT/postscripts/xcatdsklspost diff --git a/xCAT/postscripts/xcatdsklspost b/xCAT/postscripts/xcatdsklspost new file mode 100644 index 000000000..675dc09ce --- /dev/null +++ b/xCAT/postscripts/xcatdsklspost @@ -0,0 +1,81 @@ +#!/usr/bin/env perl +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html +##################################################### +# +# Generic xCAT post script for diskless nodes +# +##################################################### + +# get hostname +my $shorthost = `hostname -s`; +chomp $shorthost; + +# get platform +my $osname = `uname`; +chomp $osname; + +# get the postscript tar file from the server and unwrap it +if ($osname eq "Linux") { + getLinuxpostfile(); +} else { + # TBD +# getAIXpostfile(); +} + +# check & run the postscript +my $scriptname = "/xcatpost/".$shorthost; +if (-f $scriptname) +{ + my $rc = system("$scriptname"); + if ($rc >> 8) + { + print "Could not run $scriptname.\n"; + } +} else { + print "Could not find post script for $shorthost.\n"; +} + +exit 0; + +##################################################### +# +# getLinuxpostfile +# Get the linux post scripts from the server +# +##################################################### +sub getLinuxpostfile { + + # look in the dhcp leases file for the name of the server + my $dhclientfile="/var/lib/dhclient/dhclient-eth0.leases"; + + my @lines; + if (open(DHCLIENT, "<$dhclientfile")) { + @lines = ; + close(DHCLIENT); + } else { + print "Could not open $dhclientfile.\n"; + return 1; + } + + my $ip; # IP of server + foreach my $l (@lines) + { + if ($l =~ /dhcp-server-identifier/) { + my ($junk, $junk2, $s) = split(" ", $l); + ($ip, $junk) = split("\;", $s); +# print "ip = $ip\n"; + } + } + + # get postscripts tar file from the server + my $getcmd = "mkdir -p /xcatpost; cd /xcatpost; wget --wait=10 --random-wait --waitretry=10 --retry-connrefused -t 0 -T 60 http://$ip/install/autoinst/xcatpost.tar.gz; gunzip xcatpost.tar.gz; tar -xvf xcatpost.tar"; + +#print "getcmd= $getcmd\n"; + + my $rc = system("$getcmd"); + if ($rc >> 8) + { + print "Could not get xcatpost.tar.bz2.\n"; + } + +}