diff --git a/perl-xCAT/xCAT/Postage.pm b/perl-xCAT/xCAT/Postage.pm index a4299c0e1..51ff3d068 100644 --- a/perl-xCAT/xCAT/Postage.pm +++ b/perl-xCAT/xCAT/Postage.pm @@ -247,7 +247,12 @@ sub makescript { if ( @otherpkgs > 0) { push @scriptd, "OTHERPKGS=". join(',',@otherpkgs) . " \n"; push @scriptd, "export OTHERPKGS\n"; - } + + if (-r "/install/post/otherpkgs/$os/$arch/repodata/repomd.xml") { + push @scriptd, "OTHERPKGS_HASREPO=1\n"; + push @scriptd, "export OTHERPKGS_HASREPO\n"; + } + } } } @@ -260,7 +265,8 @@ sub makescript { my $defscripts = $et->{'postscripts'}; if ($defscripts) { foreach my $n (split(/,/, $defscripts)) { - if (($n eq "otherpkgs") && ($stat eq "netboot")) { next; } #skip 'otherpkgs' for diskless case + #skip 'otherpkgs' for diskless case because it is handled by genimage + if (($n eq "otherpkgs") && ($stat eq "netboot")) { next; } push @scriptd, $n."\n"; } } @@ -270,7 +276,8 @@ sub makescript { $ps = $et->{'postscripts'}; if ($ps) { foreach my $n (split(/,/, $ps)) { - if (($n eq "otherpkgs") && ($stat eq "netboot")) { next; } #skip 'otherpkgs' for diskless case + #skip 'otherpkgs' for diskless case because it is handled by genimage + if (($n eq "otherpkgs") && ($stat eq "netboot")) { next; } push @scriptd, $n."\n"; } } diff --git a/xCAT-server/lib/xcat/plugins/updatenode.pm b/xCAT-server/lib/xcat/plugins/updatenode.pm index a46416f9a..f2894ca77 100644 --- a/xCAT-server/lib/xcat/plugins/updatenode.pm +++ b/xCAT-server/lib/xcat/plugins/updatenode.pm @@ -125,8 +125,8 @@ sub preprocess_updatenode { my $cb=shift; my $rsp={}; $rsp->{data}->[0]= "Usage:"; - $rsp->{data}->[1]= " updaenode [posts]"; - $rsp->{data}->[2]= " updaenode [-h|--help|-v|--version]"; + $rsp->{data}->[1]= " updatenode [posts]"; + $rsp->{data}->[2]= " updatenode [-h|--help|-v|--version]"; $rsp->{data}->[3]= " noderange is a list of nodes or groups."; $rsp->{data}->[4]= " posts is a comma separated list of postscript names."; $rsp->{data}->[5]= " if omitted, all the postscripts will be run."; @@ -231,7 +231,13 @@ sub updatenode { print "postscripts=$postscripts, nodestring=$nodestring\n"; if ($nodestring) { - my $output=`XCATBYPASS=Y $::XCATROOT/bin/xdsh $nodestring -e /install/postscripts/xcatdsklspost $postscripts`; + my $output; + if (xCAT::Utils->isLinux()) { + $output=`XCATBYPASS=Y $::XCATROOT/bin/xdsh $nodestring -e /install/postscripts/xcatdsklspost $postscripts 2>&1`; + } + else { + $output=`XCATBYPASS=Y $::XCATROOT/bin/xdsh $nodestring -e /install/postscripts/xcataixpost $postscripts 2>&1`; + } my $rsp={}; $rsp->{data}->[0]= "$output\n"; $callback->($rsp); diff --git a/xCAT/postscripts/otherpkgs b/xCAT/postscripts/otherpkgs index 27412b117..7fcbae01c 100755 --- a/xCAT/postscripts/otherpkgs +++ b/xCAT/postscripts/otherpkgs @@ -28,26 +28,127 @@ if [[ -z "$OTHERPKGS" ]]; then exit 0 fi -SIP=`grep -h dhcp-server-identifier /var/lib/dhclient/dhclient-*.leases|tail -n 1|awk '{print $3}'|sed -e 's/;//'` -if [ -z "$SIP" ]; then +if [[ $OSTYPE = linux* ]]; then + #find out the server + SIP=`grep -h dhcp-server-identifier /var/lib/dhclient/dhclient-*.leases|tail -n 1|awk '{print $3}'|sed -e 's/;//'` + if [ -z "$SIP" ]; then SIP=`grep -h DHCPSID /var/lib/dhcpcd/*.info|awk -F= '{print $2}'|tail -n 1` + fi + + if [[ $OTHERPKGS_HASREPO -eq 1 ]]; then + rpm -q yum + if [ $? -eq 0 ]; then + #use yum + REPOFILE="/tmp/xCAT-otherpkgs.repo" + echo "[xcat-otherpkgs]" > $REPOFILE + echo "name=xcat-otherpkgs" >> $REPOFILE + echo "baseurl=ftp://$SIP/post/otherpkgs/$OSVER/$ARCH" >> $REPOFILE + echo "enabled=1" >> $REPOFILE + echo "gpgcheck=0" >> $REPOFILE + #clean meta data to make possible for update + yum -c $REPOFILE clean metadata + + INSTALLPKGS="" + UPDATEPKGS="" + #check if the packges are installed already + for x in `echo "$OTHERPKGS" | tr "," "\n"` + do + rpm -q $x + if [ $? -eq 0 ]; then + UPDATEPKGS="$UPDATEPKGS $x" + else + INSTALLPKGS="$INSTALLPKGS $x" + fi + done + + #update packages + if [[ ! -z $UPDATEPKGS ]]; then + echo "yum -c $REPOFILE -y update $UPDATEPKGS" + result=`yum -c $REPOFILE -y update $UPDATEPKGS 2>&1` + if [ $? -ne 0 ]; then + echo "$result" + logger "otherpkgs: $result" + fi + exit 0 + fi + + #install packages + if [[ ! -z $INSTALLPKGS ]]; then + echo "yum -c $REPOFILE -y install $INSTALLPKGS" + result=`yum -c $REPOFILE -y install $INSTALLPKGS 2>&1` + if [ $? -ne 0 ]; then + echo "$result" + logger "otherpkgs: $result" + fi + exit 0 + fi + fi + + + #try zypper --- TODO: get a SLES cluster and test + #rpm -q zypper + #if [ $? -eq 0 ]; then + #use zypper + #zypper sa ftp://$SIP/post/otherpkgs/$OSVER/$ARCH/1 + + #install + #PKGS=`echo "$OTHERPKGS" | tr "," " "` + #zypper install -y $PKGS + #exit 0 + #fi + fi + + #if it is not handled by the above code, we will use wget to handle it + mkdir -p /xcatpost/post/otherpkgs/$OSVER/$ARCH; + rm -f -R /xcatpost/post/otherpkgs/* + mkdir -p /tmp/postage/ + rm -f -R /tmp/postage/* + cd /tmp/postage + + for x in `echo "$OTHERPKGS" | tr "," "\n"` + do + wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 0 -T 60 ftp://$SIP/post/otherpkgs/$OSVER/$ARCH/$x-* 2> /tmp/wget.log + done + + mv $SIP/post/otherpkgs/* /xcatpost/post/otherpkgs; + rm -rf $SIP + + cd /xcatpost/post/otherpkgs/$OSVER/$ARCH + result=`rpm -Uvh * 2>&1` + echo "$result" + if [ $? -ne 0 ]; then + logger "otherpkgs $result" + fi + exit 0 +else #AIX + mkdir -p /xcatpost/post/otherpkgs/$OSVER/$ARCH + rm -f -R /xcatpost/post/otherpkgs/$OSVER/$ARCH/* + + # get the name of my service node/NIM master from the /etc/niminfo file + if [ -f "/etc/niminfo" ]; then + servnode=`grep NIM_MASTER_HOSTNAME /etc/niminfo|tr "=" " "|awk {'print $3'}` + echo "servnode=$servnode" + else + echo "Could not find /etc/niminfo file" + logger "otherpkgs: Could not find /etc/niminfo file" + exit 1 + fi + + for x in `echo "$OTHERPKGS" | tr "," "\n"` + do + result=`rcp -r $servnode:/install/post/otherpkgs/$OSVER/$ARCH/$x* /xcatpost/post/otherpkgs/$OSVER/$ARCH/.` + if [ $? -ne 0 ]; then + echo "$result" + logger "otherpkgs: $result" + fi + done + + #on AIX use geninstall + PKGS=`echo "$OTHERPKGS" | tr "," " "` + cd /xcatpost/post/otherpkgs/$OSVER/$ARCH + geninstall -I aX -Y -d /xcatpost/post/otherpkgs/$OSVER/$ARCH $PKGS + exit 1 fi -mkdir -p /xcatpost/post/otherpkgs; -mkdir -p /tmp/postage/ -rm -f -R /xcatpost/post/otherpkgs/* -rm -f -R /tmp/postage/* -cd /tmp/postage - -for x in `echo "$OTHERPKGS" | tr "," "\n"` -do - wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 0 -T 60 ftp://$SIP/post/otherpkgs/$OSVER/$ARCH/$x-* 2> /tmp/wget.log -done - -mv $SIP/post/otherpkgs/* /xcatpost/post/otherpkgs; -rm -rf $SIP - -cd /xcatpost/post/otherpkgs/$OSVER/$ARCH -rpm -Uvh * exit 0 diff --git a/xCAT/postscripts/xcataixpost b/xCAT/postscripts/xcataixpost index 986540815..21e9e8d84 100644 --- a/xCAT/postscripts/xcataixpost +++ b/xCAT/postscripts/xcataixpost @@ -86,7 +86,18 @@ if (&runcmd($chcmd) != 0) { # check & run the postscript if (-f $scriptname) { - if (&runcmd($scriptname) != 0) + if (@ARGV>0) { + my $scripts=$ARGV[0]; + my $POSTS=join('\n', split(',', $scripts)); + #print "scripts=$scripts\n"; + #remove all the postscripts + my $TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" $scriptname`; + `echo "$TMP" > $scriptname`; + #add requested postscripts in + `echo "$POSTS" | tr "," "\n" >> $scriptname`; + } + + if (&runcmd($scriptname) != 0) { print "$::sdate xcataixpost: Could not run $scriptname.\n"; print $::LOG_FILE "$::sdate xcataixpost: Could not run $scriptname.\n";