#!/bin/sh 

AWK=/usr/bin/awk
NAWK=/usr/bin/nawk
ECHO=/usr/bin/echo
MV=/usr/bin/mv
CP=/usr/bin/cp
RM=/usr/bin/rm
GREP=/usr/bin/grep
SED=/usr/bin/sed
HEAD=/usr/bin/head
TOUCH=/usr/bin/touch

VERSION_FILE=.version

##############################################################
#
# Test if the sdk package is installed.
#
##############################################################
check_for_sdk() {
   pkginfo -q SUNWamsdk
   if [ $? -eq 0 ]; then
      sdk="yes"
   else
      sdk="no"
   fi
}

##############################################################
#
# Test if the services package is installed.
#
##############################################################
check_for_svc() {
   pkginfo -q SUNWamsvc
   if [ $? -eq 0 ]; then
      svc="yes"
   else
      svc="no"
   fi
}

##############################################################
#
# Test if the console package is installed.
#
##############################################################
check_for_con() {
   pkginfo -q SUNWamcon
   if [ $? -eq 0 ]; then
      con="yes"
   else
      con="no"
   fi
}

##############################################################
#
# Test for web server services package is installed.
#
##############################################################
check_for_iws() {
   pkginfo -q SUNWamsws
   if [ $? -eq 0 ]; then
      iws="yes"
   else
      iws="no"
   fi
}

##############################################################
#
# Test if common domain services package is installed.
#
##############################################################
check_for_fcd() {
   pkginfo -q SUNWamfcd
   if [ $? -eq 0 ]; then
      fcd="yes"
   else
      fcd="no"
   fi
}

##############################################################
#
# Test if cross domain sso package is installed.
#
##############################################################
check_for_cds() {
   pkginfo -q SUNWamcds
   if [ $? -eq 0 ]; then
      cds="yes"
   else
      cds="no"
   fi
}

##############################################################
#
# Test if samples are installed.
#
##############################################################
check_for_sam() {
   pkginfo -q SUNWamsam
   if [ $? -eq 0 ]; then
      sam="yes"
   else
      sam="no"
   fi
}

##############################################################
#
# Test if console is deployed on app server.
#
##############################################################
check_for_sac() {
   pkginfo -q SUNWamsac
   if [ $? -eq 0 ]; then
      sac="yes"
   else
      sac="no"
   fi
}

##############################################################
#
# Test if console is deployed on web logic.
#
##############################################################
check_for_wlc() {
   pkginfo -q SUNWamwlc
   if [ $? -eq 0 ]; then
      wlc="yes"
   else
      wlc="no"
   fi
}

##############################################################
#
# Test if console is deployed on web sphere.
#
##############################################################
check_for_wsc() {
   pkginfo -q SUNWamwsc
   if [ $? -eq 0 ]; then
      wsc="yes"
   else
      wsc="no"
   fi
}


##############################################################
#
#
#
##############################################################
get_base_dir() {
  check_for_sdk
  if [ "$sdk" = "yes" ]; then
    pkg="SUNWamsdk"
  else
     check_for_fcd
     if [ "$fcd" = "yes" ]; then
        pkg="SUNWamfcd"
     else
         check_for_cds
         if [ "$cds" = "yes" ]; then
           pkg="SUNWamcds"
         else
           exit
         fi
     fi
  fi

  BASE_DIR=`pkginfo -r $pkg`
}

##############################################################
#
# Replace a line of text in the given file
#
##############################################################
replace_line() {
  file=$1
  match=$2
  new=$3

  $CP $file $file-orig-$$
  sed -e "
/$match/ {
c\\
$new
}" $file > $file-tmp
mv $file-tmp $file
rm $file-orig-$$
}

##############################################################
#
# Replace a block of text in a file.
#
##############################################################
replace_block() {
  FILE=$1
  START_TAG=$2
  END_TAG=$3
  NEW_TEXT_FILE=$4

  $CP $FILE $FILE-tmp
  $NAWK 'BEGIN {
           IN_REPLACE = 0;
         };
         {
           if (index($0, START_TAG) > 0) {
            while (getline str < NEW_TEXT_FILE > 0) {
              if (length(str) > 0) {
                printf("%s\n", str);
              }
            }
             IN_REPLACE = 1;
           } else if (index($0, END_TAG) > 0) {
             if (IN_REPLACE == 0) {
               printf("%s\n", $0);
             }
             IN_REPLACE = 0;
           } else {
             if (IN_REPLACE == 0) {
               printf("%s\n", $0);
             }
           }
         };
         END {};' START_TAG="$START_TAG" END_TAG="$END_TAG" NEW_TEXT_FILE="$NEW_TEXT_FILE" $FILE-tmp > $FILE
  $RM -f $FILE-tmp
}

