com.ibm.jsdt.support.deploymenthelper
Class LinuxDeploymentHelper

java.lang.Object
  extended by com.ibm.jsdt.common.Base
      extended by com.ibm.jsdt.support.deploymenthelper.DeploymentHelper
          extended by com.ibm.jsdt.support.deploymenthelper.LinuxDeploymentHelper

public class LinuxDeploymentHelper
extends DeploymentHelper

Linux specific helper functionality.


Field Summary
protected static java.lang.String filePath
          File that indicates the current version of the Linux OS.
protected static java.lang.String searchString
          String that represents the version of Linux on the target computer.
static java.lang.String sNEWLN
          System-independent line separator.
protected static int startIndex
          Index where the file start to search.
 
Fields inherited from class com.ibm.jsdt.support.deploymenthelper.DeploymentHelper
DEPLOYER_SPECIFICATION_VERSION_KEY, ENTRY_STAGE, EXIT_STAGE, FAILURE, ISMP_GLOBAL_PROPERTY, ISMP_PRODUCT_PROPERTY, ISMP_WIZARD_PROPERTY, MAIN_STAGE, PDC_CANCEL_INSTALL, PDC_DO_NOT_INSTALL, PDC_DOES_NOT_EXIST, PDC_EXISTS, resourceBundle, SELECTED_TASK_NAMES_KEY, SUCCESS, VERSIONCHECKER_STAGE, VPD_INSTALL_LOCATION_PIPE, VPD_VERSION_PIPE
 
Fields inherited from class com.ibm.jsdt.common.Base
NEW_LINE, OS_NAME, SLASH
 
Constructor Summary
LinuxDeploymentHelper()
          Sole constructor.
 
Method Summary
static boolean addUserToGroup(java.lang.String groupName, java.lang.String userName)
          Adds a user to a group.
static void chmodDirPermissions(java.lang.String path, java.lang.String chmodValue)
          Changes the permissions on a folder.
static void chmodFilePermissions(java.lang.String fileName, java.lang.String chmodValue)
          Changes the permissions on a file.
static boolean createGroup(java.lang.String groupName)
          Creates a new user ID group.
static boolean createLinuxUser(java.lang.String userName, java.lang.String password)
          Creates a new user ID using the Linux system's native password hashing/encryption algorithm and creates the /home/ directory.
static boolean createUser(java.lang.String userName, java.lang.String password, java.lang.String groupName)
          Creates a new user ID and assign it to the group.
static boolean doesGroupExist(java.lang.String groupName)
          Verifies the existence of a user group.
static boolean doesUserExist(java.lang.String userName)
          Verifies the existence of a user ID.
static int doUserAdd(java.lang.String compareVersion, java.lang.String userName, java.lang.String password)
          Deprecated. Use createLinuxUser instead

Example command: useradd -m -d /home/db2inst2 -p encPwd db2inst2

This method can only be called with local deployments or on remote computers running IBM Installation Agents with a specification version of 2.1.1.0 or later. If a down-level agent is encountered, a value of Integer.MIN_VALUE (-2147483648) is returned.

static java.lang.String getDeviceNameFromMountPoint(java.lang.String path)
          Gets the device name, given a mount point on Linux.
static int isAllRPMsInstalled(java.lang.Object[] RPMArray)
          Inclusively checks for a set of RPMs.
static int isAnyRPMsInstalled(java.lang.Object[] RPMArray)
          Noninclusively checks for a set of RPMs.
static boolean isIntelBasedLinux()
          Indicates whether the current architecture is Intel-based Linux.
static boolean isPowerLinux()
          Indicates whether the current architecture is Linux on POWER.
static boolean isRHEL4()
          Determines if the target computer is running Red Hat Enterprise Linux release 4.
static boolean isRHEL5()
          Determines if the target computer is running Red Hat Enterprise Linux release 5.
static boolean isRootUser()
          Verify that current user is the root user.
static boolean isRpmInstalled(java.lang.String rpmPackage)
          Checks to see if a specific RPM package is installed.
static boolean isSLES10()
          Determines if the target computer is running SUSE Linux Enterprise Server 10
static boolean isSLES9()
          Determines if the target computer is running SUSE Linux Enterprise Server 9
static boolean isUserAndPasswordValid(java.lang.String userName, java.lang.String password)
          Verifies that the given user and password are valid.
static boolean isZ_Linux()
          Indicates whether or not this is a zLinux platform.
