#!/bin/sh
#ident "@(#)postinstall	1.31 99/04/01 SMI"

PATH=/bin:/sbin:/usr/sbin:/usr/sadm/smc/bin:/usr/sadm/smc/lib
PATH=$PATH:/export/src/plocher-smc-ws/com/sun/smc/register

SMCAPPADM=smcappadm
PROGNAME=`basename "$0"`
OSVER=`uname -r`

OTHER_PATH="/opt/NSCPcom:/opt/local/bin:/usr/local/bin:/usr/dt/bin"

# Get Netscape Path
NETSCAPE_PATH="";
NETSCAPE_APPTYPE="XAPP"
LIST=`echo $PATH $OTHER_PATH | /usr/bin/nawk '
                                {
                                  FS=":";
                                  for (i = 1; i <= NF; i++)
                                  { printf $i " " }
                                 }' `

for i in ${LIST}; do
        if [ -f ${i}/netscape ]; then
                NETSCAPE_PATH="${i}/netscape";
                break
        fi
done

if [ -z "${NETSCAPE_PATH}" ]; then
        NETSCAPE_PATH="/opt/NSCPcom/netscape"
        NETSCAPE_APPTYPE="HTML"
fi


case "$PROGNAME" in
        postinstall|smc_add*)	call="-R";;
          preremove|smc_del*)	call="-U";;
esac


HOST=`uname -n`;
echo "$HOST" | fgrep -s "." 2>&1 > /dev/null
if [ $? -ne 0 ]; then 	 # No "." in the hostname, try to find domainname
        if [ -f /etc/resolv.conf ]; then
                DOMAIN=`grep "^domain" /etc/resolv.conf | sed -e "s/domain[ 	][ 	]*//"`
	fi
	if [ -z "$DOMAIN" ]; then
                DOMAIN=`domainname | nawk '{FS="."; if (NF == 4 ) {dom=$2"."$3"."$4 } else {dom=$3"."$4} print dom}'`;
		if [ "$DOMAIN" = "." ]; then DOMAIN=""; fi
        fi
	if [ -n "$DOMAIN" ]; then
		MACHINE="$HOST.$DOMAIN"
	fi
fi
if [ -z "$MACHINE" ]; then
	MACHINE="$HOST"
fi

# AdminSuite End of Featured from SEAS
    # ${SMCAPPADM} $call -n "AutoClient"               -b /opt/SUNWadm/bin/hostmgr            -t XAPP -c Infrastructure -p group14 -i auto.gif
    # ${SMCAPPADM} $call -n "Serial Manager"           -b /opt/SUNWadm/bin/serialmgr          -t XAPP -c Connectivity   -p group14 -i serial.gif
    # ${SMCAPPADM} $call -n "DataBase Manager"         -b /opt/SUNWadm/bin/dbmgr              -t XAPP -c Infrastructure -p group14 -i dbman.gif
    # ${SMCAPPADM} $call -n "Host Manager"             -b /opt/SUNWadm/bin/hostmgr            -t XAPP -c Infrastructure -p group14 -i hostman.gif
    # ${SMCAPPADM} $call -n "Print Manager"            -b /opt/SUNWadm/bin/printmgr           -t XAPP -c Print          -p group14 -i printman.gif
    # ${SMCAPPADM} $call -n "DiskSuite"                -b /usr/opt/SUNWmd/sbin/metatool       -t XAPP -c Storage        -p group14 -i diskste.gif
    # ${SMCAPPADM} $call -n "Storage Manager"          -b /opt/SUNWadm/bin/stomgr             -t XAPP -c Storage        -p group14 -i strman.gif
    # ${SMCAPPADM} $call -n "User Manager"             -b /opt/SUNWadm/bin/usermgr            -t XAPP -c "Usergroup"    -p group14 -i clientman.gif
    # ${SMCAPPADM} $call -n "Group Manager"            -b /opt/SUNWadm/bin/groupmgr           -t XAPP -c "Usergroup"    -p group14 -i groupman.gif

    # ${SMCAPPADM} $call -n "Point to Point Protocol"  -b /usr/bin/ppptool                    -t XAPP -c Connectivity   -p root -i PPP.gif
    # ${SMCAPPADM} $call -n "PPP Configuration"        -b /usr/bin/pppinit                    -t CLI  -c Connectivity   -p root -i PPP.gif
    # ${SMCAPPADM} $call -n "Directory Service"        -b /opt/SUNWconn/ldap/sbin/dsadmintool -t CLI  -c Infrastructure -p root -i sunds.gif
    # ${SMCAPPADM} $call -n "Backup"                   -b /usr/bin/nsr/networker              -t XAPP -c Storage        -p root -i backup.gif

# Connectivity
    # ${SMCAPPADM} $call -n "TotalNet"                 -b ${NETSCAPE_PATH}                    -t HTML -c Connectivity   -p user -i totnet.gif \
    # 						-a http://${MACHINE}:7777

# Events
    # Symon
# Infrastructure
    ${SMCAPPADM} $call -n "Admintool"                -b /usr/bin/admintool                  -t XAPP -c Infrastructure -p root -i adtool.gif
    if [ "$OSVER" = "5.6" ]; then
    ${SMCAPPADM} $call  -n "Performance Meter"        -b /usr/openwin/bin/perfmeter          -t XAPP -c Infrastructure -p user -i perf_meter.gif
    else
    ${SMCAPPADM} $call     -n "Performance Meter"        -b /usr/dt/bin/sdtperfmeter            -t XAPP -c Infrastructure -p user -i perf_meter.gif
    fi

    ${SMCAPPADM} $call -n "Terminal"                 -b /usr/dt/bin/dtterm                  -t XAPP -c Infrastructure -p user -i exe.gen.gif \
						-a -ls
    if [ "$OSVER" = "5.6" ]; then
    ${SMCAPPADM} $call  -n "Workstation Information"  -b /usr/openwin/bin/wsinfo             -t XAPP -c Infrastructure -p user -i workinfo.gif
    else
    ${SMCAPPADM} $call     -n "Workstation Information"  -b /usr/dt/bin/sdtwsinfo               -t XAPP -c Infrastructure -p user -i workinfo.gif
    fi
# Jobs
    if [ "$OSVER" != "5.6" ]; then
    ${SMCAPPADM} $call     -n "Process Manager"          -b /usr/dt/bin/sdtprocess              -t XAPP -c Jobs           -p root -i procman.gif
    fi
# Mail
# SIMS2.0 (Shipped with SFI 3.0) does not have a launchable admin component
#    ${SMCAPPADM} $call -n "SIMS"                     -b http://${MACHINE}/sims              -t HTML -c Mail           -p user -i sims.gif
# Print
# Security
# Software
    ${SMCAPPADM} $call -n "Solaris Product Registry" -b /usr/bin/prodreg                    -t XAPP -c Software       -p user -i spr.gif
    ${SMCAPPADM} $call -n "Software Manager"         -b /usr/sbin/swmtool                   -t XAPP -c Software       -p user -i swman.gif
# Storage
# User & Group
# Web and Information
    # ${SMCAPPADM} $call -n "Sun Web Server"           -b http://${MACHINE}                   -t HTML -c Webinfo        -p user -i webserv.gif
# Documentation
    ${SMCAPPADM} $call -n "Answerbook"               -b http://${MACHINE}:8888              -t HTML -c Documentation  -p user -i ab2.gif



