#!/bin/sh
#
#ident "@(#)pngomatic	1.1 07/09/06 SMI"
# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.

# Get console installation home directory
# This command is in ${CONSOLE_HOME}/bin
PROGDIR=`dirname "$0"`
SAVEDIR=`pwd`
cd $PROGDIR/..
CONSOLE_HOME=`pwd`
cd ${SAVEDIR}

# Get the path to the java command
if [ "${JAVA_HOME}" = "" ]; then
    JAVA_PATH=/usr/java/bin/java
else
    JAVA_PATH=${JAVA_HOME}/bin/java
fi

# Get the command arguments.
# Build up one big argument with a special value between options.
# This allows option values with white space to be handled.
ARGS=""
if [ $# -gt 0 ]; then
    ARGS=$1
    shift
    while [ $# -gt 0 ]; do
        ARGS="${ARGS}_WxS_$1"
        shift
    done
fi

# Set umask for creating new files
umask 022

# Set classpath
LIBPATH=${CONSOLE_HOME}/other
CLASSPATH=${LIBPATH}/pngomatic.jar

# Execute the java based command
${JAVA_PATH} -classpath ${CLASSPATH} \
    -Djava.awt.headless=true \
    com.sun.webui.util.prodname.CliProductImage pngomatic "${ARGS}"

exit $?