##############################################################
#
# Delete block
#
##############################################################
delete_block() {
  FILE=$1
  START_TAG=$2
  END_TAG=$3

  $CP $FILE $FILE-tmp
  $NAWK 'BEGIN {
           IN_REPLACE = 0;
         };
         {
           if (index($0, START_TAG) > 0) {
             IN_REPLACE = 1;
           } else if (index($0, END_TAG) > 0) {
             if (IN_REPLACE == 0) {
               printf("%s\n", $0);
             }
             IN_REPLACE = 0;
           } else {
             if (IN_REPLACE == 0) {
               printf("%s\n", $0);
             }
           }
         };
         END {};' START_TAG="$START_TAG" END_TAG="$END_TAG" $FILE-tmp > $FILE
  $RM -f $FILE-tmp
}

##############################################################
#
# Restores a file to the prepatch state.
#
##############################################################
restore_file() {
    file=$1
    backupVersion=.$file-version-61-13
    backupFile=.$file.bak

    if [ -f $file ]; then
	cp -f $file $backupFile
    fi

    if [ -f $backupVersion ]; then
	cp -f $backupVersion $file
	$TOUCH $file
    fi
}

##############################################################
#
# Run an ldapsearch command and send the results 
# to a file.
#
##############################################################
ldap_search() {
   cd $INSTALL_DIR/bin
   if [ "$DS_SSL" = "true" ]; then
      ./ldapsearch -Z -o -P $CERTDB -b "ou=1.0,ou=$1,ou=services,$ROOT_SUFFIX" -D "$DIR_MANAGER" -w "$PASSWORD" -h $DS_HOST -p $DS_PORT "(objectclass=*)" sunserviceschema > $2
   else
      ./ldapsearch -o -b "ou=1.0,ou=$1,ou=services,$ROOT_SUFFIX" -D "$DIR_MANAGER" -w "$PASSWORD" -h $DS_HOST -p $DS_PORT "(objectclass=*)" sunserviceschema > $2
   fi
}

##############################################################
#
# Run an ldapmodify command on the given file.
#
##############################################################
ldap_modify() {
   cd $INSTALL_DIR/bin
   if [ "$DS_SSL" = "true" ]; then
      ./ldapmodify -Z -c -P $CERTDB -D "$DIR_MANAGER" -w "$PASSWORD" -h $DS_HOST -p $DS_PORT -f $1 > /dev/null 2>&1
   else
      ./ldapmodify -c -D "$DIR_MANAGER" -w "$PASSWORD" -h $DS_HOST -p $DS_PORT -f $1 > /dev/null 2>&1
   fi
}

##############################################################
#
# main start
#
##############################################################

get_base_dir
INSTALL_DIR=$BASE_DIR/SUNWam
LD_LIBRARY_PATH=$BASE_DIR/SUNWam/ldaplib/solaris/sparc/ldapsdk:$BASE_DIR/SUNWam/lib/solaris/sparc/jss:/usr/lib/mps/secv1:/usr/lib/mps

rm -f /tmp/.patch.ans 2>/dev/null
cd $BASE_DIR/SUNWam/lib
if [ -f .version-61 ]; then
    $MV .version-61 .version
else 
    $ECHO "Sun One Identity Server 6.1" > .version
fi

if [ -d $BASE_DIR/SUNWam/ldaplib/solaris/sparc/ldapsdk ]; then
   export LD_LIBRARY_PATH

   ROOT_SUFFIX=`$GREP com.iplanet.am.rootsuffix $INSTALL_DIR/lib/AMConfig.properties | /$AWK ' BEGIN { FS="=" } { ORS="" } { print $2; for (i=3;i<=NF;i++ ) print "=" $i } `

fi