static boolean isZ_Linux32()
          Indicates whether or not this is a zLinux 32 bit platform.
static boolean isZ_Linux64()
          Indicates whether or not this is a zLinux 64 bit platform.
static int runCommandAsUser(java.lang.String userId, java.lang.String password, java.lang.String command)
          Runs the command on the local computer as the specified user.
static int runCommandAsUser(java.lang.String userId, java.lang.String password, java.lang.String command, boolean shouldLogOutput)
          Runs the command on the local computer as the specified user.
 
Methods inherited from class com.ibm.jsdt.support.deploymenthelper.DeploymentHelper
arraySearch, checkFreeSpaceAvailable, checkTargetDirectory, compareVersions, copyAndRenameFile, copyDirectory, copyFile, deleteFile, determineLogFileName, directorySearch, endOfFileScan, executeCommand, fileExists, fileGrep, fileLength, fileScan, fileSearchAndReplace, fileSearchAndReplaceLine, fileSearchAndReturnLinesWithSearch, getAgentRelease, getBackLevelDeployerMessage, getBackLevelJsdtMessage, getDeployerLocale, getDeploymentPackageJarName, getDeploymentWizardSpecificationVersion, getDomain, getEntryResponseFilePath, getEntryResponseFilePath, getExitResponseFilePath, getExitResponseFilePath, getGroupLocale, getHostName, getIbmNsiISMPPropValue, getIbmNsiProperties, getIbmnsiPropertyKeyPrefix, getIbmNsiPropValue, getIbmNsiPropValueByKey, getIimInstallLocationArray, getIimVersionArray, getKeyValue, getLogFileName, getLogger, getLogsDir, getMainResponseFilePath, getMainResponseFilePath, getOSType, getPartitionCapacity, getPartitionFileSystemType, getPartitionVolumeLabel, getPasswordValue, getPasswordValueByKey, getPreDeploymentCheckerResponseFilePath, getPreDeploymentCheckerResponseFilePath, getProductInstallingBundleProperties, getProductInstallingId, getProductInstallingVersion, getPropertyLogFileName, getQualifiedHostName, getQualifiedTiedPasswordValue, getQualifiedTiedVariableValue, getResourceString, getResponseFilePath, getResponseFilePath, getResponseFileProperties, getResponseFileProperty, getResponseFileValue, getSelectedTaskList, getSetupFileRemovalSetting, getStringFromCommandArray, getSystemEnvVar, getTaskApplicationList, getTaskHostnameList, getTempDir, getTiedPasswordValue, getTiedPasswordValueForKey, getTiedVariableValue, getTiedVariableValueForKey, getTranslatedMessage, getUnpackedDir, getVariableValueForTaskApplication, getVpdInstallLocationArray, getVpdPropertyList, getVpdVersionArray, isAix, isAixOSType, isApplicationVersionEqual, isEnoughTargetDirSpaceAvailable, isHPUX, isHPUXOSType, isIpv6Address, isLinux, isLinuxOSType, isLinuxX86_32, isLinuxX86_64, isOS400, isOS400OSType, isPortOpen, isPortRegistered, isPowerLinuxOSType, isSameDirectoryName, isSunOS, isSunOSType, isVersionSupported, isWindows, isWindowsOSType, log, log, logAppendFile, logAppendFile, logNewLine, logStatus, modifyResponseFile, postCompletionMessageToDeployerUI, postErrorMessageToDeployerMainUI, postErrorMessageToDeployerUI, postInformationMessageToDeployerMainUI, postInformationMessageToDeployerUI, postSuccessMessageToDeployerMainUI, postSuccessMessageToDeployerUI, postWarningMessageToDeployerMainUI, postWarningMessageToDeployerUI, readFile, removeAlphaCharsFromString, replaceSubstring, runAs, runAs, setIbmNsiProperty, setKeyValue, setLogFileName, setMainResources, setResponseFileProperty, setResponseFileValue, trace, trace, trace, trimDoubleQuotes, unPackJar, valueExists, waitForFile, writeFile
 
Methods inherited from class com.ibm.jsdt.common.Base
getBuildPropertiesAccessor, getFullVersion, getMainResources, getResourceString, getResourceString, getResourceString, getResourceString, getResourceString, getResourceStringArray, getResourceStringArray, showBuildProperties, showFullVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sNEWLN

public static final java.lang.String sNEWLN
System-independent line separator.


filePath

protected static java.lang.String filePath
File that indicates the current version of the Linux OS.


