Mini Shell

Direktori : /opt/dell/srvadmin/sbin/
Upload File :
Current File : //opt/dell/srvadmin/sbin/srvadmin-uninstall.sh

#!/bin/sh
###############################################################################
#
#          Dell Inc. PROPRIETARY INFORMATION
# This software is supplied under the terms of a license agreement or
# nondisclosure agreement with Dell Inc. and may not
# be copied or disclosed except in accordance with the terms of that
# agreement.
#
# Copyright (c) 2000-2009 Dell Inc. All Rights Reserved.
#
#   This script uninstalls all the installed Systems Management
#   rpm packages from the system
#
###############################################################################

# global variables
DELL_OPENMANAGE_PREFIX="srvadmin"
WSMAN_PKGS=""
DEFAULT_PREFIX="/opt/dell/srvadmin"
BACKUP_LOCATION_PREFIX="/opt/dell/backup/openmanage"

##function to export OMSA configuration.
function ExportOMSAPref
{
	if [ -d $BACKUP_LOCATION_PREFIX ]; then
		rm -rf $BACKUP_LOCATION_PREFIX	
	fi
	mkdir -p $BACKUP_LOCATION_PREFIX
	mkdir -p $BACKUP_LOCATION_PREFIX/lib64/openmanage/apache-tomcat/webapps/omsa/WEB-INF
	mkdir -p $BACKUP_LOCATION_PREFIX/lib64/openmanage/apache-tomcat/webapps/omsa/WEB-INF/lib
	mkdir -p $BACKUP_LOCATION_PREFIX/lib64/openmanage/apache-tomcat/conf
	mkdir -p $BACKUP_LOCATION_PREFIX/etc/openmanage/oma/ini
	mkdir -p $BACKUP_LOCATION_PREFIX/etc/srvadmin-isvc/ini
	mkdir -p $BACKUP_LOCATION_PREFIX/etc/openmanage/wwwroot/oem/data/ini/dell
	mkdir -p $BACKUP_LOCATION_PREFIX/share/applications
	
	if [ -e $DEFAULT_PREFIX/etc/openmanage/oma/ini/omprv.ini ]; then
		key_signing_algorithm_value=`sed -n '/key_signing_algorithm=/p' $DEFAULT_PREFIX/etc/openmanage/oma/ini/omprv.ini`
		echo $key_signing_algorithm_value > $BACKUP_LOCATION_PREFIX/key_signing_algorithm.bak
		dws_value=`sed -n '/enableDWS=/p' $DEFAULT_PREFIX/etc/openmanage/oma/ini/omprv.ini`
        echo $dws_value > $BACKUP_LOCATION_PREFIX/dws_value.bak
	fi
	if [ -e $DEFAULT_PREFIX/share/applications/srvadmin.desktop ]; then
		cp -pf $DEFAULT_PREFIX/share/applications/srvadmin.desktop $BACKUP_LOCATION_PREFIX/share/applications/                
	fi
    if [ -e $DEFAULT_PREFIX/lib64/openmanage/apache-tomcat/webapps/omsa/WEB-INF/web.xml ]; then
		cp -pf $DEFAULT_PREFIX/lib64/openmanage/apache-tomcat/webapps/omsa/WEB-INF/web.xml $BACKUP_LOCATION_PREFIX/lib64/openmanage/apache-tomcat/webapps/omsa/WEB-INF/
		echo "web.xml settings has been exported successfully" > $DEFAULT_PREFIX/var/log/openmanage/backup.log
	fi
	if [ -e $DEFAULT_PREFIX/lib64/openmanage/apache-tomcat/webapps/omsa/WEB-INF/lib/OMSA.jar ] && [ -e $DEFAULT_PREFIX/lib64/openmanage/apache-tomcat/webapps/omsa/WEB-INF/lib/OMPREF.jar ]; then
        cp -pf $DEFAULT_PREFIX/lib64/openmanage/apache-tomcat/webapps/omsa/WEB-INF/lib/OMSA.jar $BACKUP_LOCATION_PREFIX/lib64/openmanage/apache-tomcat/webapps/omsa/WEB-INF/lib/OMSA.jar.bak
        cp -pf $DEFAULT_PREFIX/lib64/openmanage/apache-tomcat/webapps/omsa/WEB-INF/lib/OMPREF.jar $BACKUP_LOCATION_PREFIX/lib64/openmanage/apache-tomcat/webapps/omsa/WEB-INF/lib/OMPREF.jar.bak
    fi
	if [ -e $DEFAULT_PREFIX/lib64/openmanage/apache-tomcat/conf/server.xml ]; then
		cp -pf $DEFAULT_PREFIX/lib64/openmanage/apache-tomcat/conf/server.xml $BACKUP_LOCATION_PREFIX/lib64/openmanage/apache-tomcat/conf/
		echo "server.xml settings has been exported successfully" >> $DEFAULT_PREFIX/var/log/openmanage/backup.log
	fi
	if [ -e $DEFAULT_PREFIX/etc/openmanage/oma/ini/oma.properties ]; then
		cp -pf $DEFAULT_PREFIX/etc/openmanage/oma/ini/oma.properties $BACKUP_LOCATION_PREFIX/etc/openmanage/oma/ini/
		echo "oma.properties settings has been exported successfully" >> $DEFAULT_PREFIX/var/log/openmanage/backup.log
	fi
	if [ -e $DEFAULT_PREFIX/etc/srvadmin-isvc/ini/dcisdy64.ini ]; then
		cp -pf $DEFAULT_PREFIX/etc/srvadmin-isvc/ini/dcisdy64.ini $BACKUP_LOCATION_PREFIX/etc/srvadmin-isvc/ini/
		echo "dcisdy64.ini settings has been exported successfully" >> $DEFAULT_PREFIX/var/log/openmanage/backup.log
	fi
	if [ -e $DEFAULT_PREFIX/etc/openmanage/wwwroot/oem/data/ini/dell/omsaoem.ini ]; then
		cp -pf $DEFAULT_PREFIX/etc/openmanage/wwwroot/oem/data/ini/dell/omsaoem.ini $BACKUP_LOCATION_PREFIX/etc/openmanage/wwwroot/oem/data/ini/dell/
		echo "omsaoem settings has been exported successfully" >> $DEFAULT_PREFIX/var/log/openmanage/backup.log
	fi
	if [ -e $DEFAULT_PREFIX/lib64/openmanage/apache-tomcat/conf/keystore.db ]; then
		cp -pf $DEFAULT_PREFIX/lib64/openmanage/apache-tomcat/conf/keystore.db $BACKUP_LOCATION_PREFIX/lib64/openmanage/apache-tomcat/conf/
		echo "keystore settings has been exported successfully" >> $DEFAULT_PREFIX/var/log/openmanage/backup.log
	fi
	if [ -e $DEFAULT_PREFIX/etc/openmanage/oma/ini/produsefeedback.ini ]; then
		cp -pf $DEFAULT_PREFIX/etc/openmanage/oma/ini/produsefeedback.ini $BACKUP_LOCATION_PREFIX/etc/openmanage/oma/ini/
		echo "produsefeedback.ini settings has been exported successfully" >> $DEFAULT_PREFIX/var/log/openmanage/backup.log
	fi
}
function Usage
{
echo "Usage: ${0} [OPTION]"
echo "Server Administrator Custom Uninstall Utility."
echo "This Utility will run in the interactive mode if no option"
echo "is given and runs silently if a valid option is given."
echo " "
echo "Option: "
echo "  [-f, --force]  do not prompt before uninstall"
echo "  [-h, --help]   Displays this help text."
echo " "
    exit 1
}