#
# restore the files
#
check_for_sdk
if [ "$sdk" = "yes" ]; then
   JDK=`$GREP com.iplanet.am.jdk.path $INSTALL_DIR/lib/AMConfig.properties | $SED -e "s/com.iplanet.am.jdk.path=//g"`
   cd $INSTALL_DIR/lib
   restore_file AMConfig.properties

   if [ -d $BASE_DIR/SUNWam/ldaplib/solaris/sparc/ldapsdk ]; then
      BASE64="$JDK/bin/java -classpath $INSTALL_DIR/lib/am_sdk.jar com.iplanet.services.util.Base64"

      cd $INSTALL_DIR/bin
      ldap_search iPlanetAMSAMLService /tmp/amSAML.xml.$$
      LDAP_MODIFY=`$GREP "name=\"iplanet-am-saml-password\"  syntax=\"password\"" /tmp/amSAML.xml.$$`
      if [ "$LDAP_MODIFY" = "" ]; then
         SERVICE_BASE=`head -1 /tmp/amSAML.xml.$$`
         $SED -n -e '/sunserviceschema=<?xml version="1.0" encoding="UTF-8"?>/,/<\/ServicesConfiguration>/p' /tmp/amSAML.xml.$$ | sed -e "s/sunserviceschema=//g" > /tmp/amSAML.xml.$$.1
         replace_line /tmp/amSAML.xml.$$.1 "<AttributeSchema any=\"adminDisplay\"  cosQualifier=\"default\"  i18nKey=\"a131\"  name=\"iplanet-am-saml-password\"  syntax=\"encrypted_password\"  type=\"single\" >" "<AttributeSchema any=\"adminDisplay\"  cosQualifier=\"default\"  i18nKey=\"a131\"  name=\"iplanet-am-saml-password\"  syntax=\"password\"  type=\"single\" >"
         ENCODED=`$BASE64 /tmp/amSAML.xml.$$.1`
         $ECHO "dn: $SERVICE_BASE
changetype: modify
replace: sunserviceschema
sunserviceschema:: $ENCODED" > /tmp/amSAML.xml.$$
         ldap_modify /tmp/amSAML.xml.$$
         $RM /tmp/amSAML.xml.$$ /tmp/amSAML.xml.$$.1

         ldap_search iPlanetAMProviderConfigService /tmp/amProviderConfig.xml.$$
         SERVICE_BASE=`head -1 /tmp/amProviderConfig.xml.$$`
         $SED -n -e '/sunserviceschema=<?xml version="1.0" encoding="UTF-8"?>/,/<\/ServicesConfiguration>/p' /tmp/amProviderConfig.xml.$$ | sed -e "s/sunserviceschema=//g" > /tmp/amProviderConfig.xml.$$.1
         delete_block /tmp/amProviderConfig.xml.$$.1 iplanet-am-name-registration-profile AttributeSchema
         delete_block /tmp/amProviderConfig.xml.$$.1 iplanet-am-name-registration-url AttributeSchema
         delete_block /tmp/amProviderConfig.xml.$$.1 iplanet-am-name-registration-return-url AttributeSchema
         delete_block /tmp/amProviderConfig.xml.$$.1 iplanet-am-name-registration-after-sso AttributeSchema
         delete_block /tmp/amProviderConfig.xml.$$.1 iplanet-am-name-registration-indicator AttributeSchema
         echo '                                                <AttributeSchema cosQualifier="default"  i18nKey="a56"  name="iplanet-am-name-registration-indicator"  syntax="boolean"  type="single" >
                                                       <DefaultValues>
                                                               <Value>false</Value>
                                                       </DefaultValues>
                                       </AttributeSchema>' > /tmp/.new_file
         replace_block /tmp/amProviderConfig.xml.$$.1 iplanet-am-name-registration-donepage-url AttributeSchema /tmp/.new_file

         $ECHO `$HEAD -1 /tmp/amProviderConfig.xml.$$.1` > /tmp/amProviderConfig.xml.$$
         $SED -n -e '/<ServicesConfiguration>/,/<\/ServicesConfiguration>/p' /tmp/amProviderConfig.xml.$$.1 >> /tmp/amProviderConfig.xml.$$

         ENCODED=`$BASE64 /tmp/amProviderConfig.xml.$$`
         $ECHO "dn: $SERVICE_BASE
