#!/bin/sh ########################################################### # This script unpacks the PDDE server and agent packages ########################################################### # $Copyright: Copyright (c) 2022 Veritas Technologies LLC. All rights reserved $ # # 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=16.0.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 ;; SunOS*) SaNative=1 ;; HP*) SaNative=1 ;; AIX*) SaNative=1 ;; esac self_exit () { exit $1; } ################################################################################ # 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} self_exit 1 fi fi ################################################################################ # helptext - Print the usage. ################################################################################ helptext () { echo "Usage: $0 -pdde_pack_path -pddeagent_pack_path [-clean][-forceclean]" echo echo " -pdde_pack_path : Full path to ${PACKAGE_NAME} Server package." echo " -pddeagent_pack_path : 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." self_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 self_exit $2 else self_exit 1 fi } ################################################################################ # getPDInstallPath - Get install path for classic PureDisk ################################################################################ getPDInstallPath () { PD_INSTALL_PATH="" PD_INSTALL_PATH="`${AWK} 'BEGIN { FS="=" } ; { if ( /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 x_parameters="${x_parameters} -x reinstall=true" 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 -F -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 -" is_Tar=0 case ${package_path} in *.tar.gz) is_Tar=1 ;; *) is_Tar=0 ;; esac 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} if [ "${OS}" = "SunOS" ] && [ ${is_Tar} = 0 ] ; then gunzip -c ${package_path} > ${pkg_dir}/${package_name}.pkg 2>&1 if [ ! -f ${pkg_dir}/admin ] ; then ## Create a temporary .pkg_defaults (admin) file to complete the installation of new packages on Solaris dummy_pkg_defaults="${pkg_dir}/admin" cat << eof > ${dummy_pkg_defaults} instance=overwrite partial=nocheck runlevel=nocheck idepend=nocheck rdepend=nocheck space=nocheck setuid=nocheck conflict=nocheck action=nocheck basedir=default eof chmod 555 ${dummy_pkg_defaults} fi elif [ "${OS}" = "HP-UX" ] && [ ${is_Tar} = 0 ] ; then gunzip -c ${package_path} > ${pkg_dir}/${package_name}.depot 2>&1 #If os type is AIX and is_tar flag is false then will gunzip and move .image file to pkg_dir else will gunzip and untar it. elif [ "${OS}" = "AIX" ] && [ ${is_Tar} = 0 ] ; then gunzip -c ${package_path} > ${pkg_dir}/${package_name}.image 2>&1 else ${gunzip_cmd} | ${tar_cmd} >> ${LOGFILE} 2>&1 fi 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 } ################################################################################ # 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 "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 "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 return 0 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 return 0 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 () { if [ -f /etc/debian_version ]; then return 0 fi 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 [ -n "${pdde_pack_path}" -a "${OS}" = "AIX" ]; then echo "${PACKAGE_NAME} is not supported on AIX platform." self_exit 0 fi if [ -n "${pdde_pack_path}" -a "${OS}" = "HP-UX" ]; then echo "${PACKAGE_NAME} is not supported on HP-UX platform." self_exit 0 fi if [ -n "${pdde_pack_path}" -a "${OS}" = "SunOS" ]; then echo "${PACKAGE_NAME} is not supported on SunOS platform." self_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 self_exit ${precheckResult} fi if [ "${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}" self_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." self_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 self_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 AIX*) ;; HP*) ;; Linux*) ;; SunOS*) ;; *) 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} if [ -f /etc/debian_version ]; then echo "gunzip -d -c $agent_pack_path | /bin/tar xv --keep-directory-symlink -C / " | tee -a ${LOGFILE} gunzip -d -c $agent_pack_path | /bin/tar xv --keep-directory-symlink -C / if [ $? -ne 0 ] ; then rm -rf /tmp/PDDE_SKIP_PACKAGE_SCRIPTS die "Failed to install VRTSpddea!" fi echo "Run post install scripts" | tee -a ${LOGFILE} chmod +x /usr/openv/pdde/pdag/scripts/VRTSpddea.postinstall /usr/openv/pdde/pdag/scripts/VRTSpddea.postinstall | tee -a ${LOGFILE} if [ $? -ne 0 ] ; then rm -rf /tmp/PDDE_SKIP_PACKAGE_SCRIPTS die "Failed to install VRTSpddea!" fi else installPackage VRTSpddea $agent_pack_path if [ $? -ne 0 ] ; then rm -rf /tmp/PDDE_SKIP_PACKAGE_SCRIPTS die "Failed to install VRTSpddea!" fi 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 "${agent_pack_path}" ] ; then 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 self_exit 0