#!/bin/sh
#
# Data Source Setup - IBM WebServices Gateway
#
# The arguments are:
# "1: WebServices Gateway dir"
# "2: WebSphere nodename"
# "3: WebSphere AppServer dir"
# "4: DB2 user id"
# "5: DB2 password"

echo

if [ $# -eq 5 ]; then # test there are 5 arguments

  if [ -d $1 ]; then # test 1st argument is a directory

    if [ -d $3 ]; then # test 3d  argument is a directory

      ./installDS.sh $1 $2 $3 $4 $5 > $3/logs/WSGWinstallDS.log 2>&1
 
      if [ $? -eq 0 ]; then # installDS.sh worked.

        echo "The WebServices Gateway DataSource has been installed."

      else

        echo "The WebServices Gateway DataSource has NOT been created."
        echo "Try looking at the WSGWinstallDS.log file in the /logs subdirectory"
        echo "of the WebSphere AppServer dir to diagnose the problem."

      fi

    else # 3d  argument isn't a dir

      echo "The directory ($3) specified for WebSphere AppServer doesn't exist."
      echo "The WebServices Gateway JDBC has NOT been installed."

    fi

  else # 1st argument isn't a dir

    echo "The directory ($1) specified for WebServices Gateway doesn't exist."
    echo "The WebServices Gateway JDBC has NOT been installed."

  fi

else # user didn't pass 5 arguments

  echo "WSGWinstallDS.sh requires 5 arguments:"
  echo "1: WebServices Gateway Directory (no trailing /)"
  echo "2: WebSphere nodename"
  echo "3: WebSphere AppServer Directory (no trailing /)"
  echo "4: DB2 USERID"
  echo "5: DB2 PASSWORD"
  echo "Example: ./WSGWinstallDS.sh /opt/WebSphere/AppServer/WSGW bportier /opt/WebSphere/AppServer db2inst1 db2pwd"


fi

echo