changetype: modify
replace: sunserviceschema
sunserviceschema:: $ENCODED" > /tmp/amProviderConfig.xml.$$
         ldap_modify /tmp/amProviderConfig.xml.$$
         $RM /tmp/amProviderConfig.xml.$$ /tmp/amProviderConfig.xml.$$.1 /tmp/.new_file

         ldap_search iPlanetAMClientDetection /tmp/iPlanetAMClientDetection.xml.$$
         SERVICE_BASE=`$HEAD -1 /tmp/iPlanetAMClientDetection.xml.$$`
         $SED -n -e '/sunserviceschema=<?xml version="1.0" encoding="UTF-8"?>/,/<\/ServicesConfiguration>/p' /tmp/iPlanetAMClientDetection.xml.$$ | $SED -e "s/sunserviceschema=//g" > /tmp/iPlanetAMClientDetection.xml.$$.1
         replace_line /tmp/iPlanetAMClientDetection.xml.$$.1 "clientType=genericHTML" "<Value>clientType=genericHTML|userAgent=Mozilla/4.0|contentType=text/html|cookieSupport=true|fileIdentifier=html|filePath=html|charset=UTF-8</Value>"
         ENCODED=`$BASE64 /tmp/iPlanetAMClientDetection.xml.$$.1`
         $ECHO "dn: $SERVICE_BASE
changetype: modify
replace: sunserviceschema
sunserviceschema:: $ENCODED" > /tmp/iPlanetAMClientDetection.xml.$$
         ldap_modify /tmp/iPlanetAMClientDetection.xml.$$
         $RM /tmp/iPlanetAMClientDetection.xml.$$ /tmp/iPlanetAMClientDetection.xml.$$.1

         ldap_search iPlanetAMAuthCertService /tmp/iPlanetAMAuthCertService.xml.$$
         SERVICE_BASE=`$HEAD -1 /tmp/iPlanetAMAuthCertService.xml.$$`
         $SED -n -e '/sunserviceschema=<?xml version="1.0" encoding="UTF-8"?>/,/<\/ServicesConfiguration>/p' /tmp/iPlanetAMAuthCertService.xml.$$ | $SED -e "s/sunserviceschema=//g" > /tmp/iPlanetAMAuthCertService.xml.$$.1
         $ECHO '                <AttributeSchema cosQualifier="default"  i18nKey=""  name="iplanet-am-auth-cert-gw-cert-auth-enabled"  syntax="string"  type="list" >
                    <DefaultValues>
                        <Value>none</Value>
                    </DefaultValues>
                </AttributeSchema>' > /tmp/.new_file
         replace_block /tmp/iPlanetAMAuthCertService.xml.$$.1 iplanet-am-auth-cert-gw-cert-auth-enabled AttributeSchema /tmp/.new_file
         ENCODED=`$BASE64  /tmp/iPlanetAMAuthCertService.xml.$$.1`
         $ECHO "dn: $SERVICE_BASE
changetype: modify
replace: sunserviceschema
sunserviceschema:: $ENCODED" > /tmp/iPlanetAMAuthCertService.xml.$$
         ldap_modify /tmp/iPlanetAMAuthCertService.xml.$$
         $RM /tmp/iPlanetAMAuthCertService.xml.$$ /tmp/iPlanetAMAuthCertService.xml.$$.1 /tmp/.new_file

      fi
   fi

   if [ -d $BASE_DIR/SUNWam/config/xml ]; then
      cd $BASE_DIR/SUNWam/config/xml
      restore_file amSAML.xml
      restore_file amProviderConfig.xml
      restore_file amClientDetection.xml
      restore_file amAuthCert.xml
   fi

fi

check_for_con
check_for_sac
check_for_wlc
check_for_wsc
if [ "$con" = "yes" -o "$sac" = "yes" -o "$wlc" = "yes" -o "$wsc" = "yes" ]; then
   AM_CONSOLE_JAR_DIR=$INSTALL_DIR/web-apps/applications/WEB-INF/lib
   AM_CONSOLE_JSP_DIR=$INSTALL_DIR/web-apps/applications
   cd $AM_CONSOLE_JAR_DIR
   
   restore_file am_console.jar

   cd $AM_CONSOLE_JSP_DIR/console/base
   rm AMPost.jsp 2>/dev/null
fi

check_for_sac
if [ "$sac" = "yes" ]; then
   IAS7INSTANCEDIR=`$GREP IAS7INSTANCEDIR /var/sadm/pkg/SUNWamsac/pkginfo | $SED -e "s/IAS7INSTANCEDIR=//g"`
   cd ${IAS7INSTANCEDIR}/config
   restore_file server.xml
   restore_file server.policy

fi

