#!/bin/ksh

#########################################################################################
# This script expects the location of DSSIMULIA_Established.htm as its first argument.
# /usr/SIMULIA/Documentation/2017/English/DSSIMULIA_Established.htm OR
# http://dsdoc/doc419/English/DSSIMULIA_Established.htm
#########################################################################################


BASEDIR=$(readlink -f "$0")
BASE=$(dirname "$BASEDIR")
FIPER_HOME=`cd "$BASE/../.."; \pwd`
export FIPER_HOME

cd $FIPER_HOME/..

unzip -oq $FIPER_HOME/reffiles/SMAFIPapi/api.zip -d $FIPER_HOME/..

mkdir -p config
cd config

propFile=isight.properties
webtopPropFile=webtop.properties
docPathDefaultEng=fiper.help.url

if [ "$1" != "" ] ; then
	newDocPathFull=$1
	
	newDocPathFullEng=$docPathDefaultEng=$newDocPathFull
	newDocPathFullEng=`echo "$newDocPathFullEng"|sed 's/ /%20/g'`
	cat $propFile | sed "s|$docPathDefaultEng|$newDocPathFullEng|" > $propFile"1"
	mv -f $propFile"1" $propFile
fi

if [ "$1" != "" ] ; then
	newDocPathFull=$1
	
	newDocPathFullEng=$docPathDefaultEng=$newDocPathFull
	newDocPathFullEng=`echo "$newDocPathFullEng"|sed 's/ /%20/g'`
	cat $webtopPropFile | sed "s|$docPathDefaultEng|$newDocPathFullEng|" > $webtopPropFile"1"
	mv -f $webtopPropFile"1" $webtopPropFile
fi
