#!/bin/sh
#
#    C A S P E R M . S H 
#
#    Configure permissions for CAS processes.
#
#    @(#)  casperm.sh - v1.0 10th July 2012
#
#   Script Checksum - MFSUM#49080#
#
#  This script contains the following functions.
#
#     AlternativeGetMessage - Get message from var store.         
#     CAS_Permissions - Install and Configure ES.                 
#     center - Center text string on screen.                      
#     Debug - Display debug messages.                             
#     ExitScript - Display exit mesage and set return code.       
#     GetMessage - Load cobgetmsg tool.                           
#     logit - Print message to log file.                          
#     printit - Print message to installation script log file.    
#     Root - Check script is running as root.                     
#     ScriptArgs - Process any command line arguments.            
#     ScriptLogFiles - Deal with script log files.                
#     yorn - Ask Yes or No question to user.                      
#
#  Script Requirements.
#
#     o. Bourne shell support must be available.
#     o. Script MUST be run as root.
#
#  Usage:
#
#   ./casperm.sh
#
# -=-=======================================================================-=-
#
#    Copyright (C) Micro Focus 2010-2012.
#    All rights reserved.
#
#    This software is provided "as is" without warranty of any kind.
#    Micro Focus disclaims all warranties, either express or implied,
#    including the warranties of merchantability and fitness for a particular
#    purpose. In no event shall Micro Focus or its suppliers be liable for
#    any damages whatsoever including direct, indirect, incidental,
#    consequential, loss of business profits or special damages, even if
#    Micro Focus or its suppliers have been advised of the possibility of
#    such damages. Some states do not allow the exclusion or limitation of
#    liability for consequential or incidental damages so the foregoing
#    limitation may not apply.
#
# -=-=======================================================================-=-




# -=-=======================================================================-=-
#     AlternativeGetMessage - Get message from var store.         [ Start ]
AlternativeGetMessage()
{
   debug "Start AlternativeGetMessage function"

   set_in=`echo $1 | awk -F: '{ print $1 }'`
   msg_in=`echo $1 | awk -F: '{ print $2 }'`
   msg_in=`printf -- "%02d\n" $msg_in`
   shift 1
   eval msg=\$msg${set_in}_${msg_in}
   printf -- "$msg" "$@"

   debug "End AlternativeGetMessage function"
}

#     AlternativeGetMessage - Get message from var store.           [ End ]
# -=-=======================================================================-=-


# -=-=======================================================================-=-
#     CAS_Permissions - Install and Configure ES.                 [ Start ]
CAS_Permissions()
{
   debug "Start cas_permissions function"

   action=$1
   debug "action" "$action"

   if [ "$action.x" = "prompts.x" ]
   then
      # Prompt user for require information to run CAS perm.
      #----------------------------------------------------------------
        debug "GetMSG 20:1"
      barmsg=`$GETMSG 20:1`
      bar=`center "$barmsg"`
      printit "\n$bar"

      debug "GetMSG 36:1"
      msg1=`$GETMSG 36:1 "COBDIR" "${CAScfg}"`
      printit "\n$msg1"

      # Ask if warning and error logging should be turned on.
         debug "GetMSG 36:2"
      prompt1=`$GETMSG 36:2`
      yorn "\n$prompt1 \c"
      ESsysLog=$?
      debug "ESsysLog" "$ESsysLog"

      # Ask for ES Admin ID.
      if [ "$ESadminID.x" = ".x" ]
      then
         ESadminID="$userid"
      fi

      ESadminIDin="null"
      debug "ESadminIDin" "$ESadminIDin"

         debug "GetMSG 36:3"
      prompt2=`$GETMSG 36:3 "$ESadminID"`
      printit "\n$prompt2 \c"
      read ESadminIDin
      ESadminID=${ESadminIDin:-$userid}

      # Ask for CES Run Time directory.
      CASrtDirin="null"
      debug "CASrtDirin" "$CASrtDirin"

         debug "GetMSG 36:4"
      prompt3=`$GETMSG 36:4 "$CASrtDir"`
      printit "\n$prompt3 \c"
      read CASrtDirin

      CASrtDir=${CASrtDirin:-$CASrtDir}

        debug "GetMSG 20:1"
      barmsg=`$GETMSG 20:1`
      bar=`center "$barmsg"`
      printit "\n$bar"
   else
      # Perform CAS perm action.
      logit "-=-===== start ===== Running CAS configuration ===== start =====-=-"

      debug "umask 000"
      umask 000

      host=`uname -n`
      debug "host" "$host"

      # Copy cciusers.dat to /etc
      #-----------------------------------------------------------------------
      debug "Copy cciusers.dat to /etc"
      if [ -f "${INSTDIR}/${CCIUsersLocation}" ]
      then
         debug "COBDIR/etc/cciusers.dat found."
         if [ ! -f ${CCIUsersDestination} ]
         then
            debug "/etc/cciusers.dat not found adding files to etc."
            cp "${INSTDIR}/${CCIUsersLocation}" ${CCIUsersDestination}
         fi
      else
         logit "WARNING - ${INSTDIR}/${CCIUsersLocation} missing from product."
      fi

      # Create log file area.
      #-----------------------------------------------------------------------
      debug "Create ${MFCobolLogs}"
      if [ ! -d ${MFCobolLogs} ]
      then
         debug "${MFCobolLogs} not found.  creating."
         mkdir -p ${MFCobolLogs}
         chmod 777 ${MFCobolLogs}
      fi

      # Create mf-server.dat.
      #-----------------------------------------------------------------------
      debug "Create $INSTDIR/${MFServerDat}"
      cat <<EOF >> "$INSTDIR/${MFServerDat}"
name=ESDEMO
mfds=mrpi://$host:86
logdir=/var/mfcobol/logs
EOF

      # Create deploy directory if it does not exist.
      #----------------------------------------------------------------------
      if [ ! -d "$INSTDIR/deploy" ]
      then
         debug "COBDIR/deploy not found.  Creating."
         mkdir -p "$INSTDIR/deploy"
      fi
      chmod 777 "$INSTDIR/deploy"

      # Create .mfdeploy file if it does not exist.
      #-----------------------------------------------------------------------
      if [ ! -f "$INSTDIR/deploy/.mfdeploy" ]
      then
         debug "COBDIR/deploy/.mfdeploy not found.  Creating."
         touch "$INSTDIR/deploy/.mfdeploy"
         chmod 444 "$INSTDIR/deploy/.mfdeploy"
         fi

      # Create Transaction System Global/Region Configuration File.
      #-----------------------------------------------------------------------
      debug "Create $INSTDIR/${CAScfg}."
      cat <<EOF > "$INSTDIR/${CAScfg}"
###########################################################
### Transaction System Global/Region Configuration File ###
###########################################################
###              global only directives                 ###
EOF

      if [ "$ESsysLog" = "1" ]
      then
         $echocmd "USESYSCON=Y" >> "$INSTDIR/${CAScfg}"
      else
         $echocmd "USESYSCON=N" >> "$INSTDIR/${CAScfg}"
      fi

      # Get System Administrator user id
      #-----------------------------------------------------------------------
      osname=`uname -s`
      if [ "$osname.x" = "SunOS.x" ]
      then
         GID=`/usr/xpg4/bin/id -g $ESadminID`
      else
         GID=`id -g $ESadminID`
      fi
      debug "GID" "$GID"

      $echocmd "AUTHPGMS=" >> "$INSTDIR/${CAScfg}"
      $echocmd "CASROOT=$CASrtDir" >> "$INSTDIR/${CAScfg}"

      cat <<EOF >> "$INSTDIR/${CAScfg}"
###              other directives                       ###
###########################################################
EOF
      debug "Set permissions on $INSTDIR/${CAScfg}"
      chmod 664 "$INSTDIR/${CAScfg}"

      if [ ! -d "$CASrtDir" ]
      then
         debug "Make $CASrtDir location."
         mkdir -p $CASrtDir
      fi
      debug "Set permissions on $CASrtDir."
      chgrp $GID $CASrtDir
      chmod g+w $CASrtDir

      # If ESadminID value set then change permissions.  If not skip section.
      if [ "$ESadminID.x" != ".x" ]
      then
         # Set correct group ownership
         #---------------------------------------------------------------------
         # debug "Update ownership for .so files in lib."
         for i in cascfg.so dfhextfh.so dfherdio.so dfhff.so dfhpmgen.so \
                  dfhpcgen.so dfhppgen.so dfherdcv.so dfhregns.so dfhpmfio.so \
                  dfhxinit.so cicsecm.so dfhmon.so dfhmoclr.so dfheappc.so \
                  dfhgerr.so dfhgreq.so casgreqt.so casgate.so dfhgerr2.so \
                  dfhgini2.so dfhgfshi.so dfhginit.so dfhgjcpi.so dfhgpca.so \
                  dfhgpcam.so dfht32db.so dfht32sb.so dfhe3270.so dfhe32db.so \
                  dfhecci1.so dfhecnv.so dfheexin.so dfhefctl.so dfheibmq.so \
                  dfhemesg.so dfhepctc.so dfhesche.so dfheserv.so casadmin.so \
                  casmqsrv.so cashtsrv.so casbnsrv.so cas0supp.so dfhesysp.so \
                  dfhetstd.so dfheuser.so dfhexfpf.so dfhgdump.so dfhebms.so \
                  dfheini1.so dfhgreqc.so dfhtex32.so dfhtinit.so dfhrapi.so \
                  dfhrval.so dfhrmsg.so
         do
            if [ -f "$INSTDIR/lib/$i" ]
            then
               # debug "   chgrp, chmod and chown $INSTDIR/lib/$i"
               chgrp $GID "$INSTDIR/lib/$i"
               chmod 555  "$INSTDIR/lib/$i"
               chown -h $ESadminID "$INSTDIR/lib/$i"
            else
               if [ "$i.x" != "cicsecm.so.x" ]
               then
                  logit "WARNING - ${INSTDIR}/lib/$i missing from product."
               fi
            fi
         done

         #---------------------------------------------------------------------
         # debug "Update ownership for .so files in lib/es."
         for i in cascgirh.so MFRHCGI.so valerorh.so SRVRH.so
         do
            if [ -f "$INSTDIR/lib/es/$i" ]
            then
               # debug "   chgrp, chmod and chown $INSTDIR/lib/es/$i"
               chgrp $GID "$INSTDIR/lib/es/$i"
               chmod 555  "$INSTDIR/lib/es/$i"
               chown -h $ESadminID "$INSTDIR/lib/es/$i"
            else
               logit "WARNING - ${INSTDIR}/lib/es/$i missing from product."
            fi
         done

         #---------------------------------------------------------------------
         # debug "Update ownership for .so files in lib/es64."
         for i in cascgirh.so MFRHCGI.so valerorh.so SRVRH.so
         do
            if [ -f "$INSTDIR/lib/es64/$i" ]
            then
               # debug "   chgrp, chmod and chown $INSTDIR/lib/es64/$i"
               chgrp $GID "$INSTDIR/lib/es64/$i"
               chmod 555  "$INSTDIR/lib/es64/$i"
               chown -h $ESadminID "$INSTDIR/lib/es64/$i"
            else
               logit "WARNING - ${INSTDIR}/lib/es64/$i missing from product."
            fi
         done

         #---------------------------------------------------------------------
         # debug "Update ownership for bin files in bin."
         for i in casdup casdup32 casdup64 casinfo casinfo32 casinfo64 \
                  cassrvtm32 cassrvtm64 caspdied32 caspdied64 cascd32 \
                  cascd64 casmgr32 casmgr64 casfile casfile32 casfile64 \
                  casstart casstart32 casstart64 casstop casstop32 casstop64 \
                  casdump casdump32 casdump64 casmq casmq32 casmq64 cas3270 \
                  cas327032 cas327064 casfshr32 casfshr64 casjcp32 casjcp64 \
                  cascci32 cascci64 cas32prt32 cas32prt64 cascrd32 cascrd64 \
                  casatch32 casatch64 cassi cassi32 cassi64
         do
            if [ -f "$INSTDIR/bin/$i" ]
            then
               # debug "   chgrp, chmod and chown $INSTDIR/bin/$i"
               chgrp $GID  "$INSTDIR/bin/$i"
               chmod 550   "$INSTDIR/bin/$i"
               chown -h $ESadminID "$INSTDIR/bin/$i"
            else
               logit "WARNING - ${INSTDIR}/bin/$i missing from product."
            fi
         done

         #---------------------------------------------------------------------
         # debug "Update ownership for _mfpreld.so"
         if [ -f "$INSTDIR/lib/_mfpreld.so" ]
         then
            chown -h $ESadminID "$INSTDIR/lib/_mfpreld.so"
         else
            logit "WARNING - ${INSTDIR}/lib/_mfpreld.so missing from product."
         fi

         #---------------------------------------------------------------------
         # debug "Update permissions and ownership of binfiles."
         for i in cas3270 casdump casdup casfile casinfo cassi casstart casstop
         do
            if [ -f "$INSTDIR/bin/$i" ]
            then
               # debug "   chmod and chown $INSTDIR/bin/$i"
               chmod o+rx "$INSTDIR/bin/$i"
               chown -h $ESadminID "$INSTDIR/bin/$i"
            else
               logit "WARNING - ${INSTDIR}/bin/$i missing from product."
            fi
         done

         #---------------------------------------------------------------------
         # debug "Update permissions and ownership of base files."
         for i in `ls -1 "$INSTDIR/etc/cas"`
         do
            if [ -f "$INSTDIR/etc/cas/$i" ]
            then
               # debug "   chown and chgrp $INSTDIR/etc/cas/$i"
               chown -h $ESadminID "$INSTDIR/etc/cas/$i"
               chgrp $GID          "$INSTDIR/etc/cas/$i"
            else
               logit "WARNING - $i - File not found."
            fi
         done

         #---------------------------------------------------------------------
         # debug "Update permissions and ownership of lib files."
         for i in "$INSTDIR/lib/"dfh*.so
         do
            if [ -f "$i" ]
            then
               # debug "   chown and chgrp $i"
               chown -h $ESadminID "$i"
               chgrp $GID          "$i"
            else
               logit "WARNING - $i - File not found."
            fi
         done

         for i in "$INSTDIR/lib/"cas*.so
         do
            if [ -f "$i" ]
            then
               # debug "   chown and chgrp $i"
               chown -h $ESadminID "$i"
               chgrp $GID          "$i"
            else
               logit "WARNING - $i - File not found."
            fi
         done
      fi

      #-----------------------------------------------------------------------
      debug "Update etc/cobver with PTI=ES"
      cat <<EOF >> "$INSTDIR/etc/cobver"
PTI=ES
EOF

      logit "\nCreating $INSTDIR/etc/mfreg.dat"

      # Get Release Version.
      mfreg_version=`grep cobol "$INSTDIR/etc/cobver" | sed -e 's/cobol.*v//' | sed -e 's/\.[0-9][0-9]//'`

      if [ "$mfreg_version.x" = ".x" ]
      then
         debug "Unable to get mfreg_version from cobver.  Set to 0.0."
         logit "CAS_Permissions - Unable to get mfreg_version from cobver.  Set to 0.0."
         logit "                  File need to be edited with RTS version number."
         mfreg_version=0.0
      fi

      cat <<EOT > "$INSTDIR/etc/mfreg.dat"
Visual COBOL

Visual COBOL/$mfreg_version

Visual COBOL/$mfreg_version/Interface Mapping Toolkit

Visual COBOL/$mfreg_version/Interface Mapping Toolkit/Version
$mfreg_version
Visual COBOL/$mfreg_version/Interface Mapping Toolkit/$mfreg_version/Install

Visual COBOL/$mfreg_version/Interface Mapping Toolkit/$mfreg_version/Install/SCHEMA
$INSTDIR/etc/schema
Visual COBOL/$mfreg_version/Interface Mapping Toolkit/$mfreg_version/Install/BIN
$INSTDIR/lib
Visual COBOL/$mfreg_version/COBOL

Visual COBOL/$mfreg_version/COBOL/Version
$mfreg_version
Visual COBOL/$mfreg_version/COBOL/$mfreg_version/Install

Visual COBOL/$mfreg_version/COBOL/$mfreg_version/Install/WORK
$CASrtDir
EOT
      chmod 444 "$INSTDIR/etc/mfreg.dat"

      debug "umask 022"
      umask 022

      if [ "$InstallLog.x" = ".x" ]
      then
         # Install logfile not set so send to screen.
         "$INSTDIR/bin/mfds" -f $ESadminID
      else
         "$INSTDIR/bin/mfds" -f $ESadminID >> $InstallLog 2>&1
      fi
      RES=$?
      if [ "$RES.x" != "0.x" ]
      then
         logit "Error $RES for: $INSTDIR/bin/mfds -f $ESadminID\n"
         logit "WARNING - Enterprise Server configuration is not complete"
         logit "          To complete Enterprise Server configuration please correct"
         logit "          this error and run $INSTDIR/bin/casperm\n"
      fi

      logit "\nEnterprise Server configuration complete.\n"
      logit "-=-=====  end  ===== Running CAS configuration =====  end  =====-=-"
   fi

   debug "End cas_permissions function"
}
#     CAS_Permissions - Install and Configure ES.                 [ End ]
# -=-=======================================================================-=-