check_for_wlc
if [ "$wlc" = "yes" ]; then
   WL61_BASE=`$GREP WL61_BASE /var/sadm/pkg/SUNWamwlc/pkginfo | $SED -e "s/WL61_BASE=//g"`
   WL61_PROD_DIR=`$GREP WL61_PROD_DIR /var/sadm/pkg/SUNWamwlc/pkginfo | $SED -e "s/WL61_PROD_DIR=//g"`
   WL61_DOMAIN=`$GREP WL61_DOMAIN /var/sadm/pkg/SUNWamwlc/pkginfo | $SED -e "s/WL61_DOMAIN=//g"`
   cd ${WL61_BASE}/${WL61_PROD_DIR}/config/${WL61_DOMAIN}
   restore_file startWebLogic.sh
   restore_file startManagedWebLogic.sh
fi

check_for_wsc
if [ "$wsc" = "yes" ]; then
   echo "restore_file SUNWamwsc classpath"
fi

# get DS info first
if [ ! -f /tmp/.patch.ans ];then
   touch /tmp/.patch.ans
   DIR_MANAGER="cn=Directory Manager"
   $ECHO
   $ECHO "What is the dn of the Directory Manager [$DIR_MANAGER] \c"
   read ANS
   if [ "$ANS" != "" ]; then
      DIR_MANAGER=$ANS
   fi
   $ECHO "DIR_MANAGER=$DIR_MANAGER" >> /tmp/.patch.ans

   while [ 1 ];do
    $ECHO "What is the password for the Directory Manager [] \c"
    stty -echo
    read PASSWORD_ANS
    stty echo
    if [ "$PASSWORD_ANS" != "" ]; then
      PASSWORD=$PASSWORD_ANS
      $ECHO
      break
    else
      $ECHO "\nPlease enter the password."
    fi
    $ECHO
   done
   $ECHO "DS_PASSWORD=$PASSWORD_ANS" >> /tmp/.patch.ans
fi

get_base_dir
if [ ! -d $BASE_DIR/SUNWam/ldaplib/ldapsdk ]; then
   $ECHO "Can't locate the LDAP lib at $BASE_DIR/SUNWam/ldaplib/ldapsdk"
   exit 1
fi

LD_LIBRARY_PATH=$BASE_DIR/SUNWam/ldaplib/ldapsdk:$BASE_DIR/SUNWam/lib/jss:/usr/lib/mps/secv1:/usr/lib/mps 
export LD_LIBRARY_PATH

INSTALL_DIR=$BASE_DIR/SUNWam
DS_HOST=`$GREP com.iplanet.am.directory.host $INSTALL_DIR/lib/AMConfig.properties | $AWK ' BEGIN { FS="=" } {print $2}`
DS_PORT=`$GREP com.iplanet.am.directory.port $INSTALL_DIR/lib/AMConfig.properties | $AWK ' BEGIN { FS="=" } {print $2}`
DS_SSL=`$GREP com.iplanet.am.directory.ssl.enabled $INSTALL_DIR/lib/AMConfig.properties | $SED -e "s/com.iplanet.am.directory.ssl.enabled=//g"`
CERTDB_DIR=`$GREP com.iplanet.am.admin.cli.certdb.dir $INSTALL_DIR/lib/AMConfig.properties | $SED -e "s/com.iplanet.am.admin.cli.certdb.dir=//g"`
CERTDB_PREFIX=`$GREP com.iplanet.am.admin.cli.certdb.prefix  $INSTALL_DIR/lib/AMConfig.properties | $SED -e "s/com.iplanet.am.admin.cli.certdb.prefix=//g"`
CERTDB=$CERTDB_DIR/"$CERTDB_PREFIX"cert7.db


cd $INSTALL_DIR/bin
if [ "$DS_SSL" = "true" ]; then
   ./ldapsearch -Z -o -P $CERTDB -b "cn=schema" -D "$DIR_MANAGER" -w "$PASSWORD" -p $DS_PORT -h $DS_HOST "(objectclass=*)" > /dev/null 2>&1
else
   ./ldapsearch -b "cn=schema" -D "$DIR_MANAGER" -w "$PASSWORD" -p $DS_PORT -h $DS_HOST "(objectclass=*)" > /dev/null 2>&1
fi

if [ $? -ne 0 ]; then
   $ECHO
   $ECHO "Could not connect to the Directory Server. Please make"
   $ECHO "sure the user name and password are correct and that"
   $ECHO "the Directory Server is running."
   exit 1
fi

