#!/bin/sh
# A major installer for all of GUARDIANSECURITY Ver. 1.2.09
# Copyright (c) 2008 Canon IT Solutions Inc.
#

# check shell and set PATH environment variable
#
umask 022
PATH=/bin:/usr/bin
export PATH || (echo "You must use sh to run this script"; kill $$)
if [ ! -t 0 ]; then
    echo "Say 'sh `basename $0`', not 'sh < `basename $0`'"
    exit 1
fi

# check a script path
#
case $0 in
inst|./inst)
    ;;
*)
    echo "Start this script from the 'release' directory using: 'sh inst'." 1>&2
    exit 1
    ;;
esac

SFBYS_OPT=""
while [ $# -ne 0 ]
do
    case $1 in
    '')
        break
        ;;
    '-w'|'--with-hidden')
        SFBYS_OPT=$1
        ;;
    *)
        true
        ;;
    esac
    shift
done

# hold original IFS
#
ORG_IFS="$IFS"

# import environment variables and script functions
#
. bin/.ImportEnv

# functions
#
get_field1()
{
    expr "$1" : '\([^,]*\)'
}

get_field2()
{
    expr "$1" : '[^,]*,\([^,]*\)'
}

get_field3()
{
    expr "$1" : '[^,]*,[^,]*,\([^,]*\)'
}

get_field4()
{
    expr "$1" : '[^,]*,[^,]*,[^,]*,\([^,]*\)'
}

v2i()
{
    echo "$1" | $AWK '{split($1, v, "[.-]"); printf("%02d%02d%02d%03d", v[1], v[2], v[3], v[4]);}'
}

# get_package_files pkgname [pkgfile]
get_package_files()
{
    if [ "$2" != "" ]; then
        INFO_OPT="-d $2"
    else
        INFO_OPT=""
    fi
    LANG=C pkginfo -l $INFO_OPT $1 | \
        sed -n '/^[ ]*FILES:[ ]*/{
            s///
            s/\([0-9]*\)[^0-9]*/\1/
            p
            q
            }'
}

# Install or Uninstall logging parameter
MEDIA_NAM=""
MEDIA_VER=""
MEDIA_PFM=""
MEDIA_DAT=""

# function of install logger
# gsigpkgif pkgname [pkgfile]
gsigpkgif()
{
    if [ "$2" != "" ]; then
        if [ ! -f "$2" ]; then
            return
        fi
        if [ ${UNAME} = "Linux" ]; then
            PKGPARAM="-p $2"
        else
            PKGPARAM="-d $2 $1"
        fi
    else
        PKGPARAM="$1"
    fi
    if [ ${UNAME} = "Linux" ]; then
        LPKGVER=`${PKG_VV} ${PKGPARAM} 2>/dev/null`
    else
        LPKGVER=`${PKG_VV} ${PKGPARAM} 2>/dev/null| sed -n -e '/^[ ]*VERSION:[ ]*/s///p'`
    fi
    if [ "X${LPKGVER}" = "X" ]; then
        return
    fi
    echo "$1,${LPKGVER}"
}

# gsilogger pkgname,version[:...] action(ADD|DEL)
gsilogger()
{
    LPKG=$1
    LACT=$2

    if [ ! -f ${MINFO} -o "X${LPKG}" = "X" -o "X${LACT}" = "X" ]; then
        return
    fi

    if [ "X${MEDIA_NAM}" = "X" ]; then
        MEDIA_NAM=`grep -i '^Name:' ${MINFO} |awk '{print $2}'`
        if [ "X${MEDIA_NAM}" = "X" ]; then
            return
        fi
    fi
    if [ "X${MEDIA_VER}" = "X" ]; then
        MEDIA_VER=`grep -i '^Version:' ${MINFO} |awk '{print $2}'`
        if [ "X${MEDIA_VER}" = "X" ]; then
            return
        fi
    fi
    if [ "X${MEDIA_PFM}" = "X" ]; then
        MEDIA_PFM=`grep -i '^Platform:' ${MINFO} |awk '{print $2}'`
        if [ "X${MEDIA_PFM}" = "X" ]; then
            return
        fi
    fi
    if [ "X${MEDIA_DAT}" = "X" ]; then
        MEDIA_DAT=`grep -i '^Date:' ${MINFO} |awk '{print $2}'`
        if [ "X${MEDIA_DAT}" = "X" ]; then
            return
        fi
    fi
    CURNT_DAT=`date '+%Y.%m.%d-%T'`

    IFS=:
    for f in ${LPKG}
    do
        IFS="$ORG_IFS"
        LOPKG_NAM=`get_field1 "$f"`
        LOPKG_VER=`get_field2 "$f"`
        echo "${CURNT_DAT}	(${LACT})	${LOPKG_NAM}	${LOPKG_VER}	${MEDIA_NAM}	${MEDIA_VER}	${MEDIA_PFM}	${MEDIA_DAT}" >>${GSROT}/.GSIHistory 2>/dev/null
    done
    IFS="$ORG_IFS"
}

# check uid
#
if (id | grep "uid=0(root)" >/dev/null 2>&1); then
    true
else
    echo "You need to login as root." 1>&2
    exit 1
fi

# ignore HUP CTRL-C and QUIT interrupts
#
trap "" 1 2 3 15

# initialize
tput init

# get ini files list
#
IF_LST=`bin/sfbys ${SFBYS_OPT} etc 2>/dev/null`
if [ $? -ne 0 ]; then
    echo "${SMSO}${EMG01}${RMSO}" 1>&2
    exit 1
fi

# This is the flag which shows whether installation was completed even once.
#
INSTALLED_FLAG=0

