#!/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.


# assume that Identity Server instance installed locally on this box
# and this script is to deploy it further to weblogic server 8.1 and 
# make further necessary changes to IS & weblogic server 8.1 site
#
# Variables imported into this script
# IS_INSTALLFILE_LOCATION
# CONSOLE_DEPLOY_URI
# SERVER_DEPLOY_URI
# PASSWORD_DEPLOY_URI
# COMMON_DEPLOY_URI
# WL8_HOST
# WL8_HOME
# WL8_INSTANCE


###########################################################
# Finds amutils and sources it. This function is identical
# in all scripts. Any changes made here need to made in
# other scripts too.
source_amutils()
{
	# Try to guess the location of amutils
	if [ "$BASEDIR" != "" -a "$PRODUCT_DIR" != "" -a -f $BASEDIR/$PRODUCT_DIR/bin/amutils ]; then
		AMUTILS=$BASEDIR/$PRODUCT_DIR/bin/amutils
	elif [ "$BASEDIR" != "" -a "$PRODUCT_DIR" != "" -a -f $BASEDIR/$PRODUCT_DIR/share/bin/amutils ]; then
		AMUTILS=$BASEDIR/$PRODUCT_DIR/share/bin/amutils
	elif [ -f ./amutils ]; then
		AMUTILS=./amutils
	elif [ -f `dirname $0`/amutils ]; then
		AMUTILS=`dirname $0`/amutils
	elif [ -f /opt/SUNWam/bin/amutils ]; then
		AMUTILS=/opt/SUNWam/bin/amutils
	elif [ -f /opt/SUNWam/share/bin/amutils ]; then
		AMUTILS=/opt/SUNWam/share/bin/amutils ]
	elif [ -f /opt/sun/identity/bin/amutils ]; then
		AMUTILS=/opt/sun/identity/bin/amutils
	elif [ -f /opt/sun/identity/share/bin/amutils ]; then
		AMUTILS=/opt/sun/identity/share/bin/amutils ]
	else
		echo "$0: FATAL: Could not find amutils. Exiting."
		exit 1
	fi

	# Source it!
	echo "$0: Sourcing $AMUTILS"
	. $AMUTILS
}

