File: //usr/openv/pdde/pdag/scripts/pddeinstall.sh
#!/bin/sh
###########################################################
# This script unpacks the PDDE server and agent packages
###########################################################
# Copyright (C) 2009 Symantec
# All Rights Reserved
#
# THIS SOURCE CODE IS AN UNPUBLISHED PROPRIETARY TRADE SECRET OF
# Symantec
#
# The copyright notice above does not evidence any actual or intendent
# publication of such source code.
#
#########################################################################
PACKAGE_NAME="NetBackup Deduplication"
OS=`uname -s`
# Remove group and world writable permissions
umask 0022
LC_ALL=C
LANG=C
case "${OS}" in
HP*)
AWK="awk"
DFCMD="df -kP"
PATH="/usr/sbin:/usr/bin:/usr/contrib/bin:${PATH}"
;;
SunOS*)
AWK="nawk"
DFCMD="df -k"
PATH="/sbin:/usr/sbin:/bin:/usr/bin:${PATH}"
;;
*)
AWK="awk"
DFCMD="df -kP"
PATH="/sbin:/usr/sbin:/bin:/usr/bin:${PATH}"
;;
esac
export LC_ALL LANG PATH
ACTION=install
TIMESTAMP=`date +%F_%H:%M`
VERSION=8.1.0.0
INSTALL_PATH="/usr/openv/pdde"
OSTPLUGINS_PATH="/usr/openv/lib/ost-plugins"
STORAGEPATH=
STORAGEFORMAT=
pdde_pack_path=""
agent_pack_path=""
pdprecheck=0
validate=0
forceclean=0
noscripts=0
verbose=0
LOGDIR="/var/log/puredisk"
if [ ! -d "${LOGDIR}" ] ; then
mkdir -p "${LOGDIR}"
fi
LOGFILE=${LOGDIR}/${TIMESTAMP}-pddeinstall.log
# Where to extract pdde packages
if [ "${NB_TMPDIR}" != "" ] ; then
pkg_dir=${NB_TMPDIR}/pdde_pkg_dir_$$
elif [ "${TMPDIR}" != "" ] ; then
pkg_dir=${TMPDIR}/pdde_pkg_dir_$$
else
pkg_dir=/tmp/pdde_pkg_dir_$$
fi
SaNative=0
case "${OS}" in
Linux*)
# RPMs in use on Red Hat or SLES
SaNative=1
;;
esac
################################################################################
# cmd_in_path - The "which" for the rest of us
################################################################################
cmd_in_path ()
{
cmd="${1}"
rm -f /tmp/cmd_in_path.$$
echo "${PATH}" | tr ':' '\012' | \
while read cpath
do
if [ -x "${cpath}"/"${cmd}" ] ; then
echo 0 >> /tmp/cmd_in_path.$$
break
fi
done
if [ -s /tmp/cmd_in_path.$$ ] ; then
rm -f /tmp/cmd_in_path.$$
return 0
fi
return 1
}
if [ ${SaNative} -eq 0 ] ; then
cmd_in_path gunzip
if [ $? -eq 1 ]; then
echo "ERROR: gunzip not found in path: ${PATH}" | tee -a ${LOGFILE}
exit 1
fi
fi
################################################################################
# helptext - Print the usage.
################################################################################
helptext () {
echo "Usage: $0 -pdde_pack_path <pddepath> -pddeagent_pack_path <agentpath> [-clean][-forceclean]"
echo
echo " -pdde_pack_path <pddepath> : Full path to ${PACKAGE_NAME} Server package."
echo " -pddeagent_pack_path <agentpath> : Full path to ${PACKAGE_NAME} Agent package."
echo " -precheck : Check for previous PureDisk installation."
echo " -clean : Uninstall."
echo " -forceclean : Uninstall and do not save config files for upgrades."
exit 1
}
################################################################################
# die - Print error message and exit immediately. Second optional parameter is
# a custom return code.
################################################################################
die () {
echo
if [ "${1}" != "" ]; then
echo "ERROR: ${1}" | tee -a ${LOGFILE}
echo
fi
echo "!!! Aborting... " | tee -a ${LOGFILE}
echo "Full ${PACKAGE_NAME} ${ACTION}ation log saved to: ${LOGFILE}" | tee -a ${LOGFILE}
echo
if [ -n "$2" ] ; then
exit $2
else
exit 1
fi
}
################################################################################
# getPDInstallPath - Get install path for classic PureDisk
################################################################################
getPDInstallPath () {
PD_INSTALL_PATH=""
PD_INSTALL_PATH="`${AWK} 'BEGIN { FS="=" } ; { if ( /Symantec\/PureDisk\/Agent/ ) \
{ getline; if ( /^path=\/.*$/ ) { print $2 } else { getline; print $2 } } }' \
/etc/pdregistry.cfg`"
if [ -n "${PD_INSTALL_PATH}" ]; then
PD_INSTALL_PATH="`dirname "${PD_INSTALL_PATH}"`"
fi
}
################################################################################
# queryPackage - Check if the native package is already installed on the system
################################################################################
queryPackage () {
package_name=$1
if [ -z "${package_name}" ] ; then
echo "ERROR: Missing package name in queryPackage function!" | tee -a ${LOGFILE}
return 1
fi
# Build the command for the right platform
case "${OS}" in
HP*) query_cmd="swlist ${package_name}" ;;
Linux*) query_cmd="rpm -q ${package_name}" ;;
AIX) query_cmd="lslpp -l ${package_name}" ;;
SunOS)
if [ -n "${alt_root_path}" ] ; then
query_cmd="pkginfo -R ${alt_root_path} ${package_name}"
else
query_cmd="pkginfo ${package_name}"
fi
;;
esac
# Query for the package!
echo >> ${LOGFILE}
echo "Checking for ${package_name} package..." | tee -a ${LOGFILE}
echo ${query_cmd} >> ${LOGFILE}
${query_cmd} >> ${LOGFILE} 2>&1
if [ $? -eq 0 ] ; then
echo " Package ${package_name} found." | tee -a ${LOGFILE}
return 0
fi
return 1
}
################################################################################
# installPackage - Install the native package on the system
################################################################################
installPackage () {
package_name=$1
package_path=$2
cwd=`pwd`
if [ -z "${package_name}" ] ; then
echo "ERROR: Missing package name in installPackage function!" | tee -a ${LOGFILE}
return 1
fi
if [ -z "${package_path}" ] ; then
echo "ERROR: Missing package path in installPackage function!" | tee -a ${LOGFILE}
return 1
fi
if [ ! -f "${package_path}" ] ; then
echo "ERROR: Package not found: ${package_path}!" | tee -a ${LOGFILE}
return 1
fi
# Build the command for the right platform
case "${OS}" in
HP*)
x_parameters="-x mount_all_filesystems=false"
check_for_HP_container
if [ $? -eq 1 ] ; then
x_parameters="${x_parameters} -x global_srp=true"
fi
inst_cmd="swinstall ${x_parameters} -s ${pkg_dir}/${package_name}.depot ${package_name}"
;;
Linux*) inst_cmd="rpm -vv -U --replacepkgs --oldpackage ${pkg_dir}/${package_name}.rpm" ;;
AIX) inst_cmd="installp -a -d ${pkg_dir}/${package_name}.image ${package_name}" ;;
SunOS) inst_cmd="pkgadd -n -a ${pkg_dir}/admin -d ${pkg_dir}/${package_name}.pkg ${package_name}" ;;
esac
gunzip_cmd="gunzip -d -c ${package_path}"
tar_cmd="/bin/tar xvf -"
if [ -d "${pkg_dir}" ] ; then
echo "${pkg_dir} exists, removing it." >> ${LOGFILE}
rm -rf "${pkg_dir}" >> ${LOGFILE} 2>&1
fi
mkdir -p "${pkg_dir}" >> ${LOGFILE} 2>&1
if [ $? -ne 0 ] ; then
echo "ERROR: Unable to create directory ${pkg_dir}" | tee -a ${LOGFILE}
return 1
fi
cd "${pkg_dir}"
# Extract the package
echo >> ${LOGFILE}
echo "Extracting package ${package_name} in ${pkg_dir}." | tee -a ${LOGFILE}
${gunzip_cmd} | ${tar_cmd} >> ${LOGFILE} 2>&1
if [ $? -ne 0 ] ; then
echo "ERROR: Unable to unbundle the package ${package_name} in ${pkg_dir}!" | tee -a ${LOGFILE}
cd ${cwd}
rm -rf "${pkg_dir}"
return 1
else
echo " Package ${package_name} extracted to ${pkg_dir}." | tee -a ${LOGFILE}
fi
# Install the package!
echo >> ${LOGFILE}
echo "Installing package ${package_name}." | tee -a ${LOGFILE}
echo ${inst_cmd} >> ${LOGFILE}
${inst_cmd} >> ${LOGFILE} 2>&1
if [ $? -eq 0 ] ; then
echo " Package ${package_name} installed." | tee -a ${LOGFILE}
else
echo "ERROR: Unable to install the package ${package_name}!" | tee -a ${LOGFILE}
cd ${cwd}
rm -rf "${pkg_dir}"
return 1
fi
cd ${cwd}
rm -rf "${pkg_dir}"
return 0
}
################################################################################
# removePackage - Uninstall the native package from the system
################################################################################
removePackage () {
package_name=$1
if [ -z "${package_name}" ] ; then
echo "ERROR: Missing package name in removePackage function!" | tee -a ${LOGFILE}
return 1
fi
# Use existing or create an admin file for removal
if [ "${OS}" = "SunOS" ] ; then
if [ -f ${INSTALL_PATH}/pdag/scripts/admin ] ; then
admin_file=${INSTALL_PATH}/pdag/scripts/admin
else
cat > /tmp/pdde_$$_admin << __EOF__
nstance=overwrite
partial=nocheck
runlevel=nocheck
idepend=nocheck
rdepend=nocheck
space=nocheck
setuid=nocheck
conflict=nocheck
action=nocheck
basedir=default
__EOF__
admin_file=/tmp/pdde_$$_admin
fi
fi
# Build the command for the right platform
case "${OS}" in
HP*)
x_parameters="-x mount_all_filesystems=false -x enforce_dependencies=false"
check_for_HP_container
if [ $? -eq 1 ] ; then
x_parameters="${x_parameters} -x global_srp=true"
fi
rm_cmd="swremove ${x_parameters} ${package_name}"
;;
Linux*) rm_cmd="rpm -vv -e ${package_name}" ;;
AIX) rm_cmd="installp -u ${package_name}" ;;
SunOS) rm_cmd="pkgrm -n -a ${admin_file} ${package_name}" ;;
esac
# Remove the package!
echo >> ${LOGFILE}
echo "Removing ${package_name} package..." | tee -a ${LOGFILE}
echo ${rm_cmd} >> ${LOGFILE}
${rm_cmd} >> ${LOGFILE} 2>&1
if [ $? -eq 0 ] ; then
echo " Package ${package_name} removed." | tee -a ${LOGFILE}
else
echo "ERROR: Removal of package ${package_name} was unsuccessful!" | tee -a ${LOGFILE}
return 1
fi
# Clean up created admin file
if [ "${OS}" = "SunOS" -a -f /tmp/pdde_$$_admin ] ; then
rm -f /tmp/pdde_$$_admin
fi
return 0
}
################################################################################
# check_for_HP_container is used to figure out if
# the host is a container on an HP Itanium machine.
# We will not install unless it is the global
# container. The caller will issue an abort message
# if necessary or add the required parameter
# to swinstall or swremove if it is global.
#
# This should only be called for HP Itanium machines.
#
# return 0 if no HP containers configured (normal)
# return 1 if in an HP container and it is global
# return 2 if in an HP container but it is not global
################################################################################
check_for_HP_container ()
{
# Only applies to HP Itanium machines
if [ `echo ${OS} | cut -c -2` != "HP" -o `uname -m` != "ia64" ] ; then
return 0;
fi
# Figure out if there are containers and
# if so, is this the global container.
# If getprocxsec fails, there are no containers
# set up on this machine. If it passes and
# the container name is init, it is the
# global one, else it is some type of
# SRP or workload container.
container=`getprocxsec -c 2>/dev/null`
if [ $? -ne 0 ] ; then
return 0
else
cname=`echo ${container} | cut -f2- -d" "`
if [ "${cname}" = "init" ] ; then
return 1
else
return 2
fi
fi
}
################################################################################
# Loads environment variables
################################################################################
LoadEnvironment() {
# /etc/pdregistry.cfg
#
# [Symantec/PureDisk/ContentRouter]
# path=/usr/openv/pdde/pdcr
# configfilepath=/StgPool/etc/puredisk/contentrouter.cfg
tmp_value1="`${AWK} 'BEGIN { FS="=" } ; { if ( /Symantec\/PureDisk\/ContentRouter/ ) \
{ getline; if ( /^configfilepath=\/.*$/ ) { print $2 } else { getline; print $2 } } }' \
/etc/pdregistry.cfg`"
# <storage>/etc/puredisk/contentrouter.cfg => STORAGEPATH
tmp_value1=`dirname "${tmp_value1}"`
tmp_value1=`dirname "${tmp_value1}"`
STORAGEPATH=`dirname "${tmp_value1}"`
echo "Storage path: ${STORAGEPATH}" >> ${LOGFILE}
if [ ! -d "${STORAGEPATH}" ]; then
echo "${STORAGEPATH} is not a directory" >> ${LOGFILE}
return 1
fi
STORAGEFORMATFILE="${STORAGEPATH}/data/.format"
if [ ! -f "${STORAGEFORMATFILE}" ]; then
if [ -f "${STORAGEPATH}/data/64.bhd" ] ; then
STORAGEFORMAT=1
else
STORAGEFORMAT=2
fi
elif [ -s "${STORAGEFORMATFILE}" ]; then
STORAGEFORMAT=`sed -n '1p' "${STORAGEFORMATFILE}"`
STORAGEFORMAT=`expr ${STORAGEFORMAT} / 10000`
else
echo "${STORAGEFORMATFILE} exists but is empty" >> ${LOGFILE}
fi
# Verify storage format was set
if [ "${STORAGEFORMAT}" = "" ]; then
echo "STORAGEFORMAT is not set, failed to extract" >> ${LOGFILE}
echo "from first line of ${STORAGEFORMATFILE} file" >> ${LOGFILE}
echo "with contents displayed below:" >> ${LOGFILE}
echo "------------------------------------------" >> ${LOGFILE}
cat ${STORAGEFORMATFILE} >> ${LOGFILE}
echo "------------------------------------------" >> ${LOGFILE}
return 1
fi
echo "Storage format: ${STORAGEFORMAT}" >> ${LOGFILE}
return 0
}
################################################################################
# Checks if there is an incomplete old conversion.
#
# Though the conversion tool can safely resume incomplete work of itself
# There will be DATA LOSS if use it to resume an incomplete work by other version conversion tool
################################################################################
CheckIncompleteConversion() {
if [ -f "${STORAGEPATH}/data/convert.lck" ]; then
echo "ATTENTION! There is an incomplete old conversion in your MSDP storage." | tee -a ${LOGFILE}
echo "Please finish the conversion before upgrade." | tee -a ${LOGFILE}
echo "Read https://www.veritas.com/support/en_US/article.TECH215769 for more details." | tee -a ${LOGFILE}
return 1
fi
return 0
}
################################################################################
# Checks if there is enough free disk space
################################################################################
CheckFreeStorageSpace()
{
FREE_DISK_SPACE_PERCENT="12"
DS_Total=""
DS_Free=""
tmp_value1=""
# Extra disk space is required only when upgrade from storage format 1.0 (7.0/7.1/7.5)
if [ "${STORAGEFORMAT}" -ne 1 ]; then
echo "Extra free storage space is not required for the upgrade from storage format ${STORAGEFORMAT}." >> ${LOGFILE}
return 0
fi
DS_Total="`${DFCMD} "$STORAGEPATH" | tail -1 | ${AWK} '{print $2}'`"
DS_Free="`${DFCMD} "$STORAGEPATH" | tail -1 | ${AWK} '{print $4}'`"
Per_Free="`echo "100*${DS_Free}/${DS_Total}" | bc`"
echo "Disk space total: ${DS_Total}" >> ${LOGFILE}
echo "Disk space free: ${DS_Free}" >> ${LOGFILE}
echo "Percentage free: ${Per_Free}%" >> ${LOGFILE}
# /bin/sh on some system(HP-UX) do not support 64bit integer
# to avoid overflow of integer, use M as unit of storage size
DS_Total="`echo $DS_Total/1024 | bc `"
DS_Free="`echo $DS_Free/1024 | bc `"
tmp_value1="`echo "$DS_Total*$FREE_DISK_SPACE_PERCENT/100" | bc`"
if [ $DS_Free -lt $tmp_value1 ]; then
PDDE_GC_TOOL="`dirname $0`/PDDE_gc"
echo "ATTENTION! There is not enough free disk space." | tee -a ${LOGFILE}
echo "The ${PACKAGE_NAME} upgrade requires at least $FREE_DISK_SPACE_PERCENT% free disk space to proceed." | tee -a ${LOGFILE}
echo "Read NetBackup Upgrade Guide for more details." | tee -a ${LOGFILE}
return 1
fi
echo "There is enough free disk space to continue" >> ${LOGFILE}
return 0
}
################################################################################
# pre-check function
# Checks the system for pre-existing issues that would cause problems with the
# installation.
# Returns 0 if the install can proceed,
# 1 if the install cannot proceed,
# 2 if the install can proceed, but a storage pool conversion will be
# required.
################################################################################
PreCheck ()
{
# Verify we can actually write to our logfile
echo "Starting ${PACKAGE_NAME} ${ACTION}er" | tee -a ${LOGFILE}
if [ ! -f "${LOGFILE}" ] ; then
echo "Failed to write to the log file: ${LOGFILE}" | tee -a ${LOGFILE}
return 1
fi
# Verify we can write to /tmp
echo "testing: $pkg_dir"
testdir=`dirname ${pkg_dir}`
testfile=${testdir}/precheck_tmp_test_$$
touch ${testfile} 2>&1 >> ${LOGFILE}
if [ $? != 0 -o ! -f "${testfile}" ] ; then
echo "Failed to write to ${testdir}" | tee -a ${LOGFILE}
return 1
fi
rm -f ${testfile}
if [ -n "${alt_root_path}" ] ; then
echo "Using an alternate root environment: ${alt_root_path}" >> ${LOGFILE}
fi
if [ -d ${alt_root_path}/opt/pdspa ]; then
echo
echo "A NetBackup PureDisk Storage Pool Authority is already installed." | tee -a ${LOGFILE}
echo
return 0
fi
check_for_HP_container
if [ $? -eq 2 ] ; then
echo "${PACKAGE_NAME} is not supported in an HP Itaniam non-global container."
return 1
fi
if [ -L "${alt_root_path}/etc/pdregistry.cfg" ]; then
alt_pdregistry_path=`ls -l ${alt_root_path}/etc/pdregistry.cfg | ${AWK} -F '-> ' '{print $NF}'`
alt_pdregistry_path="${alt_root_path}${alt_pdregistry_path}"
elif [ -f "${alt_root_path}/etc/pdregistry.cfg" ]; then
alt_pdregistry_path="${alt_root_path}/etc/pdregistry.cfg"
fi
if [ -f "${alt_pdregistry_path}" ]; then
grep "\[Symantec\/PureDisk\/PDDE\]" "${alt_pdregistry_path}" >/dev/null 2>&1
IS_PDDE=$?
queryPackage SYMCpddea
PDDE_AGENT_INSTALLED=$?
queryPackage VRTSpddea
RENAMED_PDDE_AGENT_INSTALLED=$?
if [ ${IS_PDDE} -eq 0 -o ${PDDE_AGENT_INSTALLED} -eq 0 -o ${RENAMED_PDDE_AGENT_INSTALLED} -eq 0 ]; then
if [ -d "${alt_root_path}${INSTALL_PATH}" ]; then
echo
echo "${PACKAGE_NAME} software is installed." | tee -a ${LOGFILE}
echo
grep "Symantec\/PureDisk\/ContentRouter" "${alt_pdregistry_path}" >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "${PACKAGE_NAME} is not yet configured." | tee -a ${LOGFILE}
return 0
fi
echo "${PACKAGE_NAME} is configured." | tee -a ${LOGFILE}
if [ -n "${alt_root_path}" ] ; then
echo "ATTENTION! Cannot determine the NetBackup Media Server Deduplication" | tee -a ${LOGFILE}
echo "storage directory while running in an alternate root environment." | tee -a ${LOGFILE}
echo "Please reboot with ${alt_root_path} as the running root to" | tee -a ${LOGFILE}
echo "proceed with this installation." | tee -a ${LOGFILE}
return 1
fi
LoadEnvironment
if [ $? -ne 0 ]; then
return 0
fi
if [ "${STORAGEFORMAT}" -eq 3 ]; then
echo "Your Media Server Deduplication Pool is up to date." | tee -a ${LOGFILE}
return 0
fi
CheckIncompleteConversion
if [ $? -ne 0 ]; then
return 1;
fi
CheckFreeStorageSpace
if [ $? -ne 0 ]; then
return 1;
fi
return 2
else
mv ${alt_root_path}/etc/pdregistry.cfg ${alt_root_path}/etc/pdregistry.cfg.${TIMESTAMP}
return 0
fi
fi
# Looks like we have possible PDDO or classic PureDisk installation.
getPDInstallPath
if [ -d "${PD_INSTALL_PATH}/pdag" -a -f "${OSTPLUGINS_PATH}/libstspipd.so" ]; then
echo
echo "NetBackup PureDisk PDDO software is installed." | tee -a ${LOGFILE}
echo "You must run sh ${PD_INSTALL_PATH}/pdde/pdag/bin/uninstall.sh to remove it." | tee -a ${LOGFILE}
echo "If you want to keep your custom PDDO configuration," | tee -a ${LOGFILE}
echo "make a copy of ${OSTPLUGINS_PATH}/pd.conf" | tee -a ${LOGFILE}
echo "before removing the software." | tee -a ${LOGFILE}
echo
return 1
elif [ -d "${PD_INSTALL_PATH}/pdag" ]; then
echo
echo "NetBackup PureDisk Agent software is installed." | tee -a ${LOGFILE}
echo "You must run sh ${PD_INSTALL_PATH}/pdag/bin/uninstall.sh to remove it." | tee -a ${LOGFILE}
echo
return 1
else
echo
echo "NetBackup PureDisk Agent or PDDO software is incorrectly installed." | tee -a ${LOGFILE}
echo "/etc/pdregistry.cfg was unexpectedly found." | tee -a ${LOGFILE}
echo "Moving to /etc/pdregistry.cfg.${TIMESTAMP} in order to continue." | tee -a ${LOGFILE}
echo
mv ${alt_root_path}/etc/pdregistry.cfg ${alt_root_path}/etc/pdregistry.cfg.${TIMESTAMP}
return 0
fi
else
if [ ! -d "${alt_root_path}/opt/pdag" -a ! -d "${alt_root_path}/opt/pdshared" ]; then
return 0
else
if [ "X" = "X${alt_pdregistry_path}" ]; then
alt_pdregistry_path="${alt_root_path}/etc/pdregistry.cfg"
fi
echo
echo "Cannot access ${alt_pdregistry_path}. Please confirm ${alt_pdregistry_path} exists " | tee -a ${LOGFILE}
echo "and restart the installation." | tee -a ${LOGFILE}
echo
return 1
fi
fi
}
################################################################################
# validate_func - Check the install and verify everything looks good.
# This function has three return codes:
# 0 - Everything checks out valid
# 1 - Something doesn't look right after install
# 2 - Something doesn't look right after upgrade
# Very bad! This means we just brought down someones storage.
# This should cause the DPA installing us to abort their install.
################################################################################
validate_func () {
retCode=1
echo "Validating ${PACKAGE_NAME} installation..."
if [ ! -f /etc/pdregistry.cfg ] ; then
die "/etc/pdregistry.cfg is missing!"
fi
# If pdregistry.cfg is a link, then it's an upgrade for an existing storage.
if [ -h /etc/pdregistry.cfg ] ; then
# If this install is part of an upgrade, we need to error harder
retCode=2
fi
# Check if the agnet package is installed
queryPackage VRTSpddea
if [ $? -ne 0 ] ; then
die "The VRTSpddea agent package is not installed!" ${retCode}
fi
# Query for the agent version
agentVersion=
case "${OS}" in
HP*) agentVersion=`swlist -v -a revision VRTSpddea | grep revision | sed 's/^.* \([0-9.]*\)$/\1/'` ;;
Linux*) agentVersion=`rpm -q --queryformat '%{VERSION}' VRTSpddea` ;;
AIX) agentVersion=`lslpp -cl VRTSpddea | grep VRTSpddea | sed 's/.*VRTSpddea:\([0-9.]*\):.*/\1/'` ;;
SunOS) agentVersion=`pkginfo -l VRTSpddea | grep VERSION: | sed 's/^.* \([0-9.]*\)$/\1/'` ;;
esac
# Validate version format before using it
echo ${agentVersion} | grep '^[0-9.]*$' > /dev/null 2>&1
if [ $? -eq 0 ] ; then
# Check that the version installed is correct
if [ "${agentVersion}" != "${VERSION}" ] ; then
die "The installed agent package has the wrong version! Installed: ${agentVersion}. Required: ${VERSION}" ${retCode}
fi
else
echo "Couldn't find valid agent version: ${agentVersion}."
fi
# Check that all directories and files are present
if [ ! -d "${INSTALL_PATH}/pdag" -o ! -d "${INSTALL_PATH}/pdopensource" -o ! -d "${INSTALL_PATH}/pdshared" ] ; then
die "Files missing from the agent package!" ${retCode}
fi
queryPackage VRTSpddes
if [ $? -ne 0 ] ; then
echo "The VRTSpddes server package is not installed!"
echo "${PACKAGE_NAME} agent-only installation is valid."
return 0
fi
# Query for the server version
serverVersion=
case "${OS}" in
HP*) serverVersion=`swlist -v -a revision VRTSpddes | grep revision | sed 's/^.* \([0-9.]*\)$/\1/'` ;;
Linux*) serverVersion=`rpm -q --queryformat '%{VERSION}' VRTSpddes` ;;
AIX) serverVersion=`lslpp -cl VRTSpddes | grep VRTSpddea | sed 's/.*VRTSpddes:\([0-9.]*\):.*/\1/'` ;;
SunOS) serverVersion=`pkginfo -l VRTSpddes | grep VERSION: | sed 's/^.* \([0-9.]*\)$/\1/'` ;;
esac
# Validate version format before using it
echo ${serverVersion} | grep '^[0-9.]*$' > /dev/null 2>&1
if [ $? -eq 0 ] ; then
# Check that the version installed is correct
if [ "${serverVersion}" != "${VERSION}" ] ; then
die "The installed server package has the wrong version! Installed: ${serverVersion}. Required: ${VERSION}" ${retCode}
fi
else
echo "Couldn't find valid server version: ${serverVersion}."
fi
# Check that all directories and files are present
if [ ! -d "${INSTALL_PATH}/pdconfigure" -o ! -d "${INSTALL_PATH}/pdcr" ] ; then
die "Files missing from the agent package!" ${retCode}
fi
echo "${PACKAGE_NAME} server installation is valid."
return 0
}
################################################################################
# main - Time to start installing!
################################################################################
main () {
if [ -f /etc/debian_version ]; then
exit 0
fi
if [ ${pdprecheck} -eq 1 ] ; then
PreCheck
precheckResult=$?
if [ ${precheckResult} -eq 0 -o ${precheckResult} -eq 2 ] ; then
echo "${PACKAGE_NAME} preinstall check passed" | tee -a ${LOGFILE}
elif [ ${precheckResult} -eq 1 ] ; then
echo "${PACKAGE_NAME} preinstall check failed" | tee -a ${LOGFILE}
fi
exit ${precheckResult}
elif [ "${ACTION}" = "install" ] ; then
PreCheck
precheckResult=$?
if [ ${precheckResult} -eq 1 ] ; then
echo "${PACKAGE_NAME} cannot be installed on this system." | tee -a ${LOGFILE}
echo "See the preinstall check results for more information: ${LOGFILE}"
exit 1
fi
elif [ "${ACTION}" = "uninstall" ] ; then
check_for_HP_container
if [ $? -eq 2 ] ; then
echo "${PACKAGE_NAME} is not supported in an HP Itaniam non-global container."
exit 1
fi
fi
if [ "${ACTION}" = "install" ] ; then
echo "Installing ${PACKAGE_NAME}..." >> ${LOGFILE}
if [ -n "${pdde_pack_path}" ] ; then
echo " Server package: ${pdde_pack_path}" >> ${LOGFILE}
fi
if [ -n "${agent_pack_path}" ] ; then
echo " Agent package: ${agent_pack_path}" >> ${LOGFILE}
fi
else
echo "Uninstalling ${PACKAGE_NAME}..." >> ${LOGFILE}
echo " Force clean: ${forceclean}" >> ${LOGFILE}
fi
echo " Install path: ${INSTALL_PATH}" >> ${LOGFILE}
echo " OST-Plugins path: ${OSTPLUGINS_PATH}" >> ${LOGFILE}
echo " No Scripts: ${noscripts}" >> ${LOGFILE}
if [ "${ACTION}" = "install" ] ; then
if [ -z "${pdde_pack_path}" -a -z "${agent_pack_path}" ]; then
if [ ${validate} -eq 1 ] ; then
# If validate_func is called without any other parameters, then validate and exit now
validate_func
exit 0
fi
echo
echo "Paths to the server and the agent packages not provided." | tee -a ${LOGFILE}
echo "Please either provide a path to the the server package '-pdde_pack_path'" | tee -a ${LOGFILE}
echo "or the the agent package '-pddeagent_pack_path'." | tee -a ${LOGFILE}
echo
helptext
else
if [ -n "${pdde_pack_path}" -a ! -f "${pdde_pack_path}" ] ; then
die "Cannot find ${PACKAGE_NAME} server package: ${pdde_pack_path}."
fi
if [ -n "${agent_pack_path}" -a ! -f "${agent_pack_path}" ]; then
die "Cannot find ${PACKAGE_NAME} agent package: ${agent_pack_path}."
fi
fi
fi
if [ -f ${INSTALL_PATH}/pdag/version.txt ] ; then
OLD_VERSION=`cat ${INSTALL_PATH}/pdag/version.txt`
fi
if [ ${noscripts} -eq 1 ] ; then
echo "Disabling native package scripts" | tee -a ${LOGFILE}
touch /tmp/PDDE_SKIP_PACKAGE_SCRIPTS
fi
if [ -n "${pdde_pack_path}" -o "${ACTION}" = "uninstall" ] ; then
queryPackage SYMCpddes
if [ $? -eq 0 ] ; then
removePackage SYMCpddes
if [ $? -ne 0 ] ; then
rm -rf /tmp/PDDE_SKIP_PACKAGE_SCRIPTS
die "Failed to remove SYMCpddes!"
fi
fi
fi
# checking for the VRTS packages..for removing first & then installing
if [ -n "${pdde_pack_path}" -o "${ACTION}" = "uninstall" ] ; then
queryPackage VRTSpddes
if [ $? -eq 0 ] ; then
removePackage VRTSpddes
if [ $? -ne 0 ] ; then
rm -rf /tmp/PDDE_SKIP_PACKAGE_SCRIPTS
die "Failed to remove VRTSpddes!"
fi
fi
fi
queryPackage SYMCpddea
if [ $? -eq 0 ] ; then
removePackage SYMCpddea
if [ $? -ne 0 ] ; then
rm -rf /tmp/PDDE_SKIP_PACKAGE_SCRIPTS
die "Failed to remove SYMCpddea!"
fi
fi
# checking for the VRTS packages on other platforms than Linux...for removing first & then installing
if [ ${SaNative} -eq 0 ] && [ -n "${agent_pack_path}" ] ; then
queryPackage VRTSpddea
if [ $? -eq 0 ] ; then
removePackage VRTSpddea
if [ $? -ne 0 ] ; then
rm -rf /tmp/PDDE_SKIP_PACKAGE_SCRIPTS
die "Failed to remove VRTSpddea!"
fi
fi
fi
if [ "${ACTION}" = "install" ] ; then
if [ -n "${agent_pack_path}" ] ; then
# checking for the VRTS packages..for removing first & then installing
case "${OS}" in
Linux*)
;;
*)
queryPackage VRTSpddea
if [ $? -eq 0 ] ; then
removePackage VRTSpddea
if [ $? -ne 0 ] ; then
rm -rf /tmp/PDDE_SKIP_PACKAGE_SCRIPTS
die "Failed to remove VRTSpddea!"
fi
fi
;;
esac
# Install the agent package
echo "Installing ${PACKAGE_NAME} agent package (${agent_pack_path})..." | tee -a ${LOGFILE}
installPackage VRTSpddea $agent_pack_path
if [ $? -ne 0 ] ; then
rm -rf /tmp/PDDE_SKIP_PACKAGE_SCRIPTS
die "Failed to install VRTSpddea!"
fi
fi
if [ -n "${pdde_pack_path}" ] ; then
# Install the server package
if [ -n "${pdde_pack_path}" ] ; then
echo "Installing ${PACKAGE_NAME} server package (${pdde_pack_path})..." | tee -a ${LOGFILE}
installPackage VRTSpddes $pdde_pack_path
if [ $? -ne 0 ] ; then
rm -rf /tmp/PDDE_SKIP_PACKAGE_SCRIPTS
die "Failed to install VRTSpddes!"
fi
fi
fi
# Upgrade the system
if [ -f ${INSTALL_PATH}/pdag/scripts/pddeupgrade.sh ] ; then
if [ -n "${pdde_pack_path}" ] ; then
echo "Running ${PACKAGE_NAME} upgrade script (server mode)..." | tee -a ${LOGFILE}
${INSTALL_PATH}/pdag/scripts/pddeupgrade.sh all >> ${LOGFILE} 2>&1
else
echo "Running ${PACKAGE_NAME} upgrade script (agent mode)..." | tee -a ${LOGFILE}
${INSTALL_PATH}/pdag/scripts/pddeupgrade.sh agent >> ${LOGFILE} 2>&1
fi
else
echo "ERROR: upgrade script is missing! (${INSTALL_PATH}/pdag/scripts/pddeupgrade.sh)" | tee -a ${LOGFILE}
fi
if [ ${validate} -eq 1 ] ; then
validate_func
fi
else # Uninstalling
if [ ${forceclean} -eq 1 ] ; then
if [ -f /etc/pdregistry.cfg ]; then
echo "Removing /etc/pdregistry.cfg." | tee -a ${LOGFILE}
rm -f /etc/pdregistry.cfg
fi
if [ -f ${OSTPLUGINS_PATH}/pd.conf ]; then
echo "Removing ${OSTPLUGINS_PATH}/pd.conf." | tee -a ${LOGFILE}
rm -f ${OSTPLUGINS_PATH}/pd.conf
fi
fi
fi
rm -rf /tmp/PDDE_SKIP_PACKAGE_SCRIPTS
echo "${PACKAGE_NAME} ${ACTION} finished successfully." | tee -a ${LOGFILE}
if [ -f ${INSTALL_PATH}/pdag/version.txt ] ; then
echo "Version now installed:" `cat ${INSTALL_PATH}/pdag/version.txt` | tee -a ${LOGFILE}
fi
echo "Full ${PACKAGE_NAME} ${ACTION}ation log saved to: ${LOGFILE}" | tee -a ${LOGFILE}
echo
}
# Parse CLI parameters
while [ $# -gt 0 ]; do
case ${1} in
-pdde_pack_path) shift; pdde_pack_path=${1}; shift ;;
-pddeagent_pack_path) shift; agent_pack_path=${1}; shift ;;
-precheck) pdprecheck=1; shift ;;
# Support alternate roots for precheck on Solaris. We will ignore this
# parameter when actually installing, as we will need to be in the
# running root when installing.
-alt_root_path)
shift
alt_root_path=${1}
if [ -n "$alt_root_path" ]; then
alt_root_path_clean="`echo "${alt_root_path}" | sed -e 's/^\/*//'`"
alt_root_path="/${alt_root_path_clean}"
fi
shift ;;
-postinstall) validate=1; shift ;;
-validate) validate=1; shift ;;
-uninstall) ACTION=uninstall; shift ;;
-clean) ACTION=uninstall; shift ;;
-forceclean) ACTION=uninstall; forceclean=1; shift ;;
-noscripts) noscripts=1; shift ;;
-verbose) verbose=1; shift ;;
-basedir) echo "basedir no longer needed. Ignoring..." ; shift ; shift ;;
-ostdir) echo "ostdir no longer needed. Ignoring..." ; shift ; shift ;;
*) echo "Unrecognized option: ${1}"; helptext;
esac
done
LOGFILE=/var/log/puredisk/${TIMESTAMP}-pdde-${ACTION}.log
mkdir -p `dirname ${LOGFILE}`
cd `dirname $0`
main