From e15f58b00ab5bc1cf16b4ef96ba0775adf0a4385 Mon Sep 17 00:00:00 2001
From: lissav <lissav@8638fb3e-16cb-4fca-ae20-7b5d299a9bcd>
Date: Fri, 23 Mar 2012 15:07:22 +0000
Subject: [PATCH]  Do not add otherpkgs for AIX defect 3508761

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11969 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
---
 xCAT-server/sbin/xcatconfig | 106 ++++++++++++++++--------------------
 1 file changed, 48 insertions(+), 58 deletions(-)

diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig
index faca4c407..0898da856 100755
--- a/xCAT-server/sbin/xcatconfig
+++ b/xCAT-server/sbin/xcatconfig
@@ -1066,70 +1066,56 @@ sub initDB
 
     # create default postscript list in postscripts table
     # if it does not exist, or request reset
-    # If otherpkgs does not exist, then put otherpkgs
-    # in the postbootscripts attribute
-    # else leave it where it is
 
     if (   ((!-r "/etc/xcat/postscripts.sqlite") && (!-r "/etc/xcat/cfgloc"))
         || $::FORCE
         || $::initDB)
     {
 
-        # check to see if otherpkgs in the postscripts table
+        # For Linux check to see if otherpkgs in the postscripts table
         # if it is do not change it, otherwise put in postbootscripts
-        #  0 = does not exist
-        #  1 = exists in postscripts
-        #  2 = exists in postbootscripts
-        my $otherpkgsexist     = &checkotherpkgs;
-        my $otherpkgsprocessed = 0;
-
         my $chtabcmds = "";
-
-        # if otherpkgs does not exist or we are initializing the DB
-        # put in postbootscripts
-        if (($otherpkgsexist == 0) || ($::initDB))
-        {
+        my $otherpkgsprocessed = 0;
+        my $otherpkgsexist;
+        if ($::osname eq 'Linux') {
+           $otherpkgsexist     = &checkotherpkgs;
+           #  0 = does not exist
+           #  1 = exists in postscripts
+           #  2 = exists in postbootscripts
+ 
+           # if otherpkgs does not exist or we are initializing the DB
+           # put in postbootscripts 
+           if (($otherpkgsexist == 0) || ($::initDB))
+           {
             $chtabcmds =
               "$::XCATROOT/sbin/chtab node=xcatdefaults postscripts.postbootscripts='otherpkgs';";
             $otherpkgsprocessed = 1;
-
-        }
-        if ($::osname eq 'AIX')
-        {
-
-            # if already processed otherpkgs or it is in postbootscripts
-            # don't put in postscripts, else put in postscripts
-            if (($otherpkgsprocessed == 1) || ($otherpkgsexist == 2))
-            {
-                $chtabcmds .=
-                  "$::XCATROOT/sbin/chtab node=xcatdefaults postscripts.postscripts='syslog,aixremoteshell,syncfiles';";
-            }
-            else
-            {    #  put otherpkgs in postscripts
-                $chtabcmds .=
-                  "$::XCATROOT/sbin/chtab node=xcatdefaults postscripts.postscripts='syslog,aixremoteshell,otherpkgs,syncfiles';";
-            }
-            $chtabcmds .=
-               "$::XCATROOT/sbin/chtab node=service postscripts.postscripts='' postscripts.postbootscripts='servicenode'";
-
-        }
-        else     # linux
-        {
-
-            # if already processed otherpkgs or it is in postbootscripts
-            # don't put in postscripts, else put in postscripts
-            if (($otherpkgsprocessed == 1) || ($otherpkgsexist == 2))
-            {
+           }
+           # if already processed otherpkgs or it is in postbootscripts attr
+           # then don't put otherpkgs in the postscripts attribute
+           # else it was in postscripts attribute so leave it there.
+           if (($otherpkgsprocessed == 1) || ($otherpkgsexist == 2))
+           {
                 $chtabcmds .=
                   "$::XCATROOT/sbin/chtab node=xcatdefaults postscripts.postscripts='syslog,remoteshell,syncfiles';";
-            }
-            else
-            {    # put otherpkgs in postscripts attr
+           }
+           else
+           {    # put otherpkgs in postscripts attr
                 $chtabcmds .=
                   "$::XCATROOT/sbin/chtab node=xcatdefaults postscripts.postscripts='syslog,remoteshell,otherpkgs,syncfiles';";
-            }
-            $chtabcmds .=
+           }
+           # add servicenode default
+           $chtabcmds .=
                "$::XCATROOT/sbin/chtab node=service postscripts.postscripts='servicenode'";
+
+        } 
+        if ($::osname eq 'AIX') {  # we don't use otherpkgs on AIX
+
+           $chtabcmds .=
+                  "$::XCATROOT/sbin/chtab node=xcatdefaults postscripts.postscripts='syslog,aixremoteshell,syncfiles';";
+           $chtabcmds .=
+               "$::XCATROOT/sbin/chtab node=service postscripts.postscripts='' postscripts.postbootscripts='servicenode'";
+
         }
 
         my $outref = xCAT::Utils->runcmd("$chtabcmds", 0);
@@ -1206,7 +1192,6 @@ sub initDB
     }
 
     # update install processing
-    # adding otherpkgs and syncfiles new postscripts for migration
     if ($::UPDATEINSTALL)
     {
         # setup Management Node policy to trusted
@@ -1242,22 +1227,27 @@ sub initDB
           }
         }
 
-        # check to see if otherpkgs is in the postscripts table
+        # For Linux check to see if otherpkgs is in the postscripts table
         # if it is do not change it, otherwise put in postbootscripts
         #  0 = does not exist
         #  1 = exists in postscripts
         #  2 = exists in postbootscripts
-        my $otherpkgsexist = &checkotherpkgs;
+        my $otherpkgsexist;
         $chtabcmds ="";
-        if (($otherpkgsexist == 1) || ($otherpkgsexist == 2)) {
+        if ($::osname eq 'Linux') {
+           $otherpkgsexist = &checkotherpkgs;
+           if (($otherpkgsexist == 1) || ($otherpkgsexist == 2)) {
             # otherpkgs already in postscripts or in postbootscripts
+            # just add syncfiles
+            $chtabcmds = "$::XCATROOT/sbin/chtab node=xcatdefaults postscripts.postscripts+='syncfiles'";
+           }
+           else
+           {   #  otherpkgs does not exist
+               #  put in postbootscripts
+               $chtabcmds = "$::XCATROOT/sbin/chtab node=xcatdefaults postscripts.postbootscripts+='otherpkgs';";
+          }
+        } else { # AIX ,  no otherpkgs just add syncfiles
             $chtabcmds = "$::XCATROOT/sbin/chtab node=xcatdefaults postscripts.postscripts+='syncfiles'";
-        }
-        else
-        {   # else otherpkgs does not exist
-            #  put in postbootscripts
-            $chtabcmds = "$::XCATROOT/sbin/chtab node=xcatdefaults postscripts.postbootscripts+='otherpkgs';";
-            $chtabcmds .= "$::XCATROOT/sbin/chtab node=xcatdefaults postscripts.postscripts+='syncfiles'";
         }
 
         if ($chtabcmds ne "") {