if [ ${#} -eq 0 ]; then
	INSTALL_FILE_NOT_REQUIRED=true
	source_amutils
	do_interactive
	set -- -s $IS_SILENT_INSTALL_FILE
	INSTALL_FILE_NOT_REQUIRED=false
elif [ $1 = "-s" ]; then 
    if [ ! -f $2 ]; then 
        echo Silent file not found: $2 
        exit 
    fi 
    IS_SILENT_INSTALL_FILE=$2 
    export IS_SILENT_INSTALL_FILE 
else 
    echo "Usage: amwl81config [ -s <silent> ]" 
    exit 
fi

source_amutils

# variables needed for this script

SERVER_URI="$SERVER_PROTOCOL://$SERVER_HOST:$SERVER_PORT"


uri1="${CONSOLE_DEPLOY_URI:-/amconsole}"
uri2="${SERVER_DEPLOY_URI:-/amserver}"
uri3="${PASSWORD_DEPLOY_URI:-/ampassword}"
uri4="${COMMON_DEPLOY_URI:-/amcommon}"

# WL8.1 variables need to be set and used here

WL8_HOSTNAME=`echo $WL8_HOST |nawk -F. '{print $1}'`
WL8_CONFIG_BASE=${WL8_HOME}/$WL8_PROJECT_DIR/domains/$WL8_DOMAIN
export WL8_CONFIG_BASE
WL8_INSTANCE_HOST=$WL8_HOSTNAME
export WL8_INSTANCE_HOST
WL8_CONFILES="$WL8_CONFIG_BASE/startWebLogic.sh $WL8_CONFIG_BASE/startManagedWebLogic.sh"
export WL8_CONFILES
BACKUP_DIR=$WL8_CONFIG_BASE/.dsame
export BACKUP_DIR

# add path for wdeploy
JSS_JAR_FILE=${JSS_JAR_PATH}/jss3.jar
LIB_DIR=${PKGDIR}/lib
PATH=${WL8_CONFIG_BASE}:${JAVA_HOME}/bin:/bin:/usr/bin
export PATH
LD_LIBRARY_PATH=${JSS_SO_PATH}:${NSS_SO_PATH}:${NSPR_SO_PATH}:${WL8_INSTANCE}/server/lib
export LD_LIBRARY_PATH
CLASSPATH=$LIB_DIR/am_sdk.jar:$LIB_DIR/am_services.jar:$LIB_DIR:$PKGDIR/locale:$JSS_JAR_FILE:$LIB_DIR/jaas.jar:$LIB_DIR/jaxp-api.jar:$LIB_DIR/sax.jar:$LIB_DIR/xercesImpl.jar:$LIB_DIR/dom.jar:$LIB_DIR/servlet.jar:/$CONFIG_DIR
export CLASSPATH
WEBAPPS_SOURCE_DIR=$PKGDIR/web-src
CONSOLE_DIR=$WEBAPPS_SOURCE_DIR/applications
PASSWORD_DIR=$WEBAPPS_SOURCE_DIR/password
COMMON_DIR=$WEBAPPS_SOURCE_DIR/common
SERVICES_DIR=$WEBAPPS_SOURCE_DIR/services
CONSOLE_DEPLOY_DIR=$WL8_DEPLOY_DIR/applications
PASSWORD_DEPLOY_DIR=$WL8_DEPLOY_DIR/password
COMMON_DEPLOY_DIR=$WL8_DEPLOY_DIR/common
SERVICES_DEPLOY_DIR=$WL8_DEPLOY_DIR/services


backupConfig()
{
 
  if [ ! -d $BACKUP_DIR ];then
    mkdir -p $BACKUP_DIR
  fi
  for file in $WL8_CONFILES
  do
   if [ ! -f $BACKUP_DIR/$file ];then
  	cp -f $file $BACKUP_DIR/
   fi
  done
}

setJavaOptions()
{
  # create ${WL8_CONFIG_BASE}/.java.login.config

  file="${WL8_CONFIG_BASE}/.java.login.config"

cat <<EOF > $file
{
  weblogic.security.internal.ServerLoginModule required debug=true;
};
EOF
}

configureJavaSecurity()
{
# change java.security of weblogic jdk
file=${WL8_JDK_HOME}/jre/lib/security/java.security
cat <<EOF >> $file
login.configuration.provider=com.sun.identity.authentication.config.AMConfiguration
EOF
}

configureServerPolicy()
{
  # modifying weblogic.policy
  file="$WL8_INSTANCE/server/lib/weblogic.policy"
  add_to_end "$file" "// IS RELATED ADDITIONS"
  add_to_end "$file" "grant {"
  add_to_end "$file" "    permission java.lang.RuntimePermission \"modifyThreadGroup\";"
  add_to_end "$file" "    permission java.lang.RuntimePermission \"setFactory\";"
  add_to_end "$file" "    permission java.lang.RuntimePermission \"accessClassInPackage.*\";"
  add_to_end "$file" "    permission java.lang.RuntimePermission \"shutdownHooks\";"
  add_to_end "$file" "    permission java.util.logging.LoggingPermission \"control\";"
  add_to_end "$file" "    permission java.util.PropertyPermission \"java.util.logging.config.class\", \"write\";"
  add_to_end "$file" "    permission java.security.AllPermission;"
  add_to_end "$file" "    permission java.io.FilePermission \"<<ALL FILES>>\", \"execute,delete\";"
  add_to_end "$file" "    permission javax.security.auth.AuthPermission \"getLoginConfiguration\";"
  add_to_end "$file" "    permission javax.security.auth.AuthPermission \"setLoginConfiguration\";"
  add_to_end "$file" "    permission javax.security.auth.AuthPermission \"modifyPrincipals\";"
  add_to_end "$file" "    permission javax.security.auth.AuthPermission \"createLoginContext.*\";"
  add_to_end "$file" "    permission java.security.securityPermission \"insertProvider.Mozilla-JSS\";"
  add_to_end "$file" "    permission javax.security.auth.AuthPermission \"putProviderProperty.Mozilla-JSS\";"
  add_to_end "$file" "    permission java.security.SecurityPermission \"putProviderProperty.Mozilla-JSS\";"
  add_to_end "$file" "    permission java.security.SecurityPermission \"insertProvider.Mozilla-JSS\";"
  add_to_end "$file" "    permission java.security.SecurityPermission \"removeProvider.SUN\";"
  add_to_end "$file" "    permission java.security.SecurityPermission \"insertProvider.SUN\";"
  add_to_end "$file" "    permission java.security.SecurityPermission \"removeProvider.Mozilla-JSS\";"
  add_to_end "$file" "    permission javax.security.auth.AuthPermission \"doAs\";"
  add_to_end "$file" "    permission java.util.PropertyPermission \"java.security.krb5.realm\", \"write\";"
  add_to_end "$file" "    permission java.util.PropertyPermission \"java.security.krb5.kdc\", \"write\";"
  add_to_end "$file" "    permission java.util.PropertyPermission \"java.security.auth.login.config\", \"write\";"
  add_to_end "$file" "    permission javax.security.auth.kerberos.ServicePermission \"*\", \"accept\";"
  add_to_end "$file" "};"
  add_to_end "$file" "// END OF ADDITIONS FOR IS"
}

configureEndorsedDirs()
{
  if [ ! -d ${LIB_DIR}/endorsed ];then
      mkdir -p ${LIB_DIR}/endorsed
  fi
  ln -s "${LIB_DIR}/xalan.jar" "${LIB_DIR}/endorsed/xalan.jar" 2>/dev/null
  ln -s "${LIB_DIR}/xercesImpl.jar" "${LIB_DIR}/endorsed/xercesImpl.jar" 2>/dev/null
  ln -s "${LIB_DIR}/sax.jar" "${LIB_DIR}/endorsed/sax.jar" 2>/dev/null
  ln -s "${LIB_DIR}/dom.jar" "${LIB_DIR}/endorsed/dom.jar" 2>/dev/null
  ln -s "${LIB_DIR}/xsltc.jar" "${LIB_DIR}/endorsed/xsltc.jar" 2>/dev/null
}

# configure weblogic
configureWL8()
{
  echo "Checking if WebLogic Server is configed with IS"
  entry=`grep am_sdk.jar $WL8_HOME/$WL8_PROJECT_DIR/domains/$WL8_DOMAIN/startWebLogic.sh`
  if [ "$entry" = "" ];then
  echo Configuring WebLogic Server
  backupConfig
  setJavaOptions
  configureServerPolicy
  configureJavaSecurity
  configureEndorsedDirs
  setClassPath
  # update_saml_config

  # online help link to webserver doc root
  # ln -s $PKGDIR/public_html/online_help $WL8_HOME/docs/online_help    2>/dev/null
  fi

}

update_saml_config()
{
currpwd=`pwd`
samldir=/tmp/samlconfig-$$
if [ -d $samldir ];then
 rm -fr $samldir
fi
mkdir -p $samldir
cd $samldir
file="META-INF/services/javax.xml.soap.SOAPConnectionFactory"
${WL8_JDK_HOME}/bin/jar -xf ${WL8_INSTANCE}/server/lib/webservices.jar $file

rm -f $file
echo "javax.xml.soap.SOAPConnectionFactory" > $file

${WL8_JDK_HOME}/bin/jar -uf ${WL8_INSTANCE}/server/lib/webservices.jar $file

cd $currpwd
rm -fr $samldir
}

restore_saml_config()
{
currpwd=`pwd`
samldir=/tmp/samlconfig-$$
if [ -d $samldir ];then
 rm -fr $samldir
fi
mkdir -p $samldir
cd $samldir
file="META-INF/services/javax.xml.soap.SOAPConnectionFactory"
${WL8_JDK_HOME}/bin/jar -xf ${WL8_INSTANCE}/server/lib/webservices.jar $file

rm -f $file
echo "weblogic.webservice.core.soap.SOAPConnectionFactoryImpl" > $file

${WL8_JDK_HOME}/bin/jar -uf ${WL8_INSTANCE}/server/lib/webservices.jar $file

cd $currpwd
rm -fr $samldir
}

setClassPath()
{

  LIB_DIR=${PKGDIR}/lib

  # Begin PORTALMA
if [ "$OSTYPE" = "Linux" ]; then
        MOBILE_ACCESS_LIB_DIR=/opt/sun/mobileaccess/share/lib
else
        MOBILE_ACCESS_LIB_DIR=/opt/SUNWma/lib
fi

  MOBILE_ACCESS_JARS="$MOBILE_ACCESS_LIB_DIR/wireless_rendering.jar:$MOBILE_ACCESS_LIB_DIR/wireless_rendering_util.jar:$MOBILE_ACCESS_LIB_DIR/mobile_services.jar:$MOBILE_ACCESS_LIB_DIR/ccpp-1_0.jar:$MOBILE_ACCESS_LIB_DIR/ccpp-ri-1_0.jar:$MOBILE_ACCESS_LIB_DIR/jena-1.4.0.jar:$MOBILE_ACCESS_LIB_DIR/rdffilter.jar:$MOBILE_ACCESS_LIB_DIR/locale"
  is_pkg_installed $MA_PKGNAME
  if [ $? -eq 0 ]; then
      	MOBILE_ACCESS_JARS="$MOBILE_ACCESS_JARS:$LIB_DIR/mobile_identity.jar"
  fi
  # End PORTALMA

  JVM_CLASSPATH_CLASSES="$LIB_DIR/jaxrpc_1.0/jaxrpc-api.jar:$LIB_DIR/jaxrpc_1.0/jaxrpc-ri.jar:$LIB_DIR/xalan.jar:$LIB_DIR/xmlsec.jar:$LIB_DIR/xercesImpl.jar:$LIB_DIR/sax.jar:$LIB_DIR/dom.jar:$LIB_DIR/dom4j.jar:$LIB_DIR/jakarta-log4j-1.2.6.jar:$LIB_DIR/saaj-api.jar:$LIB_DIR/saaj-impl.jar:$CONFIG_DIR:$LIB_DIR:$PKGDIR/locale:$JSS_JAR_FILE:$LIB_DIR/am_sdk.jar:${LIB_DIR}/am_services.jar:${LIB_DIR}/am_sso_provider.jar:$LIB_DIR/swec.jar:$LIB_DIR/acmecrypt.jar:$LIB_DIR/iaik_ssl.jar:$LIB_DIR/iaik_jce_full.jar:$LIB_DIR/jaxp-api.jar:$LIB_DIR/mail.jar:$LIB_DIR/activation.jar:${LIB_DIR}/am_logging.jar:$LIB_DIR/commons-logging.jar:$LIB_DIR/jaas.jar:$LIB_DIR/jax-qname.jar:$LIB_DIR/jaxm-api.jar:$LIB_DIR/jaxm-runtime.jar:$LIB_DIR/jce1_2_1.jar:$LIB_DIR/jdk_logging.jar:$LIB_DIR/servlet.jar:$LIB_DIR/xsltc.jar:$LIB_DIR/namespace.jar:$LIB_DIR/relaxngDatatype.jar:$LIB_DIR/xsdlib.jar:$LIB_DIR/jaxb-api.jar:$LIB_DIR/jaxb-impl.jar:$LIB_DIR/jaxb-libs.jar:$LIB_DIR/jaxb-xjc.jar:$MOBILE_ACCESS_JARS"

  cd ${WL8_CONFIG_BASE}

 LIB_DIR=${PKGDIR}/lib
 for file in $WL8_CONFILES; do

sed -e "/^CLASSPATH/{
a\\
### IS classes added to CLASSPATH
a\\
CLASSPATH=${CONFIG_DIR}:${JVM_CLASSPATH_CLASSES}:\$CLASSPATH
a\\

a\\
### IS related enviornment variables
a\\
IS_OPTIONS=\"-Djava.endorsed.dirs=${LIB_DIR}/endorsed -Djava.security.auth.login.config=${WL8_CONFIG_BASE}/.java.login.config -DLOG_COMPATMODE=Off -Ds1is.java.util.logging.config.class=com.sun.identity.log.s1is.LogConfigReader -Djava.protocol.handler.pkgs=com.iplanet.services.comm\" 
a\\

a\\
### IS related libraries added to LD_LIBRARY_PATH
a\\
LD_LIBRARY_PATH=${JSS_SO_PATH}:${NSS_SO_PATH}:${NSPR_SO_PATH}:\$LD_LIBRARY_PATH
a\\

}" $file >${WL8_CONFIG_BASE}/tempFile126743


## Replace JAVA_OPTIONS} with JAVA_OPTIONS} ${IS_OPTIONS}

 sed "`grep -n "{JAVA_OPTIONS}" ${WL8_CONFIG_BASE}/tempFile126743 | cut -d: -f1 | tail -1` s/JAVA_OPTIONS}/JAVA_OPTIONS} \${IS_OPTIONS} /" ${WL8_CONFIG_BASE}/tempFile126743 > $file

 echo "Removing TempFile"
 rm ${WL8_CONFIG_BASE}/tempFile126743

done

# add IS_OPTIONS to startup line
  lineno=`grep -n weblogic.Server $file|nawk -F: '{print $1}'`
  total_line=`wc -l $file |awk '{print $1}'`
  idx=1
  newfile=$file-$$
  rm -f $newfile;touch $newfile
  
  while [ $idx -le $total_line ];do
   if [ $idx -ne $lineno ];then
        line=`head -$idx $file|tail -1`
        echo "$line" >>$newfile
   else # need to modify line
        line=`head -$idx $file|tail -1`
        line=`echo $line | nawk '{for(i=1;i<=NF;i++)if(index($i,"JAVA_OPTIONS")!=0) printf("%s ${IS_OPTIONS} ",$i) ;else printf ("%s ",$i);}'`
        echo "$line" >>$newfile
   fi
   idx=`expr $idx \+ 1`
  done
  
  cp -f $newfile $file
  rm -f $newfile

}

unconfigureWL8()
{
  echo Unconfiguring WebLogic Server
  # restore the ws and IS to its init stage (config)
  rm -f ${BASEDIR}/${PRODUCT_DIR}/lib/endorsed/dom.jar
  rm -f ${BASEDIR}/${PRODUCT_DIR}/lib/endorsed/sax.jar
  rm -f ${BASEDIR}/${PRODUCT_DIR}/lib/endorsed/xalan.jar
  rm -f ${BASEDIR}/${PRODUCT_DIR}/lib/endorsed/xercesImpl.jar

 # unconfig weblogic and remove all IS related config
 cd ${WL8_CONFIG_BASE}

 #rm -f $WL8_HOME/docs/online_help

 for file in $WL8_CONFILES; do
 
  libline=`cat $file | grep -n "### IS" | awk ' BEGIN { FS=":" } { print $1}'`
  count=0
  for temp in $libline;
   do
    lineNum=`expr $temp - $count`
    delete_line_by_number $file $lineNum
    delete_line_by_number $file $lineNum
    delete_line_by_number $file $lineNum
    count=`expr $count + 3`
  done
 optLine=`cat $file | grep IS_OPTIONS |egrep -v "weblogic.Server"`
  newOptLine=`echo $optLine | awk '{
         line=$0
         size = split(line, arrays, " ")
         for(i=1; i <= size; i++) {
          if ((index($i, "IS_OPTIONS") == 0)) {
            printf("%s ", $i)
          }
         }

   }'`
  #append_line "$file" "IS_OPTIONS" "$newOptLine"
  #delete_line "$file" "IS_OPTIONS"

 #sed -e 's/{CLASSPATH}/CLASSPATH/g' \
 #$file > ${file}-tmp
 #cp ${file}-tmp $file
 #rm ${file}-tmp

 sed -e 's/{JAVA_OPTIONS} \${IS_OPTIONS}/{JAVA_OPTIONS}/g' \
 $file > ${file}-tmp
 cp ${file}-tmp $file
 rm ${file}-tmp

 done

  # deleting permission settings in weblogic.policy
  file="$WL8_INSTANCE/server/lib/weblogic.policy"
  line=`cat $file | grep -n "IS RELATED ADDITIONS" | nawk ' BEGIN { FS=":" } { print $1}'`
  count=1
  while [ $count -lt 29 ]
  do
      delete_line_by_number "$file" "$line"
      count=`expr $count + 1`
  done

 # restore java.security of weblogic
 file="${WL8_JDK_HOME}/jre/lib/security/java.security"
 delete_line "$file" "login.configuration.provider=com.sun.identity.authentication.config.AMConfiguration"

# delete IS_OPTIONS from startup line
 
 for file in $WL8_CONFILES; do
 
  lineno=`grep -n weblogic.Server $file|nawk -F: '{print $1}'`
  total_line=`wc -l $file |awk '{print $1}'`
  idx=1
  newfile=$file-$$
  rm -f $newfile;touch $newfile
 
  while [ $idx -le $total_line ];do
       if [ $idx -ne $lineno ];then
               line=`head -$idx $file|tail -1`
               echo "$line" >>$newfile
       else   # need to modify line
               line=`head -$idx $file|tail -1`
               line=`echo $line | nawk '{for(i=1;i<=NF;i++)if(index($i,"IS_OPTIONS")!=0) printf("");else printf ("%s ",$i);}'`
               echo "$line" >>$newfile
       fi
       idx=`expr $idx \+ 1`
  done
       cp -f $newfile $file
       rm -f $newfile
 done

 # restore weblogic 8.1 saml config
 # restore_saml_config
}

# start weblogic server
start_wl81()
{
  if [ -x $WL8_CONFIG_BASE/startWebLogic.sh ];then
    currdir=`pwd`
    cd $WL8_CONFIG_BASE
    ./startWebLogic.sh &
    check_and_wait
    cd $currdir
  else
    echo "weblogic 8.1 image ($WL8_CONFIG_BASE) has problem"
    exit 0
  fi
  echo "Weblogic 8.1 started."
}

# stop weblogic 
stop_wl81()
{
 pid=`ps -ef|grep "$WL8_HOME"|egrep -v grep|awk '{print $2}'`
 if [ ! -z ${pid:-""} ];then
        kill -9 ${pid:-99999999} > /dev/null 2>&1
 fi
}

check_ports()
{
if [ $DEPLOY_LEVEL -eq 4 ];then #       full wl81 install
        x="*.$WL8_PORT"
        yesorno=1
        yesorno=`netstat -an | grep "*.$WL8_PORT" | egrep -v grep | nawk -v v=$x -v i=0 '{if (length(v)==length($1)) i++; print i}'`
        if [ ${yesorno:-0} -ne 0 ];then
                echo "Port $WL8_PORT is busy, please check it and rerun $0"
                exit 0
        fi
fi

}
check_and_wait()
{
 yesorno=0
 x="*.$WL8_PORT"
 while [ ${yesorno:-0} -eq 0 ];do
  yesorno=`netstat -an | grep "*.$WL8_PORT" | egrep -v grep | wc -l`
  if [ ${yesorno:-0} -ne 0 ];then
   yesorno=`netstat -an | grep "*.$WL8_PORT" | egrep -v grep | nawk -v v=$x -v i=0 '{if (length(v)==length($1)) i++; print i}'`
  fi
  sleep 3
 done

}

#############################################################################
# Start of main program
#############################################################################

PWD=`pwd`
# check system env. 
check_env

# DEPLOY_LEVEL level range from 10 ~ 99 of following meaning
case $DEPLOY_LEVEL in
	4)	# sdk only container config
                configureWL8
		;;
	14)	# undeploy sdk only with container config
                unconfigureWL8
		;;
	31*)	# config IS SDK only
                configureWL8
		;;
	*)	echo "Unsupported DEPLOY_LEVEL value" 
		exit 0 ;;
esac



