#!/bin/sh

# Copyright  2004 Sun Microsystems, Inc. All rights reserved. 
# 
# Sun Microsystems, Inc. has intellectual property rights relating to
# technology embodied in the product that is described in this document.
# In particular, and without limitation, these intellectual property rights
# may include one or more of the U.S. patents listed at
# http://www.sun.com/patents and one or more additional patents or pending
# patent applications in the U.S. and in other countries.
# 
# U.S. Government Rights - Commercial software. Government users are subject
# to the Sun Microsystems, Inc. standard license agreement and applicable
# provisions of the FAR and its supplements.
# 
# Use is subject to license terms. 
# 
# This distribution may include materials developed by third parties. Sun,
# Sun Microsystems, the Sun logo, Java and Sun[tm] ONE are trademarks or
# registered trademarks of Sun Microsystems, Inc. in the U.S. and other
# countries. 
# 
# Copyright  2004 Sun Microsystems, Inc. Tous droits rservs. Sun
# Microsystems, Inc. dtient les droits de proprit intellectuels relatifs
#  la technologie incorpore dans le produit qui est dcrit dans ce document.
# En particulier, et ce sans limitation, ces droits de proprit
# intellectuelle peuvent inclure un ou plus des brevets amricains lists
#  l'adresse http://www.sun.com/patents et un ou les brevets supplmentaires
# ou les applications de brevet en attente aux Etats - Unis et dans les
# autres pays.
# 
# L'utilisation est soumise aux termes du contrat de licence.
# 
# Cette distribution peut comprendre des composants dvelopps par des
# tierces parties.
# 
# Sun, Sun Microsystems, le logo Sun, Java et Sun[tm] ONE sont des marques
# de fabrique ou des marques dposes de Sun Microsystems, Inc. aux
# Etats-Unis et dans d'autres pays.
#############################################################################

tune_DesktopConfig() {
    tune_file="$PS_DESKTOP_CONFIG_DIR/desktopconfig.properties"
    
    $ECHO $LINE_SEP
    $ECHO "Tuning $tune_file..."
    $ECHO
    $ECHO "File                 : $tune_file"
    $ECHO "Parameter tuning     :"
    $ECHO
    $ECHO "1.   callerPoolMinSize"
    $ECHO "Current Value        : callerPoolMinSize=`getEntry 'callerPoolMinSize' $tune_file`"
    $ECHO "Recommended Value    : callerPoolMinSize=$PSTUNE_CALLER_POOL_MIN_SIZE"
    $ECHO
    $ECHO "2.   callerPoolMaxSize"
    $ECHO "Current Value        : callerPoolMaxSize=`getEntry 'callerPoolMaxSize' $tune_file`"
    $ECHO "Recommended Value    : callerPoolMaxSize=$PSTUNE_CALLER_POOL_MAX_SIZE"
    $ECHO
    $ECHO "3.   callerPoolPartitionSize"
    $ECHO "Current Value        : callerPoolPartitionSize=`getEntry 'callerPoolPartitionSize' $tune_file`"
    $ECHO "Recommended Value    : callerPoolPartitionSize=$PSTUNE_CALLER_POOL_PARTITION_SIZE"
    $ECHO
    $ECHO "4.   templateScanInterval"
    $ECHO "Current Value        : templateScanInterval=`getEntry 'templateScanInterval' $tune_file`"
    $ECHO "Recommended Value    : templateScanInterval=$PSTUNE_TEMPLATE_SCAN_INTERVAL"
    $ECHO

    if [ "$AMTUNE_MODE" = "REVIEW" ]; then
        return
    fi

    check_file_for_write $tune_file
    if [ $? = 100 ]; then
        return
    fi
    
    perf_tune_start_str="## Line modified for Performance Tuning by pstune - `date`"

    insert_line $tune_file "callerPoolMinSize=" "$perf_tune_start_str"
    replace_line $tune_file "callerPoolMinSize=" "callerPoolMinSize=$PSTUNE_CALLER_POOL_MIN_SIZE"

    insert_line $tune_file "callerPoolMaxSize=" "$perf_tune_start_str"
    replace_line $tune_file "callerPoolMaxSize=" "callerPoolMaxSize=$PSTUNE_CALLER_POOL_MAX_SIZE"

    insert_line $tune_file "callerPoolPartitionSize=" "$perf_tune_start_str"
    replace_line $tune_file "callerPoolPartitionSize=" "callerPoolPartitionSize=$PSTUNE_CALLER_POOL_PARTITION_SIZE"

    insert_line $tune_file "templateScanInterval=" "$perf_tune_start_str"
    replace_line $tune_file "templateScanInterval=" "templateScanInterval=$PSTUNE_TEMPLATE_SCAN_INTERVAL"

}


#############################################################################
# Start of main program
#############################################################################
SCRIPT_LOCATION=`/usr/bin/dirname $0`

# import the environment
if [ -f $SCRIPT_LOCATION/pstune-env ]; then
    if [ ! "$INIT_STATUS" = "INIT_COMPLETE" ]; then
        . $SCRIPT_LOCATION/pstune-env
    fi
fi

$ECHO "Portal Tuning Script"				1>>$DEBUG_FILE 2>&1

tune_DesktopConfig					1>>$DEBUG_FILE 2>&1

$ECHO $PARA_SEP                                         1>>$DEBUG_FILE 2>&1