# -=-=======================================================================-=-
#     center - Center text string on screen.                      [ Start ]
center()
{
   debug "Start center function"
   msgstr=$1
   debug "msgstr" "$msgstr"

   ScreenWidth=80
   debug "ScreenWidth" $ScreenWidth

   msgstrlen=`echo $msgstr | wc -c`
   debug "msgstrlen" $msgstrlen
   remainder=`expr $ScreenWidth - $msgstrlen`
   debug "remainder" $remainder
   spacer=`expr $remainder / 2`
   debug "spacer" $spacer

   pad=""
   i=0
   while [ $i -le $spacer ]
   do
      i=`expr $i + 1`
      pad="$pad "
   done
   debug "pad" "$pad"

   echo "$pad$msgstr"

   debug "End center function"
}
#     center - Center text string on screen.                      [ End ]
# -=-=======================================================================-=-


# -=-=======================================================================-=-
#     Debug - Display debug messages.                             [ Start ]
debug()
{
   dbug_msg="$1"
   value="$2"

   if [ "$DEBUG.x" = "1.x" ]
   then
      if [ "$value.x" = ".x" ]
      then
         $echocmd "DEBUG - $dbug_msg"
            logit "DEBUG - $dbug_msg"
      else
         $echocmd "DEBUG - $dbug_msg ...$value..."
            logit "DEBUG - $dbug_msg ...$value..."
      fi
   fi
}
#     Debug - Display debug messages.                             [ End ]
# -=-=======================================================================-=-


# -=-=======================================================================-=-
#     ExitScript - Display exit mesage and set return code.       [ Start ]
ExitScript()
{
   debug "Start ExitScript function"

   returncode=$1
   debug "returncode" $returncode

   if [ "$SILENTINST.x" = "1.x" ]
   then
      SILENTINST=0
      debug "GetMSG 30:1"
      msg1=`$GETMSG 30:1 $LogFileName`

      prodline=`center "$product_name"`

      printit "$prodline\n"
      printit "$msg1\n"
   fi

   if [ "$parentpid.x" = ".x" ]
   then
      debug "parentpid not passed in."
      TidyUp
   else
      touch /tmp/$parentpid.mfinstallskipped
      chmod 777 /tmp/$parentpid.mfinstallskipped
   fi

   # Return return code.
   debug "End ExitScript function"
   exit $returncode

}
#     ExitScript - Display exit mesage and set return code.       [ End ]
# -=-=======================================================================-=-