searchString

protected static java.lang.String searchString
String that represents the version of Linux on the target computer.

For example: "SUSE LINUX Enterprise Server 10"


startIndex

protected static int startIndex
Index where the file start to search.

Constructor Detail

LinuxDeploymentHelper

public LinuxDeploymentHelper()
Sole constructor.

Method Detail

doesUserExist

public static boolean doesUserExist(java.lang.String userName)
Verifies the existence of a user ID.

Parameters:
userName - - user name to verify
Returns:
A Boolean value of
  • true if username is found
  • false if username is not found

createUser

public static boolean createUser(java.lang.String userName,
                                 java.lang.String password,
                                 java.lang.String groupName)
Creates a new user ID and assign it to the group.

Parameters:
userName - - a user name
password - - a password
groupName - - a group name
Returns:
A Boolean value of
  • true if user ID is successfully created
  • false all else

createLinuxUser

public static boolean createLinuxUser(java.lang.String userName,
                                      java.lang.String password)
Creates a new user ID using the Linux system's native password hashing/encryption algorithm and creates the /home/ directory.

Parameters:
userName - - a user name
password - - a password
Returns:
A Boolean value of
  • true if user ID is successfully created
  • false all else

doesGroupExist

public static boolean doesGroupExist(java.lang.String groupName)
Verifies the existence of a user group.

Parameters:
groupName - - a group name
Returns:
A Boolean value of
  • true if group name is found
  • false if group name is not found

createGroup

public static boolean createGroup(java.lang.String groupName)
Creates a new user ID group.

Parameters:
groupName - - a group name
Returns:
A Boolean value of
  • true if group is created
  • false otherwise

addUserToGroup

public static boolean addUserToGroup(java.lang.String groupName,
                                     java.lang.String userName)
Adds a user to a group.

Parameters:
groupName - - a Linux group name
userName - - a user name
Returns:
a boolean
  • true if user name is added to group successfully
  • false otherwise

isAllRPMsInstalled

public static int isAllRPMsInstalled(java.lang.Object[] RPMArray)
Inclusively checks for a set of RPMs.

Do not use suffixes on the RPM name, such as ".i386.rpm". For example, the RPM file db2rte71-7.1.0-0.i386.rpm would have the following valid names:
  db2rte71 and db2rte71-7.1.0-0
The following names would not be valid:
  db2rte71-7.1.0-0.i386 and db2rte71-7.1.0-0.i386.rpm

Parameters:
RPMArray - - an Objects[] array of RPM package names
Returns:
An int as follows:
  • 0 if all RPMs are found to be installed
  • 1 if less than all RPMs are installed or there are RPM names that are not valid
  • 99 exception

isAnyRPMsInstalled

public static int isAnyRPMsInstalled(java.lang.Object[] RPMArray)
Noninclusively checks for a set of RPMs.

Do not use suffixes on the RPM name, such as ".i386.rpm". For example, the RPM file db2rte71-7.1.0-0.i386.rpm would have the following valid names:
  db2rte71 and db2rte71-7.1.0-0
And the following names would not be valid:
  db2rte71-7.1.0-0.i386 and db2rte71-7.1.0-0.i386.rpm

Parameters:
RPMArray - - an array of RPM package names
Returns:
An int as follows
  • 0 if none of the RPMs are found
  • n+1 indicating the number in the array of the RPM that was found

isRpmInstalled

public static boolean isRpmInstalled(java.lang.String rpmPackage)
Checks to see if a specific RPM package is installed.

Parameters:
rpmPackage - - an RPM package name
Returns:
A Boolean value of
  • true if the RPM is installed
  • false otherwise

chmodDirPermissions

public static void chmodDirPermissions(java.lang.String path,
                                       java.lang.String chmodValue)
Changes the permissions on a folder.

Parameters:
path - - directory on which to set the access permission
chmodValue - - chmod value indicating the permission level to set on the folder

chmodFilePermissions

public static void chmodFilePermissions(java.lang.String fileName,
                                        java.lang.String chmodValue)
Changes the permissions on a file.

Parameters:
fileName - - a file name on which to set the access permission
chmodValue - - chmod value indicating the permission level to set on the file

isRootUser

public static boolean isRootUser()
Verify that current user is the root user.

Returns:
A Boolean value of
  • true if the current user is a root user.
  • false if the current user is not a root user, or if an error occurred while detecting the current user level.

isUserAndPasswordValid