###############################################################################
#
#  Script execution begins here with the invocation
#  of Main function
#
###############################################################################
# check for root privileges
if [ ${UID} != 0 ]; then
    echo "Uninstall requires root privileges"
    exit 1
fi

INTERACTIVE=1
if [ $# -gt 0 ]; then
    if [ "${1}" == "-f" -o "${1}" == "--force" ]; then
        INTERACTIVE=0
    elif [ "${1}" == "-h" -o "${1}" == "--help" ]; then
        Usage
    else
        echo "Invalid option '${1}', please see the usage below"
        echo " "
        Usage
    fi
fi

if [ -x /usr/bin/vmware ]; then
    /usr/bin/vmware -v | grep "VMware ESX 4.0.*" >/dev/null 2>&1
    if [ $? == 0 ]; then
        WSMAN_PKGS=`rpm -qa | grep wsman`
    else
      /usr/bin/vmware -v | grep "VMware ESX 4.1.*" >/dev/null 2>&1
      if [ $? == 0 ]; then
        WSMAN_PKGS=`rpm -qa | grep wsman`
       fi
    fi
fi

# check for forced uninstall
if [ ${INTERACTIVE} == 1 ];
then
    echo "Uninstall will remove the following RPMs:"
    rpm -qa | egrep "^$DELL_OPENMANAGE_PREFIX|^instsvc" 
    [ -n "$WSMAN_PKGS" ] && echo "$WSMAN_PKGS"
    echo "Are you sure you want to uninstall?"
    read -p "   Press ('y' for yes | 'Enter' to exit): " RESP
    if ! echo "${RESP}" | grep -iq "^\s*y\s*$" ; then
        echo "Aborting uninstall on user input."
        exit 1
    fi
fi

##export OMSA configuration.
ExportOMSAPref

# remove srvadmin-omilcore last, as other rpms use scripts from it
# not required on newer RPM versions, as Requires(postun) takes care of this. RHEL4
# is the only RPM version that needs it.
OM_RPMS=$(rpm -qa | egrep "^$DELL_OPENMANAGE_PREFIX|^instsvc")
if [ -n "$OM_RPMS" ]; then
    [ -x /opt/dell/srvadmin/sbin/srvadmin-services.sh ] && 
         /opt/dell/srvadmin/sbin/srvadmin-services.sh stop
    # exclude omilcore and hapi here; they are uninstalled later.
    OM_RPMS=$(rpm -qa | egrep "^$DELL_OPENMANAGE_PREFIX|^instsvc" | grep -v omilcore | grep -v hapi | grep -v srvadmin-storelib-libpci | grep -v srvadmin-storelib-sysfs | grep -v srvadmin-sysfsutils | grep -v srvadmin-racadm4 | grep -v srvadmin-racsvc | grep -v srvadmin-omcommon | grep -v srvadmin-omacs | grep -v srvadmin-omaksmig | grep -v srvadmin-marvellib  )
    if [ -n "$OM_RPMS" ]; then
        rpm -e $OM_RPMS
        if [ $? -ne 0 ]; then
           rpm -e --allmatches --noscripts $OM_RPMS
        fi
    fi

    OM_RPMS=$(rpm -qa | grep 'srvadmin-omaksmig')
    if [ -n "$OM_RPMS" ]; then
       rpm -e srvadmin-omaksmig >/dev/null 2>&1
       if [ $? -ne 0 ]; then
          rpm -e --allmatches --noscripts srvadmin-omaksmig >/dev/null 2>&1
       fi
    fi

    for PKG_NAME in srvadmin-omcommon srvadmin-omacs srvadmin-storelib-libpci srvadmin-storelib-sysfs srvadmin-hapi srvadmin-sysfsutils srvadmin-racsvc srvadmin-racadm4 srvadmin-omilcore srvadmin-marvellib
    do
       OM_RPMS=$(rpm -qa | grep $PKG_NAME)
       if [ -n "$OM_RPMS" ]; then
           rpm -e $OM_RPMS
           if [ $? -ne 0 ]; then
              rpm -e --allmatches --noscripts $OM_RPMS
           fi
       fi
    done
fi

CLEANED_WSMAN_LIST=""
for WSMAN_PKG in $WSMAN_PKGS
do
   FILE_LIST=$(rpm -ql $WSMAN_PKG)
   echo $FILE_LIST | grep "opt/dell/srvadmin" >/dev/null 2>&1

   if [ $? == 0 ]
   then
     CLEANED_WSMAN_LIST="${CLEANED_WSMAN_LIST} ${WSMAN_PKG}"
   fi
done

WSMAN_PKGS=$CLEANED_WSMAN_LIST

if [ -n "$WSMAN_PKGS" ]; then
    rpm -e $WSMAN_PKGS --test >/dev/null 2>&1
    if [ $? == 0 ] ; then
       rpm -e $WSMAN_PKGS
    fi
fi

OM_RPMS=$(rpm -qa | egrep "^$DELL_OPENMANAGE_PREFIX")
if [ -z "$OM_RPMS" ]; then
    rm -f /etc/omreg.cfg
    rm -f /etc/delloma.d
    rm -f /etc/init.d/dsm_sa_ipmi  >/dev/null 2>&1
    find /opt/dell/srvadmin -type d -depth -exec rmdir {} \; >/dev/null  2>&1 ||:
fi
#delete the install log file
rm -f /opt/dell/srvadmin/var/log/omsa_install_ver_*.log

Zerion Mini Shell 1.0