# -=-=======================================================================-=-
#     GetMessage - Load cobgetmsg tool.                           [ Start ]
GetMessage()
{
   debug "Start GetMessage function"

   LocationIn=$1
   debug "LocationIn" "$LocationIn"

   if [ "$LocationIn.x" = ".x" ]
   then
      # Work out the location of cobgetmsg so that we can get our messages.
      case $0 in
         /*) CURLOC=`dirname "$0"`        ;;
          *) CURLOC=`pwd`/`dirname "$0"`  ;;
      esac
   else
      CURLOC=$LocationIn
   fi

   debug "CURLOC" "$CURLOC"

   # cobgetmsg should be in bin under the current directory.
   COBGETMSG=`command -v "$CURLOC/bin/cobgetmsg" 2> /dev/null`
   debug "COBGETMSG" "$COBGETMSG"

   # Check COBGETMSG variable.  If empty then cobgetmsg missing.
   if [ "$COBGETMSG.x" = ".x" ]
   then
      GETMSG="AlternativeGetMessage"
   else
      # Build up command line for getting messages.
      GETMSG="$COBGETMSG -s2 -p"$CURLOC" -n -e ScriptSDK.lng"

      # Check that a message can be got from lang file.  If not exit.
      $GETMSG 1:1 > /dev/null 2>&1
      RES=$?
      if [ "$RES.x" = "0.x" ]
      then
         debug "Cobgetmessage working."
      else
         printit "$script - GetMessage - cobgetmsg was unable to get message"
         printit "$scriptnamespacer   from $CURLOC/ScriptSDK.lng"
         ExitScript 1
      fi 
   fi
   debug "GETMSG" "$GETMSG"

   debug "End GetMessage function"
}
#     GetMessage - Load cobgetmsg tool.                           [ End ]
# -=-=======================================================================-=-


# -=-=======================================================================-=-
#     logit - Print message to log file.                          [ Start ]
logit()
{
   logit_msg=$1

   if [ "$InstallLog.x" != ".x" ]
   then
      $echocmd "$logit_msg" >> $InstallLog
   fi
}
#     logit - Print message to log file.                          [ End ]
# -=-=======================================================================-=-


# -=-=======================================================================-=-
#     printit - Print message to installation script log file.    [ Start ]
printit()
{
   pit_msg=$1

   if [ "$SILENTINST.x" = "0.x" ]
   then
      $echocmd "$pit_msg"
   fi

   if [ "$InstallLog.x" != ".x" ]
   then
      $echocmd "$pit_msg" >> $InstallLog
   fi

   return 0
}
#     printit - Print message to installation script log file.    [ End ]
# -=-=======================================================================-=-


# -=-=======================================================================-=-
#     Root - Check script is running as root.                     [ Start ]
root()
{
   debug "Start root function"

   if [ ! -w /etc/passwd ]
   then
      SILENTINST=0
        debug "GetMSG 9:1"
      errmsg=`$GETMSG 9:1`
      printit "\n   $script - $errmsg\n\n"
      debug "End root function"
      ExitScript 2
   fi

   debug "End root function"
}
#     Root - Check script is running as root.                     [ End ]
# -=-=======================================================================-=-


# -=-=======================================================================-=-
#     ScriptArgs - Process any command line arguments.            [ Start ]
ScriptArgs()
{
   debug "Start ScriptArgs function"

   failflag=0
   debug "failflag" "$failflag"

   IACCEPTEULA=0
   debug "IACCEPTEULA" "$IACCEPTEULA"

   SILENTINST=0
   debug "SILENTINST" "$SILENTINST"

   LEAVETEMP=0
   debug "LEAVETEMP" "$LEAVETEMP"

   EXTRACTONLY=0
   debug "EXTRACTONLY" "$EXTRACTONLY"

   RMLOGCLEANINST=0
   debug "RMLOGCLEANINST" "$RMLOGCLEANINST"

   INTERACTIVE="silent"
   debug "INTERACTIVE" "$INTERACTIVE"

   DISPLAYEULA=0
   debug "DISPLAYEULA" "$DISPLAYEULA"

   skipargs=0
   matched=0
   ARGC=$#

   while [ $# -gt 0 ]
   do
      args=$1
      debug "args" "$args"

      if [ "$args.x" = "--.x" ]
      then
         debug "End of arguments flag passed in."
         skipargs=1
         debug "skipargs" "$skipargs"
         matched=`expr $matched + 1`
         debug "matched" "$matched"
         break
      fi

      if [ "$args.x" = "-debug.x" -o "$args.x" = "-d.x" ]
      then
         DEBUG=1
         debug "Start ScriptArgs function"
         debug "args" "$args"
         debug "Debug option enabled."
         matched=`expr $matched + 1`
         debug "matched" "$matched"
      fi

      if [ "$args.x" = "-test.x" -o "$args.x" = "-t.x" ]
      then
         TESTMODE=1
         DEBUG=1
         debug "Start ScriptArgs function"
         debug "args" "$args"
         debug "Test option enabled."
         debug "Debug option also enabled."
         matched=`expr $matched + 1`
         debug "matched" "$matched"
      fi

      if [ "$args.x" = "-help.x" -o "$args.x" = "-h.x"  -o "$args.x" = "-?.x" ]
      then
         debug "Display usage message argument passed in."
         SILENTINST=0
         Usage
         exit 0
      fi

      if [ "$args.x" = "-mfhelp.x" ]
      then
         debug "Display Internal Usage message argument passed in."
         SILENTINST=0
         Usage mfversion
         exit 0
      fi

      if [ "$args.x" = "-ISV.x" -o "$args.x" = "-url.x" -o "$args.x" = "-downloadonl.x" ]
      then
         debug "args" "$args"
         debug "Arguments from webinstaller or selfxp installer."
         debug "Do nothing with as not applicable to scritps."
         matched=`expr $matched + 1`
         debug "matched" "$matched"
      fi

      if [ "$args.x" = "-noplatformcheck.x" ]
      then
         PLATFORMCHECK=1
         debug "args" "$args"
         debug "No Platform Check option enabled."
         matched=`expr $matched + 1`
         debug "matched" "$matched"
      fi

      if [ "$args.x" = "-silent.x" -o "$args.x" = "-s.x" ]
      then
         SILENTINST=1
         debug "args" "$args"
         debug "Silent option enabled."
         matched=`expr $matched + 1`
         debug "matched" "$matched"
      fi

      if [ "$args.x" = "-IacceptEULA.x" ]
      then
         IACCEPTEULA=1
         debug "args" "$args"
         debug "EULA Accept option enabled."
         matched=`expr $matched + 1`
         debug "matched" "$matched"
      fi

      if [ "$args.x" = "-leavetemp.x" ]
      then
         LEAVETEMP=1
         debug "args" "$args"
         debug "Leave Temp option enabled."
         matched=`expr $matched + 1`
         debug "matched" "$matched"
      fi

      if [ "$args.x" = "-rmlogcleaninst.x" ]
      then
         RMLOGCLEANINST=1
         debug "args" "$args"
         debug "Remove Log File on clean install option enabled."
         matched=`expr $matched + 1`
         debug "matched" "$matched"
      fi

      if [ "$args.x" = "-extractonly.x" ]
      then
         EXTRACTONLY=1
         LEAVETEMP=1
         IACCEPTEULA=1
         debug "args" "$args"
         debug "Extract Only option enabled."
         matched=`expr $matched + 1`
         debug "matched" "$matched"
      fi

      if [ "$args.x" = "-interactive.x" ]
      then
         INTERACTIVE="interactive"
         debug "args" "$args"
         debug "Run installation interactively."
         matched=`expr $matched + 1`
         debug "matched" "$matched"
      fi

      if [ "$args.x" = "-skipsafenet.x" ]
      then
         SKIPSAFENET=1
         debug "args" "$args"
         debug "Skip SafeNet Installation enabled."
         matched=`expr $matched + 1`
         debug "matched" "$matched"
      fi

      if [ "$args.x" = "-displayEULA.x" ]
      then
         DISPLAYEULA=1
         debug "args" "$args"
         debug "Extract and display full EULA."
         matched=`expr $matched + 1`
         debug "matched" "$matched"
      fi

      instlocarg=`echo $args | sed -e 's/=/ /' | awk '{print $1}'`
      debug "instlocarg" "$instlocarg"

      if [ "$instlocarg.x" = "-installlocation.x" ]
      then
         instlocvalue=`echo $args | sed -e 's/-installlocation//' | sed -e 's/=//' | sed -e 's/"//'`
         debug "instlocvalue" "$instlocvalue"

         if [ "$instlocvalue.x" = ".x" ]
         then
            SILENTINST=0
            failflag=1
            debug "failflag" "$failflag"
            debug "GetMSG 10:1"
            msg1=`$GETMSG 10:1`
            printit "\n$script - ScriptArgs - $msg1"
         else
            DEFCOBDIR="$instlocvalue"
            debug "DEFCOBDIR" "$DEFCOBDIR"
            unset COBDIR
            matched=`expr $matched + 1`
            debug "matched" "$matched"
         fi
      else
         instlocarg=""
      fi

      templocarg=`echo $args | sed -e 's/=/ /' | awk '{print $1}'`
      debug "templocarg" "$templocarg"

      if [ "$templocarg.x" = "-templocation.x" ]
      then
         templocvalue=`echo $args | sed -e 's/-templocation//' | sed -e 's/=//' | sed -e 's/"//'`
         debug "templocvalue" "$templocvalue"

         if [ "$templocvalue.x" = ".x" ]
         then
            SILENTINST=0
            failflag=1
            debug "failflag" "$failflag"
            debug "GetMSG 10:2"
            msg2=`$GETMSG 10:2`
            printit "\n$script - ScriptArgs - $msg2"
         else
            TEMPEXTRAC="$templocvalue/$TEMPEXTRACNAME"
            debug "TEMPEXTRAC" "$TEMPEXTRAC"
            matched=`expr $matched + 1`
            debug "matched" "$matched"
         fi
      else
         templocarg=""
      fi

      runlocarg=`echo $args | sed -e 's/=/ /' | awk '{print $1}'`
      debug "runlocarg" "$runlocarg"

      if [ "$runlocarg.x" = "-runlocation.x" ]
      then
         runlocvalue=`echo $args | sed -e 's/-runlocation//' | sed -e 's/=//' | sed -e 's/"//'`
         debug "runlocvalue" "$runlocvalue"

         if [ "$runlocvalue.x" = ".x" ]
         then
            SILENTINST=0
            failflag=1
            debug "failflag" "$failflag"
            debug "GetMSG 10:4"
            msg4=`$GETMSG 10:4`
            printit "\n$script - ScriptArgs - $msg4"
         else
            run_location="$runlocvalue"
            debug "run_location" "$run_location"
            matched=`expr $matched + 1`
            debug "matched" "$matched"
         fi
      else
         runlocarg=""
      fi

      parentpidarg=`echo $args | sed -e 's/=/ /' | awk '{print $1}'`
      debug "parentpidarg" "$parentpidarg"

      if [ "$parentpidarg.x" = "-parentpid.x" ]
      then
         parentpidvalue=`echo $args | sed -e 's/-parentpid//' | sed -e 's/=//' | sed -e 's/"//'`
         debug "parentpidvalue" "$parentpidvalue"

         if [ "$parentpidvalue.x" = ".x" ]
         then
            SILENTINST=0
            failflag=1
            debug "failflag" "$failflag"
            debug "GetMSG 10:5"
            msg5=`$GETMSG 10:5`
            printit "\n$script - ScriptArgs - $msg5"
         else
            parentpid="$parentpidvalue"
            debug "parentpid" "$parentpid"
            matched=`expr $matched + 1`
            debug "matched" "$matched"
         fi
      else
         parentpidarg=""
      fi

      inputfilearg=`echo $args | sed -e 's/=/ /' | awk '{print $1}'`
      debug "inputfilearg" "$inputfilearg"

      if [ "$inputfilearg.x" = "-inputfile.x" ]
      then
         inputfilevalue=`echo $args | sed -e 's/-inputfile//' | sed -e 's/=//' | sed -e 's/"//'`
         debug "inputfilevalue" "$inputfilevalue"

         if [ "$inputfilevalue.x" = ".x" ]
         then
            SILENTINST=0
            failflag=1
            debug "failflag" "$failflag"
            debug "GetMSG 10:6"
            msg5=`$GETMSG 10:6`
            printit "\n$script - ScriptArgs - $msg5"
         else
            RePackageInputFile="$inputfilevalue"
            debug "RePackageInputFile" "$RePackageInputFile"
            matched=`expr $matched + 1`
            debug "matched" "$matched"
         fi
      else
         inputfilearg=""
      fi

      subdirarg=`echo $args | sed -e 's/=/ /' | awk '{print $1}'`
      debug "subdirarg" "$subdirarg"

      if [ "$subdirarg.x" = "-subdir.x" ]
      then
         subdirvalue=`echo $args | sed -e 's/-subdir//' | sed -e 's/=//' | sed -e 's/"//'`
         debug "subdirvalue" "$subdirvalue"

         if [ "$subdirvalue.x" = ".x" ]
         then
            SILENTINST=0
            failflag=1
            debug "failflag" "$failflag"
            debug "GetMSG 10:7"
            msg5=`$GETMSG 10:7`
            printit "\n$script - ScriptArgs - $msg5"
         else
            RePackageSubDir="$subdirvalue"
            debug "RePackageSubDir" "$RePackageSubDir"
            matched=`expr $matched + 1`
            debug "matched" "$matched"
         fi
      else
         subdirarg=""
      fi

      newscriptarg=`echo $args | sed -e 's/=/ /' | awk '{print $1}'`
      debug "newscriptarg" "$newscriptarg"

      if [ "$newscriptarg.x" = "-newscript.x" ]
      then
         newscriptvalue=`echo $args | sed -e 's/-newscript//' | sed -e 's/=//' | sed -e 's/"//'`
         debug "newscriptvalue" "$newscriptvalue"

         if [ "$newscriptvalue.x" = ".x" ]
         then
            SILENTINST=0
            failflag=1
            debug "failflag" "$failflag"
            debug "GetMSG 10:8"
            msg5=`$GETMSG 10:8`
            printit "\n$script - ScriptArgs - $msg5"
         else
            RePackageNewScript="$newscriptvalue"
            debug "RePackageNewScript" "$RePackageNewScript"
            matched=`expr $matched + 1`
            debug "matched" "$matched"
         fi
      else
         newscriptarg=""
      fi

      newarchivearg=`echo $args | sed -e 's/=/ /' | awk '{print $1}'`
      debug "newarchivearg" "$newarchivearg"

      if [ "$newarchivearg.x" = "-newarchive.x" ]
      then
         newarchivevalue=`echo $args | sed -e 's/-newarchive//' | sed -e 's/=//' | sed -e 's/"//'`
         debug "newarchivevalue" "$newarchivevalue"

         if [ "$newarchivevalue.x" = ".x" ]
         then
            SILENTINST=0
            failflag=1
            debug "failflag" "$failflag"
            debug "GetMSG 10:9"
            msg5=`$GETMSG 10:9`
            printit "\n$script - ScriptArgs - $msg5"
         else
            RePackageNewArchive="$newarchivevalue"
            debug "RePackageNewArchive" "$RePackageNewArchive"
            matched=`expr $matched + 1`
            debug "matched" "$matched"
         fi
      else
         newarchivearg=""
      fi

      productnamearg=`echo $args | sed -e 's/=/ /' | awk '{print $1}'`
      debug "productnamearg" "$productnamearg"

      if [ "$productnamearg.x" = "-productname.x" ]
      then
         productnamevalue=`echo $args | sed -e 's/-productname//' | sed -e 's/=//' | sed -e 's/"//'`
         debug "productnamevalue" "$productnamevalue"

         if [ "$productnamevalue.x" = ".x" ]
         then
            SILENTINST=0
            failflag=1
            debug "failflag" "$failflag"
            debug "GetMSG 10:10"
            msg5=`$GETMSG 10:10`
            printit "\n$script - ScriptArgs - $msg5"
         else
            RePackageProductName="$productnamevalue"
            debug "RePackageProductName" "$RePackageProductName"
            matched=`expr $matched + 1`
            debug "matched" "$matched"
         fi
      else
         productnamearg=""
      fi

      parentnamearg=`echo $args | sed -e 's/=/ /' | awk '{print $1}'`
      debug "parentnamearg" "$parentnamearg"

      if [ "$parentnamearg.x" = "-parentname.x" ]
      then
         parentnamevalue=`echo $args | sed -e 's/-parentname//' | sed -e 's/=//' | sed -e 's/"//'`
         debug "parentnamevalue" "$parentnamevalue"

         if [ "$parentnamevalue.x" = ".x" ]
         then
            SILENTINST=0
            failflag=1
            debug "failflag" "$failflag"
            debug "GetMSG 10:11"
            msg11=`$GETMSG 10:11`
            printit "\n$script - ScriptArgs - $msg11"
         else
            parentname="$parentnamevalue"
            debug "parentname" "$parentname"
            matched=`expr $matched + 1`
            debug "matched" "$matched"
         fi
      else
         parentnamearg=""
      fi

      useridarg=`echo $args | sed -e 's/=/ /' | awk '{print $1}'`
      debug "useridarg" "$useridarg"

      if [ "$useridarg.x" = "-userid.x" ]
      then
         useridvalue=`echo $args | sed -e 's/-userid//' | sed -e 's/=//' | sed -e 's/"//'`
         debug "useridvalue" "$useridvalue"

         userid="$useridvalue"
         debug "userid" "$userid"
         matched=`expr $matched + 1`
         debug "matched" "$matched"
      else
         useridarg=""
      fi

      platformarg=`echo $args | sed -e 's/=/ /' | awk '{print $1}'`
      debug "platformarg" "$platformarg"

      if [ "$platformarg.x" = "-platform.x" ]
      then
         platformvalue=`echo $args | sed -e 's/-platform//' | sed -e 's/=//' | sed -e 's/"//'`
         debug "platformvalue" "$platformvalue"

         if [ "$platformvalue.x" = ".x" ]
         then
            SILENTINST=0
            failflag=1
            debug "failflag" "$failflag"
            debug "GetMSG 10:12"
            msg12=`$GETMSG 10:12`
            printit "\n$script - ScriptArgs - $msg12"
         else
            BuildPlatform="$platformvalue"
            debug "BuildPlatform" "$BuildPlatform"
            matched=`expr $matched + 1`
            debug "matched" "$matched"
         fi
      else
         platformarg=""
      fi

      ESsysLogarg=`echo $args | sed -e 's/=/ /' | awk '{print $1}'`
      debug "ESsysLogarg" "$ESsysLogarg"

      if [ "$ESsysLogarg.x" = "-ESsysLog.x" ]
      then
         ESsysLogvalue=`echo $args | sed -e 's/-ESsysLog//' | sed -e 's/=//' | sed -e 's/"//'`
         debug "ESsysLogvalue" "$ESsysLogvalue"

         if [ "$ESsysLogvalue.x" = ".x" ]
         then
            SILENTINST=0
            failflag=1
            debug "failflag" "$failflag"
            debug "GetMSG 10:13"
            msg12=`$GETMSG 10:13`
            printit "\n$script - ScriptArgs - $msg12"
         else
            ESsysLog="$ESsysLogvalue"
            debug "ESsysLog" "$ESsysLog"
            matched=`expr $matched + 1`
            debug "matched" "$matched"
         fi
      else
         ESsysLogarg=""
      fi

      ESadminIDarg=`echo $args | sed -e 's/=/ /' | awk '{print $1}'`
      debug "ESadminIDarg" "$ESadminIDarg"

      if [ "$ESadminIDarg.x" = "-ESadminID.x" ]
      then
         ESadminIDvalue=`echo $args | sed -e 's/-ESadminID//' | sed -e 's/=//' | sed -e 's/"//'`
         debug "ESadminIDvalue" "$ESadminIDvalue"

         if [ "$ESadminIDvalue.x" = ".x" ]
         then
            SILENTINST=0
            failflag=1
            debug "failflag" "$failflag"
            debug "GetMSG 10:14"
            msg12=`$GETMSG 10:14`
            printit "\n$script - ScriptArgs - $msg12"
         else
            ESadminID="$ESadminIDvalue"
            debug "ESadminID" "$ESadminID"
            matched=`expr $matched + 1`
            debug "matched" "$matched"
         fi
      else
         ESadminIDarg=""
      fi

      CASrtDirarg=`echo $args | sed -e 's/=/ /' | awk '{print $1}'`
      debug "CASrtDirarg" "$CASrtDirarg"

      if [ "$CASrtDirarg.x" = "-CASrtDir.x" ]
      then
         CASrtDirvalue=`echo $args | sed -e 's/-CASrtDir//' | sed -e 's/=//' | sed -e 's/"//'`
         debug "CASrtDirvalue" "$CASrtDirvalue"

         if [ "$CASrtDirvalue.x" = ".x" ]
         then
            SILENTINST=0
            failflag=1
            debug "failflag" "$failflag"
            debug "GetMSG 10:15"
            msg12=`$GETMSG 10:15`
            printit "\n$script - ScriptArgs - $msg12"
         else
            CASrtDir="$CASrtDirvalue"
            debug "CASrtDir" "$CASrtDir"
            matched=`expr $matched + 1`
            debug "matched" "$matched"
         fi
      else
         CASrtDirarg=""
      fi

      shift
   done

   if [ "$SILENTINST.x" = "1.x" ]
   then
      if [ "$IACCEPTEULA.x" = "0.x" ]
      then
         SILENTINST=0
         failflag=1
         debug "failflag" "$failflag"

         debug "GetMSG 10:3"
         msg3=`$GETMSG 10:3 "$scriptnamespacer"`
         printit "\n$script - ScriptArgs - $msg3"
      fi
   fi

   debug "matched" "$matched"
   debug "ARGC" "$ARGC"

   if [ "$matched.x" = "$ARGC.x" ]
   then
      debug "All arguments matched."
   else
      if [ "$skipargs.x" = "0.x" ]
      then
         debug "Need to display usage message as not all arguments passed in where matched."
         failflag=1
      fi
   fi

   if [ "$failflag.x" = "1.x" ]
   then
      SILENTINST=0
      Usage
      debug "End ScriptArgs function"
      exit 1
   fi

   debug "End ScriptArgs function"
}
#     ScriptArgs - Process any command line arguments.            [ End ]
# -=-=======================================================================-=-



# -=-=======================================================================-=-
#     ScriptLogFiles - Deal with script log files.                [ Start ]
ScriptLogFiles()
{
   debug "Start ScriptLogFiles function"

   action=$1
   debug "action" "$action"

   fromfile=$2
   debug "fromfile" "$fromfile"

   if [ "$fromfile.x" = ".x" ]
   then
      debug "GetMSG 25:1"
      msg1=`$GETMSG 25:1`
      printit "$script - ScriptLogFiles - $msg1"
      return 1
   fi

   tofile=$3
   debug "tofile" "$tofile"

   case $action in
      "Reset") if [ -f "$fromfile" ]
               then
                  debug "Removing $fromfile"
                  rm -f "$fromfile" 2> /dev/null
                  debug "Creating New Empty $fromfile"
                  touch "$fromfile" 2> /dev/null
                  debug "Updating permissions of $fromfile"
                  chmod 666 "$fromfile" 2> /dev/null
               else
                  debug "$fromfile not Found.  Skip Reset"
               fi
               ;;
       "Tidy") if [ -f "$fromfile" ]
               then
                  debug "Removing $fromfile"
                  rm -rf "$fromfile"
               fi
               ;;
"Move"|"Copy") if [ "$tofile.x" = ".x" ]
               then
                  debug "GetMSG 25:2"
                  msg2=`$GETMSG 25:2`
                  printit "$script - ScriptLogFiles - $msg2"
                  return 1
               fi

               if [ -f "$fromfile" ]
               then 
                  todirname=`dirname "$tofile"`
                  if [ ! -d "$todirname" ]
                  then
                     mkdir -p "$todirname" 2>/dev/null
                     chmod 777 "$todirname" 2>/dev/null
                  fi
   
                  if [ -f "$tofile" ]
                  then
                     ext=`date +%F.%H:%M:%S`
                     mv -f "$tofile" "$tofile.$ext" 2>/dev/null
                     chmod 666 "$tofile.$ext" 2>/dev/null
                  fi
   
                  if [ "$action.x" = "Move.x" ]
                  then
                     mv -f "$fromfile" "$tofile" 2>/dev/null
                  else
                     cp -f "$fromfile" "$tofile" 2>/dev/null
                  fi
                  chmod 666 "$tofile" 2>/dev/null
               fi
               ;;
           *)  
               debug "GetMSG 25:3"
               msg3=`$GETMSG 25:3 $action`
               printit "$script - ScriptLogFiles - $msg3"
               return 1;;
   esac

   debug "End ScriptLogFiles function"
}
#     ScriptLogFiles - Deal with script log files.                  [ End ]
# -=-=======================================================================-=-

#quote "
# 
#       Copyright (C) Micro Focus 2010-2012.
#       All rights reserved.
# 
#       This is the MF language information file.  Each message is contained
#       within the $quote characters (") and is preceded by the error number.
# 
#       The messages must be kept in (numerical) order.
#       Lines which start with a dollar and white space are treated as comments.
#       Lines with that end in a backslash are concatenated together by gencat.
# 
#       The message text within quotes must not be more than 2048 bytes (as
#       that is the maximum message size on some platforms, such as Solaris)
#       but remember that, in UTF-8, characters can take up to 6 bytes storage.
# 
#       @(#) ScriptSDK.01
# 
#  Sets to Functions List
#  ----------------------------------------
#    Set 1  = CheckDiskSpace
#    Set 2  = CompleteBanner
#    Set 3  = CreateInstallLocation
#    Set 4  = ExtractEncodedPax
#    Set 5  = ExtractFiles
#    Set 6  = GetInstallLocation
#    Set 7  = InstallSafeNetServer
#    set 8  = extract.sh (Self Extracting Shell Script)
#    Set 9  = Root
#    Set 10 = ScriptArgs
#    Set 11 = Usage
#    Set 12 = Welcome
#    Set 13 = yorn
#    Set 14 = install.sh (Main Install Script)
#    Set 15 = GetPlatform
#    Set 16 = esclipe_install.sh (Eclipse Install Script)
#    Set 17 = java_home
#    Set 18 = remotedevsetup
#    Set 19 = InstallEclipse
#    Set 20 = Global String used by all Scripts.
#    Set 21 = CheckPaxSum
#    Set 22 = RegisterInstallation
#    Set 23 = SetCobMode
#    Set 24 = Remotedevinstall scripts.
#    Set 25 = ScriptLogFiles
#    Set 26 = RemoveInstallation
#    Set 27 = repackage.sh (Repackage Utility Script)
#    Set 28 = InstallAdditionalPackages
#    Set 29 = AddPackInstallationLocation
#    Set 30 = ExitScript
#    Set 31 = CreateDesktopIcon
#    Set 32 = BackupInstallation
#    Set 33 = COBDIRset
#    Set 34 = Trapped
#    Set 35 = DisplayEULA
#    Set 36 = cas_permissions
#    Set 37 = configure_openldap.sh
#    Set 38 = UpdateCobopt
# 

#set 1
# =[Start] == CheckDiskSpace ===========================================
# COMMENT - Size of product archive not returned when du -k command run
# CONNENT - against it.
msg1_01="ERROR - Product size unavailable.\n"

# COMMENT - df -k system command return no information.
msg1_02="ERROR - Unable to determine current disk space.\n"

# COMMENT - Display details of disk space requirement.
msg1_03="\n    Current disk space available -%s Mb\n\
            On disk product size -%s Mb\n\
   Temporary disk space required -%s Mb\n"

# COMMENT - There is insufficient disk space on machine to install product.
msg1_05="ERROR - Not enough disk space at %s to install product."

# COMMENT - The location given were product will be installed is not found so
# COMMENT - disk space checks cannot be done.
msg1_06="ERROR - Installation location not found.\n\
%s                            Unable to determine available disk space.\n"

# =[End]===== CheckDiskSpace ===========================================

#set 2
# =[Start] == CompleteBanner ===========================================
# COMMENT - Displayed when installation process is finished.
msg2_01="Installation Complete.\n"

# COMMENT - Following text displayed to tell user how to setup there
# COMMENT - environment to use the product.
# COMMENT - Use cobsetenv to set your environment.
msg2_02="\n\tTo use this version of :\n"
msg2_03="\tRun \"cobsetenv\" to set your environment.\n\n\
\t\t. %s/bin/cobsetenv\n\n"

msg2_04="\n\tDepending on your environment add this to your\n\
\t.profile or .bashrc file(s) in your home directory.\n\n"
# =[End]===== CompleteBanner ===========================================

#set 3
# =[Start] == CreateInstallLocation ====================================
# COMMENT - Prompt for creation of installation directory.
msg3_01="\nInstallation directory %s does not exist.\n\
Do you want to create it? (y/n): "

# COMMENT - Error message - System was unable to create the directory.
msg3_02="Failed to create install directory %s.\n"

# COMMENT - User has said no to creation of installation directory.
# COMMENT - So script cannot continue.
msg3_03="003 - Unable to continue as the install directory does not exist.\n"
# =[End]===== CreateInstallLocation ====================================

#set 4
# =[Start] == ExtractEncodedPax = & = ExtractPax =======================
# COMMENT - Extraction of files from pax file can take a while.
msg4_01="      Please wait extracting files...\n"

# COMMENT - There was an issue extracting the pax file.  non zero return code.
msg4_02="Problem extracting files.\n\
See above messages for details."

# COMMENT - File to be extracted not found.
msg4_03="%s missing.\n"

# COMMENT - uudecode or base64 missing from machine.
msg4_04="ERROR - %s not found.  This system tool is required to install product.\n"
# =[End]===== ExtractEncodedPax = & = ExtractPax =======================

#set 5
# =[Start] == ExtractFiles =============================================
# COMMENT - Tell user the product pax file is being extracted and files copied.
msg5_01="\nInstalling product files to %s.\n"

# COMMENT - Catch all message is the pax extract fails.
msg5_02="001 - Failed to extract product\n\
      due to lack of disk space. RC:- %s\n"
# =[End]===== ExtractFiles =============================================

#set 6
# =[Start] == GetInstallLocation =======================================
# COMMENT - Prompt user for location to install product.
msg6_01="\nEnter the absolute path to the directory where the product should be installed.\n"

# COMMENT - User can enter location or just press return to use default
# COMMENT - installation location.
msg6_02="   Press return to use (%s):\n"

# COMMENT - Not allowed to install product in current working directory.
msg6_03="\n   Installation aborted.\n\
      %s\n\
   You cannot install to this directory, location used by installer.\n\
   Run installer from a different location to be able to install here.\n"

# COMMENT - Format of the path given does not match requirements.
msg6_04="   Absolute pathname required (i.e. must start with '/').\n"

# COMMENT - Ask the user to try entering another path.
msg6_05="   Please enter a different directory.\n"

# COMMENT - Given path already contains files.
# COMMENT - Installation must happen in an empty directory.
msg6_06="   You cannot install into a non-empty directory.\n\
   %s should not exist before starting install.\n"

# COMMENT - User given 5 attempts to enter a path after that the script stops.
msg6_07="005 - Attempts to enter installation location exhausted.\n"

# COMMENT - A product is already installed.
msg6_08="\n   Product already found in %s\n\
   Cobver details are :\n\
 ----------------- Start of cobver -----------------\n"

# COMMENT - Mark end of cobver file.
msg6_09=" ------------------ End of cobver ------------------\n"

# COMMENT - If product is already installed of default location installer
# COMMENT - will suggest alternative location.
msg6_10="\n   Please re-run the installer with the following command line\n\
   to install product in an alternative location.\n\n\
   %s -installlocation=\"%s\"\n\n"

# COMMENT - When running the update product COBDIR has to be set to the
# COMMENT - location of the product to be updated or the installer will
# COMMENT - perform a fresh install.
msg6_11="\n   If you are updating a product set COBDIR environment variable.\n\
   This has to be set to the product you wish to update.\n"

# =[End]===== GetInstallLocation =======================================

#set 7
# =[Start] == InstallSafeNetServer =====================================
# COMMENT - Message given if SafeNet installation fails for some reason.
msg7_01="\nWARNING: There was a problem that prevented the SafeNet RMS license server\n\
         from being installed.  Without the license server installed the\n\
         product will only function for a limited trial period or not at all.\n\n\
         You can install the license server later by running the following\n\
         command:\n\n\
            cd %s\n\
            sh %s\n\n"
# =[End]===== InstallSafeNetServer =====================================

#set 8
# =[Start] == extract.sh ===============================================
# COMMENT - Main script title.
msg8_01="Micro Focus Self Extracting Product Archive..."

# COMMENT - Absolute pathname required.
msg8_02="ERROR - $script - Absolute pathname required (i.e. must start with '/').\n\
        %s   %s\n"

# COMMENT - Tell user there input is invalid and they need to try a different location.
msg8_03="Please enter a different directory.\n"

# COMMENT - Tell user where files are being placed.
msg8_04="Extracting product install files into temporary area\n   %s\n"

# COMMENT - Script needs to be installed as root.  Prompt for root password.
msg8_05="\nInstallation requires root permissions.\n\
   Enter root password to continue.\n\
   Just press Enter to exit.\n\n\
Enter Root "

# COMMENT - File extract ran ok.
msg8_09="Extract complete.\n"

# COMMENT - Displayed when temp extract area could not be created.
msg8_10="Unable to create temporary extract directory.\n\
%s   %s\n\
%s   Use command line argument -templocation=\"Location\"\n\
%s   to set where temporary product are extracted to.\n\n"

# COMMENT - Given file missing.
msg8_11="%s missing.\n"

# COMMENT - Installation incomplete.
msg8_12="Installation was incomplete.\n\
%s   See above message for details.\n"

# =[End]===== extract.sh ===============================================

#set 9
# =[Start] == Root =====================================================
# COMMENT - If the script is not run as root this message is displayed.
msg9_01="You must be running as 'root' to execute this script.\n"
# =[End]===== Root =====================================================

#set 10
# =[Start] == ScriptArgs ===============================================
# COMMENT - silent install option - User has missed the installation
# COMMENT - location argument from the command line.
msg10_01="Product Installation Location not given.\n"

# COMMENT - When temporary extract location is used a location has to be
# COMMENT - included.
msg10_02="Temporary Product Extract Location not given.\n"

# COMMENT - User must give IacceptEULA on command line when running in
# COMMENT - silent mode.
msg10_03="-IacceptEULA command line argument not given.\n\
%s                Required when running installer silently.\n"

# COMMENT - When run location is used a location has to be included.
msg10_04="Run Location directory not given.\n"

# COMMENT - When run parentpid is used a process id has to be included.
msg10_05="Parent Process ID not given.\n"

# COMMENT - When running repackage function file name of input file to process
# COMMENT - not given.
msg10_06="Repackage Input File name not given.\n"

# COMMENT - When running repackage function directory name of where files
# COMMENT - are found not given.
msg10_07="Repackage Sub-Directory not given.\n"

# COMMENT - When running repackage function new script to package is not given.
msg10_08="Repackage New Script to add to Archive not given.\n"

# COMMENT - When running repackage function new archive to package is not given.
msg10_09="Repackage New Archive to add to Archive not given.\n"

# COMMENT - When running repackage function name of the Product or Add pack
# COMMENT - was not given.
msg10_10="Repackage Name of Product or Add Pack not given.\n"

# COMMENT - When -partentname cmd arg is used the name of the program calling
# COMMENT - instal.sh needs to be given.
msg10_11="Parent Program Name not given.\n"

# COMMENT - When -platform cmd arg is used the name the platform being run
# COMMENT - on can be passed in.   Mostly used for testing.
msg10_12="Platform Name not given.\n"

# COMMENT - When -ESsysLog cmd arg is used and Y or N should be supplied.
msg10_13="ESsysLog value not given.\n"

# COMMENT - When -ESadminID cmd arg is used the value of the sys admin which
# COMMENT - ES will run under has to be given.
msg10_14="ESadminID value not given.\n"

# COMMENT - When -CASrtDir cmd arg is used the location for ES files should be
# COMMENT - given.
msg10_15="CASrtDir location not given.\n"

# =[End]===== ScriptArgs ==============================================

#set 11
# =[Start] == Usage ====================================================
# COMMENT - Display usage message detailing silent install options.
msg11_01="\n   %s [ -help|-h|-? ] [ [ -silent|-s ] -IacceptEULA ]\n\
         [ -installlocation=\"Location\" ]\n\n\
   -help|-h|-?                 - Display Install help.\n\
   -silent|-s                  - Install with no prompts or screen output.\n\
   -IacceptEULA                - Confirm you accept EULA.\n\
   -installlocation=\"Location\" - Where product will be installed.\n\
   -displayEULA                - Extract EULA from install.\n"

# COMMENT - Additional command line options for internal use and support use.
msg11_02="   Additional internal use and support command line options.\n\
   -mfhelp            - Display additional command line options.\n\
   --                 - End of arguments.  Any arguments given after this\n\
                        are ignored.\n\
   -debug|-d          - Turn on debug output.  Used for testing and exploring\n\
                        installation issues.\n\
   -test|-t           - Turn on testing mode.  Disabled key actions within\n\
                        script to allow unit testing.\n\
   -noplatformcheck   - Skips platform check to allow script to be run on\n\
                        non-target platforms.\n\
   -skipsafenet       - Skip the installation of SafeNet License Manager and\n\
                        tools.\n\
   -interactive       - Defaults are turned off and script prompts for\n\
                        user interaction.\n\
   -leavetemp         - Do not remove temporary extract area after installation.\n\
   -extractonly       - Extract product archive only.  Installation skipped.\n\
   -rmlogcleaninst    - Remove installation logs from %s\n\
                        if install is successful.\n\
   -runlocation       - Inter-script coms - Tell called scripts where parent\n\
                        scripts is running from.\n\
   -parentpid         - Inter-script coms - Tell called script pid of parent\n\
                        script so flag file can be touch with that pid.\n\
                        File used to indicate successful install.\n\
   -parentname        - Inter-script coms - Name of program or script that\n\
                        called the installer.\n\
   -userid            - User ID of desktop to create Eclipse Icon on.\n\
   -templocation      - Set location of temporary extract location.\n\
   -platform          - Set platform installer is running on.\n\
   -ESsysLog          - Set ES System log location.\n\
   -ESadminID         - Set ES Admin user ID.\n\
   -CASrtDir          - Set location of ES run-time system directory.\n"

# =[End]===== Usage ====================================================

#set 12
# =[Start] == Welcome ==================================================
# COMMENT - Display welcome message.
msg12_01="\n   Welcome to the Micro Focus Product Setup.\n"

# COMMENT - Message displayed in log file when EULA accepted on command line.
msg12_02="      EULA Accepted on command line."

# COMMENT - Get user to confirm they agree with the license agreement.\n"
msg12_03="\nDo you agree to the terms of the License Agreement? (y/n): "

# COMMENT - If the user says no to the license agreement the scripts exists.
msg12_04="\n   You have chosen not to accept the terms of the license.\n\
   Installation terminated at users request.\n\n"

# COMMENT - Display details about license agreement.
msg12_05="   Before installing and using this software product you must\n\
   agree to be bound by the terms and conditions of the end user\n\
   license agreement (\"End User License Agreement\") which\n\
   accompanies this product.  Please take this time to read the\n\
   License Agreement.  If you are not in agreement with the terms\n\
   and conditions of the License Agreement, please contact your\n\
   Account Representative.\n\n"

# COMMENT - Tell user how to get Full EULA document.
msg12_06="\n   If you require a copy of the License Agreement before installing the\n\
   product then answer no and run the installer with the command.\n\n\
      %s -displayEULA\n"

# =[End]===== Welcome ==================================================

#set 13
# =[Start] == yorn =====================================================
# COMMENT - User gets 5 attempts to enter expected response before the
# COMMENT - script exists.
msg13_01="001 - Attempts to respond exhausted.\n"

# COMMENT - Tell user what the expected response should be.
msg13_02="Please enter y or n\n\n"
# =[End]===== yorn =====================================================

#set 14
# =[Start] == install.sh ===============================================
# COMMENT - userid and ESadminID not passed in.  Needed by CAS config.
# COMMENT - unable to contiune install without these values.
msg14_01="\n   Installer was unable to workout user id for the Enterprise Server\n\
   System Administrator.\n\n"

# COMMENT - Tell user how to re-run installer with command line option to
# COMMENT - set ESadminID value.
msg14_02="\n   Please re-run installer with command line argument -ESadminID and pass\n\
   in user id for Enterprise Server System Administrator.\n\n\
      %s -ESadminID=[ User ID ]\n\n"

# COMMENT - Tell user ESadminID value given not found on the machine.
msg14_03="\n   ESadminID value given to installer is not a value user id on this\n\
   machine.\n\
      Value of ESadminID set to %s\n\n"

# =[End]===== install.sh ===============================================

#set 15
# =[Start] == GetPlatform ==============================================
# COMMENT - Platform being installed on does not match what the installer
# COMMENT - is expecting.  User told the miss match and how to work around it.
msg15_01="\nCurrent platform you are installing on is not the platform this product\n\
was created for.\n\
   Expected - %s\n\
     Actual - %s\n\
\nIf you believe this is incorrect then re-run installer with\n\
-noplatformcheck command line option.\n"
# =[End]===== GetPlatform ==============================================

#set 16
# =[Start] == eclipse_install.sh =======================================
# COMMENT - Place holder.  No messages for install.sh yet.
msg16_01="NO MESSAGES YET\n"
# =[End]===== eclipse_install.sh =======================================

#set 17
# =[Start] == java_home ================================================
# COMMENT - To run install Java has to be on the PATH.
msg17_01="   A 32bit Java JRE or 32bit Java JDK installation is required to perform\n\
   the product install and to run parts of the product.\n\
   Please add Java to your PATH.\n"

# =[End]===== java_home ================================================

#set 18
# =[Start] == remotedevsetup ===========================================
# COMMENT - Warning message when remote dev option setup failed.
msg18_01="\nWARNING: There was a problem while running the Remote Development setup.\n\
         This sets up your product to use the Remote Development Functionality.\n\
         You can re-run this script later by running the following\n\
         command:\n\
         sh %s/remotedev/remotedevinstall\n"
# =[End]===== remotedevsetup ===========================================

#set 19
# =[Start] == InstallEclipse ===========================================
# COMMENT - Section banner telling user whats happening.
msg19_01="\nExtracting Eclipse.\n"

# COMMENT - Inform user installation may take a while.
msg19_02="\nPerforming Eclipse install.\n"
# =[End]===== InstallEclipse ===========================================

#set 20
# =[Start] == Global Strings ===========================================
# COMMENT - Separator line.
msg20_01="-=-==================================================================-=-\n"

# COMMENT - Company website.
msg20_02="www.microfocus.com\n"
# =[End]===== Global Strings ===========================================

#set 21
# =[Start] == CheckPaxSum ==============================================
# COMMENT - The check sum of the pax file does not match recorded sum
# COMMENT - within the install script.
msg21_01="Check sum of pax file %s\n\
%s   does not match check sum recorded when product was built.\n\
%s   This may indicate file is corrupt.\n\
%s   Please try downloading file again.\n"

# COMMENT - Displayed while pax file is being summed.
msg21_02="   Checking Product Archive integrity...\n"

# COMMENT - File name passed to sum function not found.
msg21_03="%s not found.  Unable to check sum file.\n"
# =[End]===== CheckPaxSum ==============================================

#set 22
# =[Start] == RegisterInstallation =====================================
# COMMENT - Installation location not found.
msg22_01="Installation location %s not found.\n"

# COMMENT - Function argument not matched.
msg22_02="Function argument does not match expected.\n\
%s   Expected :- install or remove\n\
%s     Actual :- %s\n"

# COMMENT - Product name not passed into function.
msg22_03="Product name not given.\n"
# =[End]===== RegisterInstallation =====================================

#set 23
# =[Start] == SetCobMode ===============================================
# COMMENT - Problem running rts32.  Non-zero return code given.
msg23_01="Unable to execute rts32.  Non-zero return code given.\n"

# COMMENT - RTS32 not found.
msg23_02="rts32 not found in installation location.\n"

# =[End]===== SetCobMode ===============================================

#set 24
# =[Start] == Remotedevinstall =========================================
# COMMENT - COBDIR has to be set to product location before script will run.
msg24_01="You must have \$COBDIR set before running this script.\n"

# COMMENT - etc/cobver not found at COBDIR location so not a valid product.
msg24_02="\$COBDIR must be set to a valid product before running this script.\n"

# COMMENT - File in product missing.
msg24_03="ERROR - %s does not exist.\n"

# COMMENT - Unable to move into given directory.
msg24_04="ERROR - Could not change directory into %s.\n"

# COMMENT - There was a problem extracting tar file into given area.
msg24_05="ERROR - Extraction of %s into %s failed.\n"

# COMMENT - Problem removing directory.
msg24_06="ERROR - Removing $destinationDir directory failed.\n"
# =[End]===== Remotedevinstall =========================================

#set 25
# =[Start] == ScriptLogFiles ===========================================
# COMMENT - Source file which ScriptLogFiles will process was not given.
msg25_01="ERROR - Source file name not given.\n"

# COMMENT - File name ScriptLogFiles will copy or move file to not given.
msg25_02="ERROR - Destination file name not given.\n"

# COMMENT - Action argument for function does not match expected.
msg25_03="ERROR - Unknown Action command.\n\
                    Actual   :- %s\n\
                    Expected :- Reset, Tidy, Move or Copy\n"
# =[End]===== ScriptLogFiles ===========================================

#set 26
# =[Start] == RemoveInstallation =======================================
# COMMENT - Display warning banner.
msg26_01="W A R N I N G\n"

# COMMENT - Tell user what is being removed and impact of the remove.
# COMMENT - Prompt for yes or no.  Script will not continue unless yes
# COMMENT - is entered.
msg26_02="\tThis tool will remove your %s\n\tInstallation.\n\n"

msg26_03="\tAny setting or configuration files under install location\n\
\twill be lost.\n\
\tPlease take a backup of these files before continuing.\n\n\
Are you sure you want to continue?\n\
   Please enter 'yes' or 'no' : "

# COMMENT - Script is being run from wrong directory.
msg26_04="Not a Product directory.\n\
\t%s%s/etc/cobver not found.\n\
\t%sIt would appear product has been partially removed."

# COMMENT - Banner to show removal is complete.
msg26_05="R E M O V A L   C O M P L E T E\n"

# COMMENT - Banner to show removal was skipped.
msg26_06="R E M O V A L   S K I P P E D\n"

# COMMENT - User did not input "yes" or "no".
msg26_07="\nResponse did not match expected.\n\
\tExpected : 'yes' or 'no'.\n\
\t  Actual : '%s'.\n"

# COMMENT - Mark start of cobver file.
msg26_08=" ----------------- Start of cobver -----------------\n"

# COMMENT - Mark end of cobver file.
msg26_09=" ------------------ End of cobver ------------------\n"

# COMMENT - Tell customer to shut down Regions and MFDS before uninstalling. 
msg26_10="\tPlease ensure Enterprise Server Regions and Micro Focus Directory\n\
\tService (MFDS) have been shut down before removing product.\n\n"

# COMMENT - Shutting down MFDS message. 
msg26_11="\nPlease wait...\n\
Micro Focus Directory Service Shutdown -"

# =[End]===== RemoveInstallation =======================================

#set 27
# =[Start] == Repackage ================================================
# COMMENT - Usage message for Repackaging Script.
msg27_01="Usgae : %s -inputfile=FileName -subdir=ISV|AddPacks\n\
              -newscript=FileName.sh -newarchive=FileName.pax\n\
              -productname=\"Product Name\"\n\
      -inputfile      - Original Product Archive file name to add new\n\
                        scripts and packages to.  Extension should be removed.\n\
      -subdir         - Either \"ISV\" or \"AddPacks\".  The sub directories\n\
                        where the product will be stored.\n\
      -newscript      - Name of Script being added.\n\
                          E.g MyInstall.sh\n\
      -newarchive      - Name of Product Archive file being added.\n\
                          E.g MyInstall.pax or MyInstall.tar\n\
      -productname    - Name of Product or Add pack.  Should be quoted.\n\
                          E.g \"My Add Pack 1.0\"\n"

# COMMENT - Processing of package and scripts started.
msg27_02="Processing Started...\n"

# COMMENT - Adding given product files into ISV area of product archive.
msg27_03="Adding product \"%s\" to ISV area.\n"

# COMMENT - Adding given Add Pack files into Add Pack area of product archive.
msg27_04="Adding Add Pack %s to Add Pack area.\n"

# COMMENT - Display details of archive being updated and file being added.
msg27_05="      in %s.pax product archive.\n\
      script  - %s\n\
      archive - %s\n"

# COMMENT - Backup of original pax file made.
msg27_06="      Creating backup of %s.pax\n\
         to %s.pax.bak\n\
         in %s\n"

# COMMENT - Backup of original shell script file made.
msg27_07="      Creating backup of %s.sh\n\
         to %s.sh.bak\n\
         in %s\n"

# COMMENT - Adding a given file into the product archive.
msg27_08="      Adding %s\n"

# COMMENT - manifest.txt is updated with details of Add Pack.
msg27_09="      Inserting details in to %s/manifest.txt\n"

# COMMENT - Update product archive sum in install script.
msg27_10="Updating Product Archive Sum.\n"

# COMMENT - Repackaging process complete.
msg27_11="Packaging complete.\n"

# COMMENT - Remove unwanted work files from temp area.
msg27_12="Tidying up work area.\n"

# COMMENT - Problem removing temp files.
msg27_13="%s - Unable to tidy up %s.\n\
%s   Please manually remove directory.\n"

# COMMENT - Unable to create files as permissions in given directory do
# COMMENT - not allow user to create them.
msg27_14="%s - Unable to create %s in %s directory.\n\
%s   You need write permissions on the current directory for\n\
%s   the script to work.\n"

# COMMENT - Unable to create files as permissions in current directory do
# COMMENT - not allow user to create them.
msg27_15="%s - Unable to create %s in current directory.\n\
%s   You need write permissions on the current directory for\n\
%s   the script to work.\n"

# COMMENT - The archive file being added to existing product archive is not
# COMMENT - found.
msg27_16="%s - New Archive file %s not found.\n"

# COMMENT - The script file being added to existing product archive is not
# COMMENT - found.
msg27_17="%s - New Script file %s not found.\n"

# COMMENT - Command line argument should be ISV or AddPacks for the
# COMMENT - product type.
msg27_18="%s - Package sub directory not match.\n\
%s   Should be \"ISV\" or \"AddPacks\".\n"

# COMMENT - Input file function uses not found.
msg27_19="%s - Input file %s not found.\n"

# COMMENT - The processing of the new files and product archive is complete.
msg27_20="Processing Complete\n"

# COMMENT - Display what is being packaged.
msg27_21="Repackaging %s\n"

# =[End]===== Repackage ================================================

#set 28
# =[Start] == InstallAdditionalPackages ================================
# COMMENT - Sub directory where package are found missing from arguments
# COMMENT - passed to function.
msg28_01="Sub-Directory not given.\n"

# COMMENT - Performing the ISV install action.
msg28_02="Micro Focus - ISV Product installation"

# COMMENT - Performing the Add Pack install action.
msg28_03="Micro Focus - Add Pack Product installation"

# COMMENT - Installing named product
msg28_04="Installing - %s"

# COMMENT - The package the install script was expecting to install is
# COMMENT - missing from product archive.
msg28_05="%s - ERROR - %s missing.\n\
%s   Additional Package installation skipped.\n"

# COMMENT - manifest file used to control whats installed is missing.
msg28_06="%s - %s/manifest.txt not present.\n\
%s   Additional Package installation skipped.\n"

# =[End]===== InstallAdditionalPackages ================================

#set 29
# =[Start] == AddPackInstallationLocation ==============================
# COMMENT - To install add pack -installlocation on the command lines
# COMMENT - need to be used or COBDIR set in the environment.
msg29_01="Install location not given or COBDIR not set to product.\n\
%s   Installation terminated.\n"

# COMMENT - Product found so install can continue.
msg29_02="Product found at %s.\n  Installing Add Pack.\n"

# COMMENT - etc/cobver not found at install location.
msg29_03="Install location does not contain valid product.\n\
%s   %s/etc/cobver not found.\n\
%s   Installation terminated.\n"

# =[End]===== AddPackInstallationLocation ==============================

#set 30
# =[Start] == ExitScript ==============================
# COMMENT - If the script exists due to an error and running in silent
# COMMENT - mode this message is output to tell the user to look at the
# COMMENT - install log file for details.
msg30_01="\tProblem detected, installation terminated.\n\
\tSee %s for full details.\n"

# =[End]===== ExitScript ==============================

#set 31
# =[Start] == CreateDesktopIcon =======================
# COMMENT - If the script exists due to an error and running in silent
msg31_01="\n\tTo create a Desktop Icon for %s\n\
\trun the following shell script as the user you will be logged in as.\n\
\t\t %s/bin/createdesktopicon.sh\n"

# =[End]===== CreateDesktopIcon =======================

#set 32
# =[Start] == BackupInstallation ==============================
# COMMENT - COBDIR given to function is not a directory.
msg32_01="Unable to backup directory %s.  Not a directory.\n\
Unable to continue with update of product.\n"

# COMMENT - For some reason the location set in COBDIR was not moved
# COMMENT - to the new back up location.
msg32_02="Problem backing up %s to %s.\n\
Unable to continue with update of product.\n"

# COMMENT - Backup worked.  Tell user were old files can be found.
msg32_03="\tThe product installed at %s\n\
\thas been backed up to %s\n\
\n\tAll your files and settings are preserved at this location.\n\n\
\tCheck the following files for any user configuration changes.\n\
\t   cob.cfg, cob64.cfg, coboops.cfg, coboops64.cfg,\n\
\t   coboops64_t.cfg, coboops_t.cfg, cobopt, cobopt64,\n\
\t   liblist, liblist64\n"

# COMMENT - Files to backup as part of ED.
msg32_04="\t   deploy/.mfdeploy etc/cas/cas.cfg etc/mf-server.dat\n"

# =[End]===== BackupInstallation ==============================

#set 33
# =[Start] == COBDIRset ==============================
# COMMENT - COBDIR environment variable not set.
msg33_01="COBDIR environment variable not set.\n\
\tThis has to be set to the product you wish to update.\n"

# COMMENT - COBDIR set but does not point to valid product.
msg33_02="Micro Focus Visual COBOL product not found at COBDIR location.\n"

# COMMENT - PRN of product installed and COBDIR does not match PRN of
# COMMENT - update product.
msg33_03="PRN of product at %s\n\
\tdoes not match PRN of update product.\n\
\t\tPRN of install product :- %s\n\
\t\tPRN of update product  :- %s\n"

# COMMENT - Product name in COBDIR/etc/cobver does not match product name
# COMMENT - in the installer.  Can only update like with like.
msg33_04="Product name in %s/etc/cobver\n\
\tdoes not match product name held in installer.\n\n\
\tProduct name in cobver :-\n\t\t%s\n\
\tProduct name in installer :-\n\t\t%s\n\n\
\tIts only possible to update the same product.\n"

# =[End]===== COBDIRset ==============================

#set 34
# =[Start] == Trapped ==============================
# COMMENT - Tell user script interupt single have been detected and install
# COMMENT - is exiting.
msg34_01="\tSignal trapped.\n\
\t\tExiting install Script.\n\
\t\tPlease wait while temp files are removed.\n"

# =[End]===== Trapped ==============================

#set 35
# =[Start] == DisplayEULA ==============================
# COMMENT - Extracting EULA file from payload.
msg35_01="      Please wait extracting EULA...\n"

# COMMENT - File to be extracted not found.
msg35_02="%s missing.\n"

# COMMENT - There was an issue extracting the pax file.  non zero return code.
msg35_03="Problem extracting files.\n\
See above messages for details."

# COMMENT - EULA17.htm and EULA17_jp.htm have been placed in local directory.
# COMMENT - EULA17.htm for English.
# COMMENT - EULA17_jp.htm for Japanese.
msg35_04="\n   Full text EULA can be found in EULA17.htm in current directory.\n"

# =[End]===== DisplayEULA ==============================

#set 36
# =[Start] == CAS_Permissions ==============================
# COMMENT - Tell the user what information they need to supply.
msg36_01="Before continuing this installation, please ensure that you have the\n\
alphanumeric user ID of the Enterprise Server System Administrator to hand.\n\n\
The responses to the following questions will be used to help construct your\n\
global transaction system configuration file (%s/%s)\n\n\
You can find more information in the Configuration and Administration Guide.\n"

# COMMENT - Ask if they want any messages stored in the system log.
msg36_02="   Do you want Error and Warning messages to be displayed via\n\
   the syslog daemon? (y/n):"

# COMMENT - Prompt for user ID ES will run under.
msg36_03="   Enter the alphanumeric user ID of the Enterprise Server System Administrator.\n\
   Press return to use (%s):\n"

# COMMENT - Prompt for location of ES files.
msg36_04="   Enter the directory where you want the Enterprise Server run-time system\n\
   files to reside.  Please enter the absolute path.\n\
   Do not use environment variables.\n\
   Press return to use (%s):\n"

# =[End]===== CAS_Permissions ==============================

#set 37
# =[Start] == configure_openldap.sh ==============================
# COMMENT - Ask user if they want to install OpenLDAP tools.
msg37_01="Do you wish to install the OpenLDAP utilities? (y/n): "

# COMMENT - Required file missing.  Unable to continue running script.
msg37_02="Unable to proceed as %s is missing.\n"

# COMMENT - Library files have been setup.
msg37_03="   OpenLDAP library utilities have been installed.\n"

# COMMENT - The link process for the library file installation failed.
msg37_04="Error linking OpenLDAP library utilities.\n"

# COMMENT - Binary files have been setup.
msg37_05="   OpenLDAP binary utilities have been installed.\n"

# COMMENT - The link process for the binary file installation failed.
msg37_06="Error linking OpenLDAP binary utilities.\n"

# COMMENT - Ask user if they want to uninstall OpenLDAP tools.
msg37_07="Do you wish to uninstall the OpenLDAP utilities now? (y/n): "

# COMMENT - Library files have been removed.
msg37_08="   OpenLDAP library utilities have been uninstalled.\n"

# COMMENT - Problem removing library files.
msg37_09="Error uninstalling OpenLDAP library Utilities.\n"

# COMMENT - Binary files have been removed.
msg37_10="   OpenLDAP binary utilities have been uninstalled.\n"

# COMMENT - Problem removing binary files.
msg37_11="Error uninstalling OpenLDAP binary Utilities.\n"

# COMMENT - OpenLDAP directory missing.  Unable to contineu with install.
msg37_12="openladp directory not found in product.\n\tInstallation skipped.\n"

# =[End]===== configure_openldap.sh ==============================

#set 38
# =[Start] == UpdateCobopt ==============================
# COMMENT - Warn user that cobopt file was not updated.
msg38_01="   WARNING - Problem updating %s/etc/cobopt\n\n\
      The version of gcc installed on this machine does not match the\n\
      version this product was built or compatibility tested with.\n\n\
      Supported versions :\n"

# =[End]===== UpdateCobopt ==============================


# -=-=======================================================================-=-
#     yorn - Ask Yes or No question to user.                      [ Start ]
yorn ()
{
   debug "Start YORN function"

   loopcounter=0
   debug "loopcounter" $loopcounter

   YN=b
   debug "YN" $YN
   while [ "$YN" != "n" -a "$YN" != "no" -a \
           "$YN" != "N" -a "$YN" != "NO" -a \
           "$YN" != "y" -a "$YN" != "yes" -a \
           "$YN" != "Y" -a "$YN" != "YES" -a \
           "$YN" != "Yes" -a "$YN" != "No" ]; do
           printit "$*"
           read YN
           if [ "$YN" = "y" -o "$YN" = "yes" -o "$YN" = "Yes" -o \
                "$YN" = "Y" -o "$YN" = "YES" ]; then
                   return 1
           fi
           if [ "$YN" = "n" -o "$YN" = "no" -o "$YN" = "No" -o \
                "$YN" = "N" -o "$YN" = "NO" ]; then
                   return 0
           fi

           loopcounter=`expr $loopcounter + 1`
           debug "loopcounter" $loopcounter

           if [ $loopcounter -gt 4 ]
           then
              debug "loopcounter" $loopcounter
              debug "Been around loop 5 times now exiting."
              debug "GetMSG 13:1"
              msg1=`$GETMSG 13:1`
              printit "$script - yorn - $msg1"
              debug "End YORN function"
              ExitScript 13
           fi
           debug "GetMSG 13:2"
           msg2=`$GETMSG 13:2`
           printit "$msg2"
   done
   debug "End YORN function"
}
#     yorn - Ask Yes or No question to user.                      [ End ]
# -=-=======================================================================-=-

# -=-=======================================================================-=-
#     Usage - Display Usage message.                              [ Start ]
Usage()
{
   debug "Start Usage function"

   printit "Usage : $0"

   debug "End Usage function"
}
#     Usage - Display Usage message.                              [ End ]
# -=-=======================================================================-=-

# -=-=======================================================================-=-
#     TidyUp - Move log files and tidy working files.             [ Start ]
TidyUp()
{
   debug "Start TidyUp function"

   debug "Skip Tidyup."

   debug "End TidyUp function"
}
#     TidyUp - Move log files and tidy working files.             [ End ]
# -=-=======================================================================-=-

# -=-=======================================================================-=-
#                    S C R I P T   S T A R T S   H E R E
# -=-=======================================================================-=-

test `uname -s` = Linux && echocmd="echo -e" || echocmd="echo"

# -=-----------------------------------------------------
#   Script settings.
          scriptname="casperm.sh"
              script=`basename $0`
    scriptnamespacer=`echo $script | sed -e 's/./ /g'`

    CCIUsersLocation="etc/cciusers.dat"
 CCIUsersDestination="/etc/cciusers.dat"
         MFCobolLogs="/var/mfcobol/logs"
         MFServerDat="etc/mf-server.dat"
            ESsysLog=1
            CASrtDir="/var/mfcobol/es"
              CAScfg="etc/cas/cas.cfg"

               DEBUG=0
            TESTMODE=0
          SILENTINST=0

# -=-----------------------------------------------------
# Load Localisation tool.
GetMessage

# -=-----------------------------------------------------
#   Check command line for any parameters that
#   have been passed in.
ScriptArgs "$@"

debug "Scripts Pre-Defined Variables..."

debug "scriptname" "$scriptname"
debug "script" "$script"
debug "scriptnamespacer" "$scriptnamespacer"

debug "CCIUsersLocation" "$CCIUsersLocation"
debug "CCIUsersDestination" "$CCIUsersDestination"
debug "MFCobolLogs" "$MFCobolLogs"
debug "MFServerDat" "$MFServerDat"
debug "ESsysLog" "$ESsysLog"
debug "CASrtDir" "$CASrtDir"
debug "CAScfg" "$CAScfg"

debug "DEBUG" "$DEBUG"
debug "TESTMODE" "$TESTMODE"
debug "SILENTINST" "$SILENTINST"

if [ "$TESTMODE.x" = "0.x" ]
then
   debug "umake 022"
   umask 022

   # -=-----------------------------------------------------
   #   Unset unwanted Cobol Environment settings.
   unset COBPATH
   unset COBDATA
   unset COBSW

     debug "GetMSG 20:1"
   barmsg=`$GETMSG 20:1`
   bar=`center "$barmsg"`
   printit "\n$bar"

   line0=`center "Micro Focus CAS Permissions Configuration Tool"`
   wwwmsg=`$GETMSG 20:2`
   www=`center $wwwmsg`

   printit "$line0"
   printit "$www"

   # -=-----------------------------------------------------
   #   Check Root permissions.
   root

   # -=-----------------------------------------------------
   #   Check COBDIR is set.
   if [ "$COBDIR.x" != ".x" ]
   then
      if [ ! -f "${COBDIR}/etc/cobver" ]
      then
         # cobver not found.
         SILENTINST=0
           debug "GetMSG 33:2"
         errmsg=`$GETMSG 33:2`
         printit "\n\t$errmsg\n\n"
         ExitScript 3
      fi
   else
      # COBDIR not set
      SILENTINST=0
        debug "GetMSG 33:1"
      errmsg=`$GETMSG 33:1`
      printit "\n\t$errmsg\n\n"
      ExitScript 4
   fi

   # -=-----------------------------------------------------
   #   Set INSTDIR for CAS_Permissions to use.
   INSTDIR=$COBDIR

   # -=-----------------------------------------------------
   #   Set variable to id of user running script.
   if [ "$userid.x" = ".x" ]
   then
      userid=`who am i | awk '{print $1}'`
   fi

   # -=-----------------------------------------------------
   #   Get CAS settings.
   CAS_Permissions "prompts"

   # -=-----------------------------------------------------
   #   Perform configuration.
   CAS_Permissions "actions"

   printit "\n$bar\n"

fi

# -=-=======================================================================-=-
#                              E N D   O F   S C R I P T
# -=-=======================================================================-=-
