#!/bin/sh
#ident "@(#)preremove	1.1	07/27/06 SMI"

# Preremove script to stop console server in local zones
# for Solaris 10 and up.  We assume a package script in
# a local zone is running in a full OS environment.

# Commands to use to stop the console.
STPX=private/bin/swcstop
ZNMX=/sbin/zonename

# Constants for console configuration
CONSOLE_CONF=$BASEDIR/etc/webconsole
CONSOLE_INST=console

# If the zonename command exists, we are on a Solaris platform.
# If zone name is not "global", we are in a local zone.
if [ -x $ZNMX ]; then
    name=`${ZNMX}`
    if [ $? -eq 0 -a "${name}" != "" -a "${name}" != "global" ]; then

	# Get path to our stop command and execute it.
	conf_file=${CONSOLE_CONF}/${CONSOLE_INST}/config.properties
	home_path=`grep -i "^console_home=" ${conf_file} | cut -f2 -d"="`
	if [ -z "${home_path}" ]; then
	    # If all else fails, use default Solaris console home path.
	    home_path=/usr/share/webconsole
	fi
	${home_path}/${STPX}
    fi
fi

exit 0