check_for_iws
if [ "$iws" = "yes" ]; then	# WS case
 while [ 1 ];do
  WS61_BASE="/sample"
  WS61_INSTANCE=""
  $ECHO
  $ECHO "What is the dirname where WS 6.1 installed [$WS61_BASE] \c"
  read ANS
  if [ "$ANS" != "" ]; then
          WS61_BASE=$ANS
  fi

  $ECHO
  $ECHO "What is the subdirname where WS 6.1 instance installed under $WS61_BASE [] \c"
  read ANS
  if [ -d "$WS61_BASE/$ANS" ]; then
          WS61_INSTANCE=$ANS
  fi

  if [ -x $WS61_BASE/$WS61_INSTANCE/start ];then
          $ECHO "WS61_BASE=$WS61_BASE" >> /tmp/.patch.ans
          $ECHO "WS61_INSTANCE=$WS61_INSTANCE" >> /tmp/.patch.ans
          break
  else
          $ECHO "\nBad WS 6.x basedir entered !"
  fi
 done
 $ECHO "WEB_CONTAINER=WS6" >> /tmp/.patch.ans

 WS61_CONFIG_BASE=$WS61_BASE/$WS61_INSTANCE/config
 cd $WS61_CONFIG_BASE
 echo "Restore config in `pwd` ..."
 restore_file server.xml
 restore_file server.policy
else	# AS case
 while [ 1 ];do
  AS7_BASE="/"
  $ECHO "In general, enter / if AS is installed in /opt/SUNWappserver7"
  $ECHO "What is the rootdir of Application Server [$AS7_BASE] \c"
  read ANS
  if [ "$ANS" != "" ]; then
          AS7_BASE=$ANS
  fi
  if [ -x $AS7_BASE/opt/SUNWappserver7/bin/asadmin ];then
          $ECHO "AS7_BASE=$AS7_BASE" >> /tmp/.patch.ans
          break
  else
          $ECHO "\nBad AS basedir entered !"
  fi
 done

 while [ 1 ];do
  AS7_DOMAIN="domain1"
  $ECHO
  $ECHO "What is the domain of Application Server [$AS7_DOMAIN] \c"
  read ANS
  if [ "$ANS" != "" ]; then
          AS7_DOMAIN=$ANS
  fi
  if [ -d /var/opt/SUNWappserver7/domains/$AS7_DOMAIN ];then
          $ECHO "AS7_DOMAIN=$AS7_DOMAIN" >> /tmp/.patch.ans
          break
  else
          $ECHO "\nBad AS DOMAIN entered !"
  fi
 done

 while [ 1 ];do
  AS7_INSTANCE="server1"
  $ECHO
  $ECHO "What is the instance of Application Server [$AS7_INSTANCE] \c"
  read ANS
  if [ "$ANS" != "" ]; then
          AS7_INSTANCE=$ANS
  fi
  if [ -x /var/opt/SUNWappserver7/domains/$AS7_DOMAIN/$AS7_INSTANCE/bin/startserv ];then
          $ECHO "AS7_INSTANCE=$AS7_INSTANCE" >> /tmp/.patch.ans
          break
  else
          $ECHO "\nBad AS INSTANCE entered !"
  fi
 done

  AS7_ADMPORT="4848"
  $ECHO
  $ECHO "What is the port number of admin instance of AS [$AS7_ADMPORT] \c"
  read ANS
  if [ "$ANS" != "" ]; then
          AS7_ADMPORT=$ANS
  fi
  $ECHO "AS7_ADMPORT=$AS7_ADMPORT" >> /tmp/.patch.ans

  AS7_ADMINID="admin"
  $ECHO
  $ECHO "What is the user name of admin instance of AS [$AS7_ADMINID] \c"
  read ANS
  if [ "$ANS" != "" ]; then
          AS7_ADMINID=$ANS
          break
  fi
  $ECHO "AS7_ADMINID=$AS7_ADMINID" >> /tmp/.patch.ans

  $ECHO "WEB_CONTAINER=AS7" >> /tmp/.patch.ans
fi

check_for_svc
if [ "$svc" = "yes" ]; then
   AM_SERVICE_JAR_DIR=$INSTALL_DIR/web-apps/services/WEB-INF/lib
   AM_SERVICE_JS_DIR=$INSTALL_DIR/web-apps/services/js
   AM_FED_JSP_DIR=$INSTALL_DIR/web-apps/services/config/federation/default
   AM_AUTH_JSP_DIR=$INSTALL_DIR/web-apps/services/config/auth/default

   cd $AM_SERVICE_JAR_DIR
   restore_file am_auth_ui.jar

   cd ..
   restore_file auth.tld
fi
