#!/bin/bash
# Installs and configures weblogic and sets up the domain in weblogic/PPS_domain

# *** Script configuration ***

# The path to the installation resources. (Assumed to be the path to this script.)
install_dir=$(dirname "$0")

# The path of the WebLogic domain to create.
domain_dir=$HOME/weblogic/PPS_domain

# The password for the 'weblogic' domain user.
password_domain="welcome1"

# *** Now on to business ***

echo Setting JAVA_HOME...
export JAVA_HOME="/usr/java/jdk1.8.0_101"
echo Updating PATH...
export PATH="$JAVA_HOME/bin/:$PATH"
echo unzipping wls1213_dev_update3.zip...
mkdir "$HOME/weblogic"
unzip -q "$install_dir/non_free/wls1213_dev_update3.zip" -d "$HOME/weblogic"
echo running configure.sh...
export MW_HOME="$HOME/weblogic/wls12130"
. "$MW_HOME/configure.sh" -silent
echo setting environment variables...
. "$MW_HOME/wlserver/server/bin/setWLSEnv.sh"
echo unpacking and creating domain...
"$MW_HOME/oracle_common/common/bin/unpack.sh" \
    -template="$install_dir/domain_template.jar" -domain="$domain_dir" \
    -user_name=weblogic -password="$password_domain"

# Also configure log4j in the domain.
"$install_dir/configureLog4j2.sh" "$domain_dir"
