#!/bin/ksh # # $Revision: 1.8 $ # $Date: 2006/11/09 05:14:47 $ # LANG=C export LANG if [ "$PKG_INSTALL_ROOT" = "/" ]; then PKG_INSTALL_ROOT="" fi # here have no good way to find it's upgrade install/remove or not, we just # assume it's upgrade. # below are two way may useful # 1) create an file in /tmp, then check it exist or not. # 2) check current package is the only one or not. UPGR_FLAG=/tmp/upgr.SUNWsscs if [ -f $UPGR_FLAG ]; then UPGRADE_INSTALL="true" else UPGRADE_INSTALL="false" fi rm -rf $UPGR_FLAG >/dev/null 2>&1 # stop console agent and dr, also remove user ssmon,ssadmin,ssconfig if [ "${PKG_INSTALL_ROOT:-/}" = "/" ]; then removeuser() { # removeuser will # First it can judge the user exist or not # Second it can remove the user. uname=$1; shift getent passwd $uname >/dev/null && { userdel $uname >/dev/null && { echo "User $uname has been removed!" } } } # stop agent if [ -f /etc/init.d/ssagent ]; then /etc/init.d/ssagent stop kindly || exit 1 fi # stop console cd ${PKG_INSTALL_ROOT}/opt/SUNWsscs/sscsconsole ./sscs stop # stop dr ssdgrptpop stop ssdgrptui stop ssdgrptd stop if [ "$UPGRADE_INSTALL" = "false" ]; then # it's full remove the pacakge. removeuser ssmon removeuser ssconfig removeuser ssadmin echo "" # disable all deamon since we want to remove the package. /etc/init.d/ssagent disable /etc/init.d/ssdgrptd disable fi fi # if it's upgrade install, we need not remove anything, just exist. if [ "$UPGRADE_INSTALL" = "true" ]; then exit 0 fi ## for console. # # Please modify the SAVE_FILE_LIST when you want to save other files. # SAVE_FILE_LIST="browser.default cfgsavset errlog.txt eventlog.txt svrlist.dat serial.txt" cd ${PKG_INSTALL_ROOT}/opt/SUNWsscs/sscsconsole tar cf sscscon.cfg.tar $SAVE_FILE_LIST >/dev/null 2>&1 if [ ! -d ${PKG_INSTALL_ROOT}/var/opt/SUNWsscs ]; then mkdir -p ${PKG_INSTALL_ROOT}/var/opt/SUNWsscs 2>&1 >/dev/null fi cp -f sscscon.cfg.tar ${PKG_INSTALL_ROOT}/var/opt/SUNWsscs/ >/dev/null 2>&1 rm -f sscscon.cfg.tar # remove any exist files to make pkgrm can remove the dir. rm -rf * ## for agent. # # Please modify the SAVE_FILE_LIST when you want to save other files. # SAVE_FILE_LIST="sstrapd.conf lunfilter.txt ssagent.cfg sscontlr.txt ssagent.spc" cd ${PKG_INSTALL_ROOT}/var/opt/SUNWsscs/ssagent tar cf ${PKG_INSTALL_ROOT}/tmp/sscsagt.cfg.tar $SAVE_FILE_LIST >/dev/null 2>&1 if [ ! -d ${PKG_INSTALL_ROOT}/var/opt/SUNWsscs ]; then mkdir -p ${PKG_INSTALL_ROOT}/var/opt/SUNWsscs 2>&1 >/dev/null fi cp -f ${PKG_INSTALL_ROOT}/tmp/sscsagt.cfg.tar ${PKG_INSTALL_ROOT}/var/opt/SUNWsscs/sscsagt.cfg.tar >/dev/null 2>&1 rm -f ${PKG_INSTALL_ROOT}/tmp/sscsagt.cfg.tar rm -rf ${PKG_INSTALL_ROOT}/var/opt/SUNWsscs/ssagent >/dev/null 2>&1 ## for dr ui # # Please modify the SAVE_FILE_LIST when you want to save other files. # SAVE_FILE_LIST="pop3.cfg svrlist.dat browser.default" cd ${PKG_INSTALL_ROOT}/opt/SUNWsscs/ssdiagreporterui tar cf ssdgrptui.cfg.tar $SAVE_FILE_LIST >/dev/null 2>&1 if [ ! -d ${PKG_INSTALL_ROOT}/var/opt/SUNWsscs ]; then mkdir -p ${PKG_INSTALL_ROOT}/var/opt/SUNWsscs 2>&1 >/dev/null fi cp -f ssdgrptui.cfg.tar ${PKG_INSTALL_ROOT}/var/opt/SUNWsscs/ >/dev/null 2>&1 rm -f ssdgrptui.cfg.tar rm -rf Mail* *.log *tmp* svrlist.* *.cfg browser.default >/dev/null 2>&1 ## for dr daemon # # Please modify the SAVE_FILE_LIST when you want to save other files. # may be we should not save errlog.txt,eventlog.txt and mailed.log. SAVE_FILE_LIST="errlog.txt eventlog.txt mailed.log ssdgrpt_cfg.xml ssdgrcli.cfg" cd ${PKG_INSTALL_ROOT}/opt/SUNWsscs/ssdiagreporterd tar cf ssdgrptd.cfg.tar $SAVE_FILE_LIST >/dev/null 2>&1 if [ ! -d ${PKG_INSTALL_ROOT}/var/opt/SUNWsscs ]; then mkdir -p ${PKG_INSTALL_ROOT}/var/opt/SUNWsscs 2>&1 >/dev/null fi cp -f ssdgrptd.cfg.tar ${PKG_INSTALL_ROOT}/var/opt/SUNWsscs/ >/dev/null 2>&1 rm -f ssdgrptd.cfg.tar rm -rf *.txt* *.log* *tmp* *xml *hel *HEL ssdgrcli.cfg >/dev/null 2>&1 exit 0