# main loop
#
while true
do
    ####################################################################
    #
    # Start of Menu section
    #  ${IF_LST} : List of included Installation Define File
    #
    ####################################################################
    # display banner
    #
    dpy_banner
    xy_cursor  ${XHM} ${YTW}

    # display products menu
    #
    NUM=1
    for f in ${IF_LST}
    do
        PR_NAM=`bin/parser -F $f -s COMMON -v NAME_${LNGAG} 2>&1`
        if [ $? -ne 0 ]; then
            PR_NAM=`bin/parser -F $f -s COMMON -v NAME 2>&1`
            if [ $? -ne 0 ]; then
                PR_NAM="Unknown Product"
            fi
        fi
        VR_NUM=`bin/parser -F $f -s COMMON -v VERSION 2>&1`
        if [ $? -ne 0 ]; then
            VR_NUM=""
        else
            VR_NUM="V${VR_NUM}"
        fi
        YPC=`expr ${YTW} + ${NUM} \* 2`
        xy_display ${XMN} ${YPC} "${NUM}.  ${SMUL}${PR_NAM} ${VR_NUM}${RMUL}"
        NUM=`expr ${NUM} + 1`
    done
    YPC=`expr ${YTW} + ${NUM} \* 2`
    xy_display ${XMN} ${YPC} "Q.  ${SMUL}${QTMSG}${RMUL}"

    # select a product
    #
    xy_status "${SMG01}"
    while true
    do
        xy_prompt
        read ANS
        case ${ANS} in
        ''|q|Q|quit|Quit|QUIT)
            if [ ${INSTALLED_FLAG} = 0 ]; then
                xy_warning "${EXMSG}"
            else
                xy_warning "${ETMSG}"
            fi
            xy_cursor ${XEX} ${YEX}
            exit 0
            ;;
        -)
            xy_warning "${WMG01}"
            ;;
        *)
            expr ${ANS} + 1 >/dev/null 2>&1
            if [ $? -eq 0 ]; then
                if [ `expr ${ANS}` -ge "1" -a `expr ${ANS}` -lt `expr ${NUM}` ]; then
                    xy_status "${ANS}${SMG02}"
                    break
                fi
            fi
            xy_warning "${WMG01}"
            ;;
        esac
    done

    # get ini file of selected product
    #
    set dammy ${IF_LST}
    shift ${ANS}
    IF_PRO="$1"
    if [ "X${IF_PRO}" = "X" ]; then
        xy_error "${EMG02}"
        exit 1
    fi

    # get product description
    #
    PR_DEC=`bin/parser -F ${IF_PRO} -s COMMON -v DESCRIPTION_${LNGAG} 2>&1`
    if [ $? -ne 0 ]; then
        PR_DEC="Unknown description..."
    fi

    # get product version
    #
    PR_VER=`bin/parser -F ${IF_PRO} -s COMMON -v VERSION 2>&1`
    if [ $? -ne 0 ]; then
        PR_VER="Unknown version"
    fi

    # get item list
    #
    IM_LST=`bin/parser -F ${IF_PRO} -s COMMON -v CONTENTS 2>&1`
    if [ $? -ne 0 ]; then
        xy_error "${EMG03}"
        exit 1
    fi

    # display contents menu
    #
    dpy_banner
    xy_display ${XTR} ${YTW} "${BOLD}${PR_DEC}${NRML}"
    NUM=1
    IFS=:
    for f in ${IM_LST}
    do
        IFS="$ORG_IFS"
        CO_DEC=`bin/parser -F ${IF_PRO} -s $f -v DESCRIPTION_${LNGAG} 2>&1`
        if [ $? -ne 0 ]; then
            CO_DEC="Unknown Content"
        fi
        YPC=`expr ${YTW} + ${NUM} \* 2`
        xy_display ${XMN} ${YPC} "${NUM}.  ${SMUL}${CO_DEC}${RMUL}"
        NUM=`expr ${NUM} + 1`
    done
    IFS="$ORG_IFS"
    YPC=`expr ${YTW} + ${NUM} \* 2`
    xy_display ${XMN} ${YPC} "B.  ${SMUL}${BKMSG}${RMUL}"

    # select a content
    #
    xy_status "${SMG03}"
    while true
    do
        xy_prompt
        read ANS
        case ${ANS} in
        ''|b|B|back|Back|BACK)
            ANS="B"
            break
            ;;
        -)
            xy_warning "${WMG01}"
            ;;
        *)
            expr ${ANS} + 1 >/dev/null 2>&1
            if [ $? -eq 0 ]; then
                if [ `expr ${ANS}` -ge "1" -a `expr ${ANS}` -lt `expr ${NUM}` ]; then
                    xy_status "${ANS}${SMG02}"
                    break
                fi
            fi
            xy_warning "${WMG01}"
            ;;
        esac
    done
    if [ "${ANS}" = "B" ]; then
        continue
    fi

    # get content section name
    #
    IFS=:
    set dammy ${IM_LST}
    shift ${ANS}
    IF_SEC="$1"
    IFS="$ORG_IFS"
    if [ "X${IF_SEC}" = "X" ]; then
        xy_error "${EMG04}"
        exit 1
    fi

    # get content description
    #
    CO_DEC=`bin/parser -F ${IF_PRO} -s ${IF_SEC} -v DESCRIPTION_${LNGAG} 2>&1`
    if [ $? -ne 0 ]; then
        CO_DEC="Unknown description..."
    fi
    INST_MODE=`bin/parser -F ${IF_PRO} -s ${IF_SEC} -v INST_MODE 2>&1`
    if [ ${INST_MODE} != 0 -a ${INST_MODE} != 1 -a ${INST_MODE} != 2 ]; then
        INST_MODE=1
    fi
    ####################################################################
    #
    # Start of System check section
    #  ${IF_PRO} : Installation Define File name
    #  ${PR_DEC} : Description of installation product
    #  ${IF_SEC} : Installed product section name
    #  ${CO_DEC} : Description of installation content
    #
    ####################################################################
    # set a installation mode and check system environments
    #
    dpy_banner
    xy_display ${XTR} ${YTW} "${BOLD}${CO_DEC}${NRML}"
    xy_status "${BOLD}${SMG04}${NRML}"

    # check platform and OS
    #
    PLATFORM=`bin/parser -F ${IF_PRO} -s ${IF_SEC} -v PLATFORM 2>&1`
    RES1=$?
    OS_TYPE=`bin/parser -F ${IF_PRO} -s ${IF_SEC} -v OS_TYPE 2>&1`
    RES2=$?
    OS_VERSION=`bin/parser -F ${IF_PRO} -s ${IF_SEC} -v OS_VERSION 2>&1`
    RES3=$?
    if [ ${RES1} -eq 0 -a ${RES2} -eq 0 -a ${RES3} -eq 0 ]; then
        NG=1
        THIS_PLATFORM=`${UNAMEP}`
        THIS_OS_TYPE=`${UNAMES}`
        THIS_OS_VERSION=`${UNAMER}`
        echo ${THIS_PLATFORM} | grep "^${PLATFORM}" >/dev/null 2>&1
        if [ $? -eq 0 -a "${OS_TYPE}" = "${THIS_OS_TYPE}" ]; then
            IFS=:
            for f in ${OS_VERSION}
            do
                echo ${THIS_OS_VERSION} | grep "^$f" >/dev/null 2>&1
                if [ $? -eq 0 ]; then
                    NG=0
                    break
                fi
            done
            IFS="$ORG_IFS"
        fi
        if [ ${NG} -eq 1 ]; then
            xy_display ${XTR} ${YTM} "${SMG05}${THIS_OS_TYPE} ${THIS_OS_VERSION} (${THIS_PLATFORM}) ${SMG06}"
            YYY=`expr ${YTM} + 1`
            xy_display ${XTR} ${YYY} "${SMG07}"
            NUM=1
            IFS=:
            for f in ${OS_VERSION}
            do
                IFS="$ORG_IFS"
                YYY=`expr ${YYY} + 1`
                xy_display ${XTL} ${YYY} "${NUM}. ${OS_TYPE} $f (${PLATFORM})"
                NUM=`expr ${NUM} + 1`
            done
            IFS="$ORG_IFS"
            xy_error "${EMG05}"
            pause
            continue
        fi
    fi

    # check the availability of same disks
    #
    MIN_DISKSP=`bin/parser -F ${IF_PRO} -s ${IF_SEC} -v MIN_DISKSP 2>&1`
    RES1=$?
    RCD_DISKSP=`bin/parser -F ${IF_PRO} -s ${IF_SEC} -v RCD_DISKSP 2>&1`
    RES2=$?
    DSC_DISKSP=`bin/parser -F ${IF_PRO} -s ${IF_SEC} -v DSC_DISKSP_${LNGAG} 2>&1`
    RES3=$?

    if [ ${RES1} -eq 0 ]; then
        xy_display ${XTL} ${YTM} "${SMUL}${SMG08}${RMUL}"
        XX1=`expr ${XTL} + 3`
        XX2=`expr ${XX1} + 25`

        IFS=:
        for f in ${MIN_DISKSP}
        do
            IFS="$ORG_IFS"
            DSK=`get_field1 "$f"`
            REQ=`get_field2 "$f"`
            if [ "X${DSK}" = "X" -o "X${REQ}" = "X" ]; then
                continue
            fi
            REALDSK="${DSK}"
            while [ "${REALDSK}" != "/" ]
            do
                if [ -d ${REALDSK} ]; then
                    break
                fi
                REALDSK=`dirname "${REALDSK}"`
            done
            YYY=`expr ${YTM} + 2`
            xy_display ${XX1} ${YYY} "${ELEL}${SMG09}"
            xy_display ${XX2} ${YYY} ": ${DSK}"
            YYY=`expr ${YYY} + 1`
            xy_display ${XX1} ${YYY} "${ELEL}${SMG10}"
            xy_display ${XX2} ${YYY} ": ${REQ}MB"

            IFS=:
            for g in ${RCD_DISKSP}
            do
                IFS="$ORG_IFS"
                R_DSK=`get_field1 "$g"`
                R_REQ=`get_field2 "$g"`
                if [ "${R_DSK}" != "${DSK}" -o "X${R_REQ}" = "X" ]; then
                    continue
                fi
                YYY=`expr ${YYY} + 1`
                xy_display ${XX1} ${YYY} "${ELEL}${SMG11}"
                xy_display ${XX2} ${YYY} ": ${R_REQ}MB"
                break
            done
            IFS="$ORG_IFS"
            if [ -x ${SUPPORT} ]; then
                AVA=`${SUPPORT} -f ${REALDSK} 2>/dev/null`
            elif [ ${UNAME} = "Linux" ]; then
                AVA=`df -mP ${REALDSK} | awk '{if (NR == 2) printf("%d\n", $4)}'`
            else
                AVA=`df -b ${REALDSK} | awk '{if (NR == 2) printf("%d\n", $2 / 1024)}'`
            fi
            YYY=`expr ${YYY} + 1`
            xy_display ${XX1} ${YYY} "${ELEL}${SMG12}"
            xy_display ${XX2} ${YYY} ": ${AVA}MB"

            IFS=:
            for g in ${DSC_DISKSP}
            do
                IFS="$ORG_IFS"
                D_DSK=`get_field1 "$g"`
                D_COM=`get_field2 "$g"`
                if [ "${D_DSK}" != "${DSK}" -o "X${D_COM}" = "X" ]; then
                    continue
                fi
                YYY=`expr ${YYY} + 2`
                xy_display ${XX1} ${YYY} "${ELEL}${D_COM}"
                break
            done
            IFS="$ORG_IFS"

            while [ ${YYY} -lt 14 ]
            do
                YYY=`expr ${YYY} + 1`
                xy_display ${XX1} ${YYY} "${ELEL}"
            done
            if get_yes_no "${CNTMG}" ; then
                if [ ${AVA} -lt ${REQ} ]; then
                    xy_error "${EMG06}"
                    exit 1
                fi
            else
                if [ ${INST_MODE} -ne 0 ]; then
                    xy_warning "${EXMSG}"
                else
                    xy_warning "${UXMSG}"
                fi
                xy_cursor ${XEX} ${YEX}
                exit 0
            fi
        done
        IFS="$ORG_IFS"

        YYY=`expr ${YTM} - 1`
        while [ ${YYY} -lt 14 ]
        do
            YYY=`expr ${YYY} + 1`
            xy_display ${XTL} ${YYY} "${ELEL}"
        done
        xy_status "${BOLD}${SMG04}${NRML}"
        xy_prompt ""
    fi

    # check existence of required packages.
    #
    NED_PACKAGE=`bin/parser -F ${IF_PRO} -s ${IF_SEC} -v NED_PACKAGE 2>&1`
    if [ $? -eq 0 ]; then
        IFS=:
        for f in ${NED_PACKAGE}
        do
            IFS="$ORG_IFS"
            PKG=`get_field1 "$f"`
            ACT=`get_field2 "$f"`
            if [ "X${PKG}" = "X" -o "X${ACT}" = "X" ]; then
                continue
            fi
            ${PKG_IF} ${PKG} >/dev/null 2>&1
            if [ $? -ne 0 ]; then
                case ${ACT} in
                ERR|Err|err)
                    xy_error "${EMG14}<${PKG}>"
                    exit 1
                    ;;
                WNG|Wng|wng)
                    xy_warning "${WMG06}<${PKG}> ${CTMSG}"
                    sleep 3
                    ;;
                *)
                    continue
                    ;;
                esac
            fi
        done
        IFS="$ORG_IFS"
    fi

    # check existence of unneccessary packages.
    #
    UND_PACKAGE=`bin/parser -F ${IF_PRO} -s ${IF_SEC} -v UND_PACKAGE 2>&1`
    if [ $? -eq 0 ]; then
        IFS=:
        for f in ${UND_PACKAGE}
        do
            IFS="$ORG_IFS"
            PKG=`get_field1 "$f"`
            ACT=`get_field2 "$f"`
            if [ "X${PKG}" = "X" -o "X${ACT}" = "X" ]; then
                continue
            fi
            ${PKG_IF} ${PKG} >/dev/null 2>&1
            if [ $? -eq 0 ]; then
                case ${ACT} in
                DEL|Del|del)
                    ${PKG_RM} ${PKG} >/dev/null 2>&1
                    ;;
                CDL|Cdl|cdl)
                    if get_yes_no "<${PKG}> ${DELMG}" ; then
                        ${PKG_RM} ${PKG} >/dev/null 2>&1
                    else
                        if [ ${INST_MODE} -ne 0 ]; then
                            xy_warning "${EXMSG}"
                        else
                            xy_warning "${UXMSG}"
                        fi
                        xy_cursor ${XEX} ${YEX}
                        exit 0
                    fi
                    ;;
                ERR|Err|err)
                    xy_error "${EMG15}<${PKG}>"
                    exit 1
                    ;;
                WNG|Wng|wng)
                    xy_warning "${WMG07}<${PKG}> ${CTMSG}"
                    sleep 3
                    ;;
                *)
                    if [ ${UNAME} = "Linux" ]; then
                        CUR_VER=`${PKG_VV} ${PKG}`
                    else
                        CUR_VER=`${PKG_VV} ${PKG} | sed -n -e '/^[ ]*VERSION:[ ]*/s///p'`
                    fi
                    INTRVER=`v2i ${ACT}`
                    INTCVER=`v2i ${CUR_VER}`
                    if [ $INTCVER -ge $INTRVER ]; then
                        continue
                    fi
                    xy_error "${EMG23}<${PKG} ${CUR_VER}>"
                    exit 1
                    ;;
                esac
            fi
        done
        IFS="$ORG_IFS"
    fi

    # check existence of required files.
    #
    NED_FILE=`bin/parser -F ${IF_PRO} -s ${IF_SEC} -v NED_FILE 2>&1`
    if [ $? -eq 0 ]; then
        IFS=:
        for f in ${NED_FILE}
        do
            IFS="$ORG_IFS"
            FIL=`get_field1 "$f"`
            TYP=`get_field2 "$f"`
            ACT=`get_field3 "$f"`
            if [ "X${FIL}" = "X" -o "X${TYP}" = "X" -o "X${ACT}" = "X" ]; then
                continue
            fi
            if [ -${TYP} ${FIL} ]; then
                continue
            else
                case ${ACT} in
                CRE|Cre|cre)
                    if [ ${TYP} = "d" ]; then
                        mkdir -p ${FIL} >/dev/null 2>&1
                        if [ $? -ne 0 ]; then
                            xy_error "${EMG07}<${FIL}>"
                            exit 1
                        fi
                    else
                        CFLG=0
                        if [ ! -f ${FIL} ]; then
                            touch ${FIL} >/dev/null 2>&1
                            if [ $? -ne 0 ]; then
                                xy_error "${EMG08}<${FIL}>"
                                exit 1
                            fi
                            CFLG=1
                        fi
                        case ${TYP} in
                        r)
                            chmod +r ${FIL} >/dev/null 2>&1
                            ;;
                        w)
                            chmod +w ${FIL} >/dev/null 2>&1
                            ;;
                        u)
                            chmod +xs ${FIL} >/dev/null 2>&1
                            ;;
                        x)
                            chmod +x ${FIL} >/dev/null 2>&1
                            ;;
                        *)
                            continue
                            ;;
                        esac
                        if [ $? -ne 0 ]; then
                            xy_error "${EMG09}<${FIL}>"
                            if [ ${CFLG} -eq 1 ]; then
                                rm -f ${FIL} >/dev/null 2>&1
                            fi
                            exit 1
                        fi
                    fi
                    ;;
                CCR|Ccr|ccr)
                    if get_yes_no "<${FIL}> ${CRTMG}" ; then
                        true
                    else
                        if [ ${INST_MODE} -ne 0 ]; then
                            xy_warning "${EXMSG}"
                        else
                            xy_warning "${UXMSG}"
                        fi
                        xy_cursor ${XEX} ${YEX}
                        exit 0
                    fi
                    if [ ${TYP} = "d" ]; then
                        mkdir -p ${FIL} >/dev/null 2>&1
                        if [ $? -ne 0 ]; then
                            xy_error "${EMG07}<${FIL}>"
                            exit 1
                        fi
                    else
                        CFLG=0
                        if [ ! -f ${FIL} ]; then
                            touch ${FIL} >/dev/null 2>&1
                            if [ $? -ne 0 ]; then
                                xy_error "${EMG08}<${FIL}>"
                                exit 1
                            fi
                            CFLG=1
                        fi
                        case ${TYP} in
                        r)
                            chmod +r ${FIL} >/dev/null 2>&1
                            ;;
                        w)
                            chmod +w ${FIL} >/dev/null 2>&1
                            ;;
                        u)
                            chmod +xs ${FIL} >/dev/null 2>&1
                            ;;
                        x)
                            chmod +x ${FIL} >/dev/null 2>&1
                            ;;
                        *)
                            continue
                            ;;
                        esac
                        if [ $? -ne 0 ]; then
                            xy_error "${EMG09}<${FIL}>"
                            if [ ${CFLG} -eq 1 ]; then
                                rm -f ${FIL} >/dev/null 2>&1
                            fi
                            exit 1
                        fi
                    fi
                    ;;
                ERR|Err|err)
                    if [ ${TYP} = "d" -a -f ${FIL} ]; then
                        xy_error "${EMG10}<${FIL}>"
                    elif [ -f ${FIL} ]; then
                        xy_error "${EMG11}<${FIL}>"
                    else
                        xy_error "${EMG12}<${FIL}>"
                    fi
                    exit 1
                    ;;
                WNG|Wng|wng)
                    if [ ${TYP} = "d" -a -f ${FIL} ]; then
                        xy_warning "${WMG02}<${FIL}> ${CTMSG}"
                    elif [ -f ${FIL} ]; then
                        xy_warning "${WMG03}<${FIL}> ${CTMSG}"
                    else
                        xy_warning "${WMG04}<${FIL}> ${CTMSG}"
                    fi
                    sleep 3
                    ;;
                *)
                    continue
                    ;;
                esac
            fi
        done
        IFS="$ORG_IFS"
    fi

    # check existence of unneccessary files.
    #
    UND_FILE=`bin/parser -F ${IF_PRO} -s ${IF_SEC} -v UND_FILE 2>&1`
    if [ $? -eq 0 ]; then
        IFS=:
        for f in ${UND_FILE}
        do
            IFS="$ORG_IFS"
            FIL=`get_field1 "$f"`
            TYP=`get_field2 "$f"`
            ACT=`get_field3 "$f"`
            if [ "X${FIL}" = "X" -o "X${TYP}" = "X" -o "X${ACT}" = "X" ]; then
                continue
            fi
            if [ -${TYP} ${FIL} ]; then
                case ${ACT} in
                DEL|Del|del)
                    rm -rf ${FIL} >/dev/null 2>&1
                    ;;
                CDL|Cdl|cdl)
                    if get_yes_no "<${FIL}> ${DELMG}" ; then
                        rm -rf ${FIL} >/dev/null 2>&1
                    else
                        if [ ${INST_MODE} -ne 0 ]; then
                            xy_warning "${EXMSG}"
                        else
                            xy_warning "${UXMSG}"
                        fi
                        xy_cursor ${XEX} ${YEX}
                        exit 0
                    fi
                    ;;
                UPD|Upd|upd)
                    continue
                    ;;
                CUP|Cup|cup)
                    if get_yes_no "<${FIL}> ${UPDMG}" ; then
                        continue
                    else
                        if [ ${INST_MODE} -ne 0 ]; then
                            xy_warning "${EXMSG}"
                        else
                            xy_warning "${UXMSG}"
                        fi
                        xy_cursor ${XEX} ${YEX}
                        exit 0
                    fi
                    ;;
                ERR|Err|err)
                    xy_error "${EMG13}<${FIL}>"
                    exit 1
                    ;;
                WNG|Wng|wng)
                    xy_warning "${WMG05}<${FIL}> ${CTMSG}"
                    sleep 3
                    ;;
                *)
                    continue
                    ;;
                esac
            else
                continue
            fi
        done
        IFS="$ORG_IFS"
    fi

    ####################################################################
    #
    # Confirm Install / Uninstall packages
    #  ${IF_PRO} : Installation Define File name
    #  ${IF_SEC} : Installed product section name
    #  ${CO_DEC} : Description of installation content
    #
    ####################################################################
    # get removed package names and added package names
    #
    dpy_banner
    xy_display ${XTR} ${YTW} "${BOLD}${CO_DEC}${NRML}"
    YYY=`expr ${YTW} + 2`
    UINST_PKG=`bin/parser -F ${IF_PRO} -s ${IF_SEC} -v UINST_PKG 2>&1`
    RES_RM=$?
    INST_PKG=`bin/parser -F ${IF_PRO} -s ${IF_SEC} -v INST_PKG 2>&1`
    RES_AD=$?
    CHECK_PKG=`bin/parser -F ${IF_PRO} -s ${IF_SEC} -v CHECK_PKG 2>&1`
    RES_CK=$?
    if [ $RES_RM -eq 0 -a $RES_AD -eq 0 ]; then
        if [ ${INST_MODE} -eq 1 ]; then
            xy_display ${XTL} ${YYY} "${SMG17}"
        else
            xy_display ${XTL} ${YYY} "${SMG18}"
        fi
        YYY=`expr ${YYY} + 1`
        SV_YYY=${YYY}
        IFS=:
        for f in ${INST_PKG}
        do
            IFS="$ORG_IFS"
            FIL="${PKGS}/`get_field1 "$f"`"
            PKG=`get_field2 "$f"`
            if [ -f ${FIL} ]; then
                if [ ${UNAME} = "Linux" ]; then
                    PKGINFO=`${PKG_SV} -p ${FIL}`
                else
                    PKGINFO=`${PKG_SV} -d ${FIL} ${PKG} | sed -n -e '/^[ ]*NAME:[ ]*/s///p' -e '/^[ ]*VERSION:[ ]*/s///p'`
                fi
                PKG_NAME=`echo "$PKGINFO" | sed -n '1p'`
                PKG_VERS=`echo "$PKGINFO" | sed -n '2p'`
                PKG_EXTS=0
                IFS=:
                for ff in ${UINST_PKG}
                do
                    IFS="$ORG_IFS"
                    DEL_PKG=`get_field1 "$ff"`
                    if [ ${PKG} != ${DEL_PKG} ]; then
                        continue
                    fi
                    PKG_EXTS=1
                    ${PKG_IF} ${DEL_PKG} >/dev/null 2>&1
                    if [ $? -ne 0 ]; then
                        continue
                    fi
                    DEL_VER=`get_field2 "$ff"`
                    case ${DEL_VER} in
                    ''|IGN|Ign|ign|CHK|Chk|chk|ERR|Err|err)
                        ;;
                    *)
                        if [ ${UNAME} = "Linux" ]; then
                            CUR_VER=`${PKG_VV} ${DEL_PKG}`
                        else
                            CUR_VER=`${PKG_VV} ${DEL_PKG} | sed -n -e '/^[ ]*VERSION:[ ]*/s///p'`
                        fi
                        INTRVER=`v2i ${DEL_VER}`
                        INTCVER=`v2i ${CUR_VER}`
                        if [ $INTCVER -ge $INTRVER ]; then
                            continue 2
                        fi
                        break
                        ;;
                    esac
                done
                IFS="$ORG_IFS"
                if [ ${PKG_EXTS} -eq 0 ]; then
                    ${PKG_IF} ${PKG} >/dev/null 2>&1
                    if [ $? -eq 0 ]; then
                        continue
                    fi
                fi
                xy_display `expr ${XTL} + 3`  ${YYY} "${PKG}"
                xy_display `expr ${XTL} + 21` ${YYY} ": ${PKG_NAME} V${PKG_VERS}"
                YYY=`expr ${YYY} + 1`
            fi
        done
        IFS="$ORG_IFS"
        if [ ${SV_YYY} -eq ${YYY} ]; then
            xy_display `expr ${XTL} + 3`  ${YYY} "${SMG19}"
            xy_warning "${EXMSG}"
            xy_homecsor
            exit 0
        fi
    elif [ $RES_RM -eq 0 ]; then
        xy_display ${XTL} ${YYY} "${SMG16}"
        YYY=`expr ${YYY} + 1`
        SV_YYY=${YYY}
        IFS=:
        for f in ${UINST_PKG}
        do
            IFS="$ORG_IFS"
            PKG=`get_field1 "$f"`
            ACT=`get_field2 "$f"`
            WET=`get_field3 "$f"`
            case ${ACT} in
            IGN|Ign|ign)
                ${PKG_IF} ${PKG} >/dev/null 2>&1
                if [ $? -ne 0 ]; then
                    continue
                fi
                ;;
            CHK|Chk|chk)
                ${PKG_IF} ${PKG} >/dev/null 2>&1
                if [ $? -ne 0 ]; then
                    continue
                fi
                if [ $RES_CK -eq 0 ]; then
                    IFS=:
                    for ff in ${CHECK_PKG}
                    do
                        IFS="$ORG_IFS"
                        CKPKG=`get_field1 "$ff"`
                        CKVER=`get_field2 "$ff"`
                        CKWET=`get_field3 "$ff"`
                        if [ "X${WET}" != "X" -a "X${CKWET}" != "X" ] && [ "${WET}" -gt "${CKWET}" ]; then
                            continue
                        fi
                        ${PKG_IF} ${CKPKG} >/dev/null 2>&1
                        if [ $? -ne 0 ]; then
                            continue
                        fi
                        if [ ${UNAME} = "Linux" ]; then
                            CUR_VER=`${PKG_VV} ${CKPKG}`
                        else
                            CUR_VER=`${PKG_VV} ${CKPKG} | sed -n -e '/^[ ]*VERSION:[ ]*/s///p'`
                        fi
                        INTRVER=`v2i ${CKVER}`
                        INTCVER=`v2i ${CUR_VER}`
                        if [ $INTCVER -ge $INTRVER ]; then
                            continue 2
                        fi
                    done
                    IFS="$ORG_IFS"
                fi
                ;;
            *)
                ;;
            esac
            if [ ${UNAME} = "Linux" ]; then
                PKGINFO=`${PKG_SV} ${PKG}`
            else
                PKGINFO=`${PKG_SV} ${PKG} | sed -n -e '/^[ ]*NAME:[ ]*/s///p' -e '/^[ ]*VERSION:[ ]*/s///p'`
            fi
            PKG_NAME=`echo "$PKGINFO" | sed -n '1p'`
            PKG_VERS=`echo "$PKGINFO" | sed -n '2p'`
            xy_display `expr ${XTL} + 3`  ${YYY} "${PKG}"
            xy_display `expr ${XTL} + 21` ${YYY} ": ${PKG_NAME} V${PKG_VERS}"
            YYY=`expr ${YYY} + 1`
        done
        IFS="$ORG_IFS"
        if [ ${SV_YYY} -eq ${YYY} ]; then
            xy_display `expr ${XTL} + 3`  ${YYY} "${SMG20}"
            xy_warning "${UXMSG}"
            xy_homecsor
            exit 0
        fi
    elif [ $RES_AD -eq 0 ]; then
        xy_display ${XTL} ${YYY} "${SMG17}"
        YYY=`expr ${YYY} + 1`
        SV_YYY=${YYY}
        IFS=:
        for f in ${INST_PKG}
        do
            IFS="$ORG_IFS"
            FIL="${PKGS}/`get_field1 "$f"`"
            PKG=`get_field2 "$f"`
            ${PKG_IF} ${PKG} >/dev/null 2>&1
            if [ $? -eq 0 ]; then
                continue
            fi
            if [ -f ${FIL} ]; then
                if [ ${UNAME} = "Linux" ]; then
                    PKGINFO=`${PKG_SV} -p ${FIL}`
                else
                    PKGINFO=`${PKG_SV} -d ${FIL} ${PKG} | sed -n -e '/^[ ]*NAME:[ ]*/s///p' -e '/^[ ]*VERSION:[ ]*/s///p'`
                fi
                PKG_NAME=`echo "$PKGINFO" | sed -n '1p'`
                PKG_VERS=`echo "$PKGINFO" | sed -n '2p'`
                xy_display `expr ${XTL} + 3`  ${YYY} "${PKG}"
                xy_display `expr ${XTL} + 21` ${YYY} ": ${PKG_NAME} V${PKG_VERS}"
                YYY=`expr ${YYY} + 1`
            fi
        done
        IFS="$ORG_IFS"
        if [ ${SV_YYY} -eq ${YYY} ]; then
            xy_display `expr ${XTL} + 3`  ${YYY} "${SMG21}"
            xy_warning "${EXMSG}"
            xy_homecsor
            exit 0
        fi
    else
        xy_display `expr ${XTL} + 3`  ${YYY} "${SMG22}"
        xy_warning "${EXMSG}"
        xy_homecsor
        exit 0
    fi
    BASE_DIR=`bin/parser -F ${IF_PRO} -s ${IF_SEC} -v BASE_DIR 2>&1`
    if [ $? -eq 0 ]; then
        YYY=`expr ${YYY} + 1`
        IFS=:
        for f in ${BASE_DIR}
        do
            IFS="$ORG_IFS"
            NDIRS=`get_field1 "$f"`
            PKG=`get_field2 "$f"`
            if [ "X${PKG}" != "X" ]; then
                ${PKG_IF} ${PKG} >/dev/null 2>&1
                if [ $? -eq 0 ]; then
                    continue
                fi
            fi
            if [ "X${NDIRS}" = "X" ]; then
                continue
            fi
            if [ -d "${NDIRS}" ]; then
                xy_display ${XTL} ${YYY} "${WMG09} ${NDIRS} ${WMG10}"
                YYY=`expr ${YYY} + 1`
                xy_display ${XTL} ${YYY} "${WMG11}"
                YYY=`expr ${YYY} + 1`
            fi
            while [ "${NDIRS}" != "/" ]
            do
                if [ -h "${NDIRS}" ]; then
                    xy_display ${XTL} ${YYY} "${WMG09} ${NDIRS} ${WMG12}"
                    YYY=`expr ${YYY} + 1`
                    xy_display ${XTL} ${YYY} "${WMG13}"
                    YYY=`expr ${YYY} + 1`
                fi
                NDIRS=`dirname "$NDIRS"`
            done
        done
        IFS="$ORG_IFS"
    fi
    if confirm_inst ${INST_MODE} ; then
        true
    else
        sleep 3
        continue
    fi

    ####################################################################
    #
    # Import script files (if it exists)
    #  ${IF_PRO} : Installation Define File name
    #  ${IF_SEC} : Installed product section name
    #
    ####################################################################
    # get script files and import them
    #
    IMPORTFILE=`bin/parser -F ${IF_PRO} -s ${IF_SEC} -v IMPORTFILE 2>&1`
    if [ $? -eq 0 ]; then
        IFS=:
        for f in ${IMPORTFILE}
        do
            IFS="$ORG_IFS"
            if [ -f "bin/$f" ]; then
                . "bin/$f"
            fi
        done
        IFS="$ORG_IFS"
    fi

    ####################################################################
    #
    # The shell functions and command which are executed before a 
    # package is installed
    #  ${IF_PRO} : Installation Define File name
    #  ${IF_SEC} : Installed product section name
    #  ${CO_DEC} : Description of installation content
    #
    ####################################################################
    # get shell functions and call them
    #
    BE_CALLFUNC=`bin/parser -F ${IF_PRO} -s ${IF_SEC} -v BE_CALLFUNC 2>&1`
    if [ $? -eq 0 ]; then
        dpy_banner
        xy_display ${XTR} ${YTW} "${BOLD}${CO_DEC}${NRML}"
        call_functions "${BE_CALLFUNC}"
        case $? in
        0)
            true
            ;;
        1)
            if [ ${INST_MODE} -ne 0 ]; then
                xy_error "${EMG97}"
            else
                xy_error "${EMG99}"
            fi
            exit 1
            ;;
        2)
            if [ ${INST_MODE} -ne 0 ]; then
                xy_error "${EXMSG}"
            else
                xy_error "${UXMSG}"
            fi
            exit 1
            ;;
        *)
            if [ ${INST_MODE} -ne 0 ]; then
                xy_error "${EMG97}"
            else
                xy_error "${EMG99}"
            fi
            exit 1
            ;;
        esac
    fi

    # get commands and execute them
    #
    BE_EXECCMD=`bin/parser -F ${IF_PRO} -s ${IF_SEC} -v BE_EXECCMD 2>&1`
    if [ $? -eq 0 ]; then
        exec_commands "${BE_EXECCMD}"
        case $? in
        0)
            true
            ;;
        1)
            if [ ${INST_MODE} -ne 0 ]; then
                xy_error "${EMG97}"
            else
                xy_error "${EMG99}"
            fi
            exit 1
            ;;
        2)
            if [ ${INST_MODE} -ne 0 ]; then
                xy_error "${EXMSG}"
            else
                xy_error "${UXMSG}"
            fi
            exit 1
            ;;
        *)
            if [ ${INST_MODE} -ne 0 ]; then
                xy_error "${EMG97}"
            else
                xy_error "${EMG99}"
            fi
            exit 1
            ;;
        esac
    fi

    ####################################################################
    #
    # Install(pkgadd) / Uninstall(pkgrm) the packages
    #  ${CO_DEC} : Description of installation content
    #
    ####################################################################
    # remove packages
    #
    if [ $RES_RM -eq 0 ]; then
        dpy_banner
        xy_display ${XTR} ${YTW} "${BOLD}${CO_DEC}${NRML}"
        OUTFILE="/tmp/_inst_pipe.$$"
        mkfifo "$OUTFILE"
        ALLRM="1"
        IFS=:
        for f in ${UINST_PKG}
        do
            IFS="$ORG_IFS"
            PKG=`get_field1 "$f"`
            ACT=`get_field2 "$f"`
            WET=`get_field3 "$f"`
            case ${ACT} in
            IGN|Ign|ign)
                ${PKG_IF} ${PKG} >/dev/null 2>&1
                if [ $? -ne 0 ]; then
                    continue
                fi
                ;;
            CHK|Chk|chk)
                ${PKG_IF} ${PKG} >/dev/null 2>&1
                if [ $? -ne 0 ]; then
                    continue
                fi
                if [ $RES_CK -eq 0 ]; then
                    IFS=:
                    for ff in ${CHECK_PKG}
                    do
                        IFS="$ORG_IFS"
                        CKPKG=`get_field1 "$ff"`
                        CKVER=`get_field2 "$ff"`
                        CKWET=`get_field3 "$ff"`
                        CKIGN=`get_field4 "$ff"`
                        if [ "X${WET}" != "X" -a "X${CKWET}" != "X" ] && [ "${WET}" -gt "${CKWET}" ]; then
                            continue
                        fi
                        ${PKG_IF} ${CKPKG} >/dev/null 2>&1
                        if [ $? -ne 0 ]; then
                            continue
                        fi
                        if [ ${UNAME} = "Linux" ]; then
                            CUR_VER=`${PKG_VV} ${CKPKG}`
                        else
                            CUR_VER=`${PKG_VV} ${CKPKG} | sed -n -e '/^[ ]*VERSION:[ ]*/s///p'`
                        fi
                        INTRVER=`v2i ${CKVER}`
                        INTCVER=`v2i ${CUR_VER}`
                        if [ $INTCVER -ge $INTRVER ]; then
                            if [ "${CKIGN}" != "EP" ]; then
                                ALLRM="0"
                            fi
                            continue 2
                        fi
                    done
                    IFS="$ORG_IFS"
                fi
                ;;
            '')
                ;;
            *)
                if [ ${INST_MODE} -ne 0 ]; then
                    ${PKG_IF} ${PKG} >/dev/null 2>&1
                    if [ $? -ne 0 ]; then
                        continue
                    fi
                    if [ ${UNAME} = "Linux" ]; then
                        CUR_VER=`${PKG_VV} ${PKG}`
                    else
                        CUR_VER=`${PKG_VV} ${PKG} | sed -n -e '/^[ ]*VERSION:[ ]*/s///p'`
                    fi
                    INTRVER=`v2i ${ACT}`
                    INTCVER=`v2i ${CUR_VER}`
                    if [ $INTCVER -ge $INTRVER ]; then
                        ALLRM="0"
                        continue
                    fi
                fi
                ;;
            esac
            if [ ${UNAME} = "Linux" ]; then
                LNM=`${PKG_IF}l $PKG | wc -l`
            else
                LNM=`get_package_files $PKG`
                LNM=`expr $LNM + 10`
            fi
            PNV=`gsigpkgif ${PKG}`
            xy_status "${BOLD}${SMG13}<${PKG}>${SMG14}${NRML}"
            bin/statdpy ${LNM} ${OUTFILE} 2>/dev/null &
            SPID=$!
            if [ ${UNAME} = "Linux" ]; then
                ${PKG_RM} -vv ${PKG} 2>&1 | grep -E "^D:[  ]*fi(ni|le)" >${OUTFILE}
                RC=$?
                wait ${SPID}
                if [ $RC -eq 0 ]; then
                    true
                else
                    xy_error "${EMG16}"
                    sleep 3
                    xy_error "${EMG17}$RC${EMG18}"
                    rm -f ${OUTFILE} >/dev/null 2>&1
                    exit 1
                fi
            else
                echo "y" | /usr/sbin/pkgrm -a ${NOCHK} ${PKG} >/dev/null 2>${OUTFILE}
                RC=$?
                wait ${SPID}
                if [ $RC -eq 0 ]; then
                    true
                elif [ $RC -eq 2 ]; then
                    xy_warning "${WMG08}"
                    if [ -d /var/sadm/pkg/${PKG} ]; then
                        rm -rf /var/sadm/pkg/${PKG} >/dev/null 2>&1
                    fi
                    sleep 3
                else
                    xy_error "${EMG16}"
                    sleep 3
                    if [ $RC -eq 1 ]; then
                        xy_error "${EMG17}$RC${EMG18} ${EMG19}"
                    else
                        xy_error "${EMG17}$RC${EMG18}"
                    fi
                    rm -f ${OUTFILE} >/dev/null 2>&1
                    exit 1
                fi
            fi
            gsilogger "${PNV}" "DEL"
        done
        IFS="$ORG_IFS"
        rm -f ${OUTFILE} >/dev/null 2>&1
    fi

    # install packages
    #
    if [ $RES_AD -eq 0 ]; then
        dpy_banner
        xy_display ${XTR} ${YTW} "${BOLD}${CO_DEC}${NRML}"
        if [ ${UNAME} = "Linux" ]; then
            OUTFILE="/tmp/_inst_error.$$"
            PACKAGES=""
            PNV=""
            IFS=:
            for f in ${INST_PKG}
            do
                IFS="$ORG_IFS"
                FIL="${PKGS}/`get_field1 "$f"`"
                PKG=`get_field2 "$f"`
                ${PKG_IF} ${PKG} >/dev/null 2>&1
                if [ $? -eq 0 ]; then
                    continue
                fi
                if [ -f ${FIL} ]; then
                    PACKAGES="${PACKAGES} ${FIL}"
                    if [ "X${PNV}" = "X" ]; then
                        PNV=`gsigpkgif ${PKG} ${FIL}`
                    else
                        TMPNV=`gsigpkgif ${PKG} ${FIL}`
                        if [ "X${TMPNV}" != "X" ]; then
                            PNV="${PNV}:${TMPNV}"
                        fi
                    fi
                fi
            done
            IFS="$ORG_IFS"
            xy_status "${BOLD}${SMG13}${SMG15}${NRML}"
            xy_cursor  ${XEX} ${YTM}
            rpm -ivh --nodeps --force${PACKAGES} 2>${OUTFILE}
            if [ $? -eq 0 ]; then
                rm -f ${OUTFILE} >/dev/null 2>&1
                gsilogger "${PNV}" "ADD"
            else
                xy_error "${EMG20}"
                sleep 3
                xy_error "${EMG21}${OUTFILE}${EMG22}"
                exit 1
            fi
        else
            OUTFILE="/tmp/_inst_pipe.$$"
            mkfifo "$OUTFILE"
            IFS=:
            for f in ${INST_PKG}
            do
                IFS="$ORG_IFS"
                FIL="${PKGS}/`get_field1 "$f"`"
                PKG=`get_field2 "$f"`
                ${PKG_IF} ${PKG} >/dev/null 2>&1
                if [ $? -eq 0 ]; then
                    continue
                fi
                LNM=`get_package_files $PKG $FIL`
                LNM=`expr $LNM + 10`
                PNV=`gsigpkgif ${PKG} ${FIL}`
                if [ -f ${FIL} ]; then
                    xy_status "${BOLD}${SMG13}<${PKG}>${SMG15}${NRML}"
                    bin/statdpy ${LNM} ${OUTFILE} 2>/dev/null &
                    SPID=$!
                    /usr/sbin/pkgadd -a ${NOCHK} -d ${FIL} ${PKG} >/dev/null 2>${OUTFILE}
                    wait ${SPID}
                    gsilogger "${PNV}" "ADD"
                fi
            done
            IFS="$ORG_IFS"
            rm -f ${OUTFILE} >/dev/null 2>&1
        fi
    fi

    ####################################################################
    #
    # The shell functions and command which are executed after a 
    # package is installed
    #  ${IF_PRO} : Installation Define File name
    #  ${IF_SEC} : Installed product section name
    #  ${CO_DEC} : Description of installation content
    #
    ####################################################################
    # get shell functions and call them
    #
    AF_CALLFUNC=`bin/parser -F ${IF_PRO} -s ${IF_SEC} -v AF_CALLFUNC 2>&1`
    if [ $? -eq 0 ]; then
        dpy_banner
        xy_display ${XTR} ${YTW} "${BOLD}${CO_DEC}${NRML}"
        call_functions "${AF_CALLFUNC}"
        case $? in
        0)
            true
            ;;
        1)
            if [ ${INST_MODE} -ne 0 ]; then
                xy_error "${EMG96}"
            else
                xy_error "${EMG98}"
            fi
            exit 1
            ;;
        2)
            if [ ${INST_MODE} -ne 0 ]; then
                xy_error "${EXMSG}"
            else
                xy_error "${UXMSG}"
            fi
            exit 1
            ;;
        *)
            if [ ${INST_MODE} -ne 0 ]; then
                xy_error "${EMG96}"
            else
                xy_error "${EMG98}"
            fi
            exit 1
            ;;
        esac
    fi

    # get commands and execute them
    #
    AF_EXECCMD=`bin/parser -F ${IF_PRO} -s ${IF_SEC} -v AF_EXECCMD 2>&1`
    if [ $? -eq 0 ]; then
        exec_commands "${AF_EXECCMD}"
        case $? in
        0)
            true
            ;;
        1)
            if [ ${INST_MODE} -ne 0 ]; then
                xy_error "${EMG96}"
            else
                xy_error "${EMG98}"
            fi
            exit 1
            ;;
        2)
            if [ ${INST_MODE} -ne 0 ]; then
                xy_error "${EXMSG}"
            else
                xy_error "${UXMSG}"
            fi
            exit 1
            ;;
        *)
            if [ ${INST_MODE} -ne 0 ]; then
                xy_error "${EMG96}"
            else
                xy_error "${EMG98}"
            fi
            exit 1
            ;;
        esac
    fi

    INSTALLED_FLAG=1
    pause
done

# end of this script
#
exit 0
