From aef592b6293ecdfb431edb38842fd316ae0b6374 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Fri, 5 Jun 2009 13:53:52 +0000 Subject: [PATCH] convert the syncfiles postscript to the bourne shell syntax git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3523 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT/postscripts/startsyncfiles.aix | 40 +++++++++++++++ xCAT/postscripts/syncfiles | 79 ++++++++--------------------- 2 files changed, 61 insertions(+), 58 deletions(-) create mode 100644 xCAT/postscripts/startsyncfiles.aix diff --git a/xCAT/postscripts/startsyncfiles.aix b/xCAT/postscripts/startsyncfiles.aix new file mode 100644 index 000000000..dc18761af --- /dev/null +++ b/xCAT/postscripts/startsyncfiles.aix @@ -0,0 +1,40 @@ +#!/usr/bin/env perl -w +# IBM(c) 2009 EPL license http://www.eclipse.org/legal/epl-v10.html +##################################################### +# +# xCAT post script for AIX nodes +# This script will send command "syncfiles" to the xcatd on +# management node or service node to initiate the sync file +# operation by xdcp command +# +##################################################### + + +use IO::Socket; + +my $port = "3002"; +my $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $ENV{MASTER}, PeerPort => $port, ); +unless ($remote) { + `logger -t xCAT "startsyncfiles: Cannot connect to host $ENV{MASTER}"`; + exit 0; +} + +$remote->autoflush(1); + +while (defined (my $line = <$remote>)) { + chomp($line); + + if ($line =~ /ready/) { + print $remote "syncfiles\n"; + } + + if ($line =~ /syncfiles done/) { + close $remote; + exit 1; + } +} + +close $remote; + +exit 1; + diff --git a/xCAT/postscripts/syncfiles b/xCAT/postscripts/syncfiles index 234e0a0f6..268c9764a 100644 --- a/xCAT/postscripts/syncfiles +++ b/xCAT/postscripts/syncfiles @@ -1,69 +1,32 @@ -#!/usr/bin/perl -# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html +#!/bin/sh +# IBM(c) 2009 EPL license http://www.eclipse.org/legal/epl-v10.html ##################################################### # -# xCAT post script for configuration files distribution -# -# It should be run after the remoteshell -# It is also run by the updatenode cmd +# Initiate the xdcp from Mangement node to sync +# files to this node # ##################################################### - # do nothing when UPDATENODE=1 -if ($ENV{'UPDATENODE'} == 1 - || $ENV{'NODESETSTATE'} eq "netboot" - || $ENV{'NODESETSTATE'} eq "diskless") { - exit 0; -} +if [ $UPDATENODE = 1 -o \ + $NODESETSTATE = "netboot" -o \ + $NODESETSTATE = "diskless" ] +then + exit 0 +fi -`logger -t xCAT "Performing syncfiles postscript"`; - -# get platform -my $osname = `uname`; -chomp $osname; +logger -t xCAT "Performing syncfiles postscript" +osname=`uname` # run the xdcp on the MN/SN -my $xcatpostdir = "/xcatpost"; -my $startsync = ""; -if ($osname eq "Linux") { -`logger -t xCAT "run $xcatpostdir/startsyncfiles.awk"`; - $startsync = "$xcatpostdir/startsyncfiles.awk"; - `$startsync`; -} else { -`logger -t xCAT "run $xcatpostdir/startsyncfilesaix.awk"`; - &startsyncfilesaix(); -} +xcatpostdir="/xcatpost" -exit 0; +if [ $osname="Linux" ] +then + `$xcatpostdir/startsyncfiles.awk` +elif [ $osname="AIX" ] +then + `$xcatpostdir/startsyncfiles.aix` +fi - -sub startsyncfilesaix -{ - use IO::Socket; - - my $port = "3002"; - my $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $ENV{'MASTER'}, PeerPort => $port, ); - unless ($remote) { - `logger -t xCAT "startsyncfiles: Cannot connect to host $ENV{'MASTER'}"`; - } - - $remote->autoflush(1); - - while (<$remote>) { - my $line = $_; - chomp($line); - - if ($line =~ /ready/) { - print $remote "syncfiles\n"; - } - - if ($line =~ /syncfiles done/) { - close $remote; - return 0; - } - } - - close $remote; - return 0; -} +exit 0