/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
 *
 * The contents of this file are subject to the terms
 * of the Common Development and Distribution License
 * (the License). You may not use this file except in
 * compliance with the License.
 *
 * You can obtain a copy of the License at
 * https://opensso.dev.java.net/public/CDDLv1.0.html or
 * opensso/legal/CDDLv1.0.txt
 * See the License for the specific language governing
 * permission and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL
 * Header Notice in each file and include the License file
 * at opensso/legal/CDDLv1.0.txt.
 * If applicable, add the following below the CDDL Header,
 * with the fields enclosed by brackets [] replaced by
 * your own identifying information:
 * "Portions Copyrighted [year] [name of copyright owner]"
 *
 *
 */ 

umask ${DEF_UMASK}

PATH=/bin:/usr/bin:/sbin:/usr/sbin
CHMOD=/usr/bin/chmod
CHOWN=/usr/bin/chown
CP="/usr/bin/cp -p"
ECHO=/usr/bin/echo
RM=/usr/bin/rm
SED=/usr/bin/sed

PKGDIR=${BASEDIR}/${PRODUCT_DIR}

BIN_DIR=${PKGDIR}/bin
BIN_FILES="crypt_util"

CONFIG_DIR=${PKGDIR}/config
CONFIG_FILE=OpenSSOAgentBootstrap.properties
CONFIG_FILE_ORIG=${CONFIG_FILE}.orig

LIB_DIR=${PKGDIR}/lib
LIB_FILES="comlib libamsdk.so.2 libxml2.so.2"


##############################################################
#
# starting main routine
#
# deploy C SDK
#

# config file
if [ -d ${CONFIG_DIR} ]; then
    cd ${CONFIG_DIR}
    if [ ! -f $CONFIG_FILE ]; then
        $CP ${CONFIG_FILE_ORIG} ${CONFIG_FILE}+
        $SED -e "s#PRIMARY_NAMING_URL#$PRIMARY_NAMING_URL#g" \
             -e "s#FAILOVER_NAMING_URL#$FAILOVER_NAMING_URL#g" \
             -e "s#TEMP_DIR_PREFIXDEBUG_DIR_PREFIX#$TEMP_DIR_PREFIXDEBUG_DIR_PREFIX#g" \
             -e "s#WS_DEBUG_DIR#$WS_DEBUG_DIR#g" \
        ${CONFIG_FILE}+ > ${CONFIG_FILE}
        $RM -f ${CONFIG_FILE}+
        $CHOWN $NEW_OWNER:$NEW_GROUP ${CONFIG_FILE} > /dev/null 2>&1
        $CHMOD 600 ${CONFIG_FILE} > /dev/null 2>&1
    fi
fi

# bin files
if [ -d ${BIN_DIR} ]; then
    cd ${BIN_DIR}
    for file in $BIN_FILES; do
        $CHOWN $NEW_OWNER:$NEW_GROUP $file > /dev/null 2>&1
        $CHMOD 500 $file > /dev/null 2>&1
    done
fi