public static boolean isUserAndPasswordValid(java.lang.String userName,
                                             java.lang.String password)
Verifies that the given user and password are valid.

This will not work with releases prior to IR 2.1.0.0 and IIA "agent version" prior to 3.1.0.0 . A value of true is returned when run on a back level IIA.

This method works for shadow passwords and the older, less secure UNIX password storage mechanism. Note: If the target machine uses DES password encryption, it is possible that a password match could occur even if the passwords do not completely match. This is a limitation of DES encryption. DES only matches the first 8 characters. For examples, if the root password is "passw0rd", "passw0rd1" will be accepted because the first 8 characters match. A machine with DES password encryption would accept "password1" as a valid root password.

Parameters:
userName - - a user name
password - - a user password
Returns:
A Boolean value of
  • true if the user name and password are valid
  • false if the user name and password are not valid

isIntelBasedLinux

public static boolean isIntelBasedLinux()
Indicates whether the current architecture is Intel-based Linux.

Returns:
A Boolean value of
  • true if architecture is Intel-based Linux
  • false if architecture is not an Intel-based Linux

isPowerLinux

public static boolean isPowerLinux()
Indicates whether the current architecture is Linux on POWER.

Returns:
a boolean
  • true if architecture is Linux on POWER
  • false if architecture is Linux on POWER

doUserAdd

public static int doUserAdd(java.lang.String compareVersion,
                            java.lang.String userName,
                            java.lang.String password)
Deprecated. Use createLinuxUser instead

Example command: useradd -m -d /home/db2inst2 -p encPwd db2inst2

This method can only be called with local deployments or on remote computers running IBM Installation Agents with a specification version of 2.1.1.0 or later. If a down-level agent is encountered, a value of Integer.MIN_VALUE (-2147483648) is returned.

Adds a user to the Linux system using the useradd command.

Parameters:
compareVersion - - version to be compared with the current Linux OS
userName - - a user name to be verified
password - - a user password.
Returns:
int the return code from the useradd call.

getDeviceNameFromMountPoint

public static java.lang.String getDeviceNameFromMountPoint(java.lang.String path)
Gets the device name, given a mount point on Linux.

Parameters:
path - - a mount point path
Returns:
String

isRHEL4

public static boolean isRHEL4()
Determines if the target computer is running Red Hat Enterprise Linux release 4.

Returns:
A Boolean value of
  • true if target computer is running Red Hat Enterprise Linux release 4
  • false if target computer is not running Linux Red Hat Enterprise Linux release 4

isSLES9

public static boolean isSLES9()
Determines if the target computer is running SUSE Linux Enterprise Server 9

Returns:
A Boolean value of
  • true if target computer is running SUSE Linux Enterprise Server 9
  • false if target computer is not running SUSE Linux Enterprise Server 9

isSLES10

public static boolean isSLES10()
Determines if the target computer is running SUSE Linux Enterprise Server 10

Returns:
A boolean value of
  • true if target computer is running SUSE Linux Enterprise Server 10
  • false if target computer is not running SUSE Linux Enterprise Server 10

isRHEL5

public static boolean isRHEL5()
Determines if the target computer is running Red Hat Enterprise Linux release 5.

Returns:
A boolean value of
  • true if target computer is running Red Hat Enterprise Linux release 5
  • false if target computer is not running Red Hat Enterprise Linux release 5

runCommandAsUser

public static int runCommandAsUser(java.lang.String userId,
                                   java.lang.String password,
                                   java.lang.String command)
Runs the command on the local computer as the specified user.

Type Parameters:
code - String userId
code - String password
code - String command
Returns:
int the return code of the command.

runCommandAsUser

public static int runCommandAsUser(java.lang.String userId,
                                   java.lang.String password,
                                   java.lang.String command,
                                   boolean shouldLogOutput)
Runs the command on the local computer as the specified user.

Type Parameters:
code - String userId
code - String password
code - String command
code - boolean turn command output logging on/off
Returns:
int the return code of the command.

isZ_Linux

public static boolean isZ_Linux()
Indicates whether or not this is a zLinux platform.

Returns:
true if this is a zLinux platform.

isZ_Linux64

public static boolean isZ_Linux64()
Indicates whether or not this is a zLinux 64 bit platform.

Returns:
true if this is a zLinux 64 bit platform.

isZ_Linux32

public static boolean isZ_Linux32()
Indicates whether or not this is a zLinux 32 bit platform.

Returns:
true if this is a zLinux 32 bit platform.