#!/bin/bash
#
#	Copyright 2012 Delphix
#
#	NOTE: This script must be customized prior to use. Replace
#	      <ORACLE_HOME> and <SID> as per local requirements.
#

# set ORACLE_HOME
ORACLE_HOME=<ORACLE_HOME>
export ORACLE_HOME

# set ORACLE_SID
ORACLE_SID=<SID>
export ORACLE_SID

# set PATH
case "$PATH" in
    *$ORACLE_HOME/bin/*) ;;
    "") PATH=$ORACLE_HOME/bin ;;
    *)  PATH=$ORACLE_HOME/bin:$PATH ;;
esac
export PATH

# set LD_LIBRARY_PATH
case "$LD_LIBRARY_PATH" in
    *$ORACLE_HOME/lib*) ;;
    "") LD_LIBRARY_PATH=$ORACLE_HOME/lib ;;
    *)  LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH ;;
esac

export LD_LIBRARY_PATH

echo "$(date) enable apply for ${ORACLE_SID}" >/tmp/enable.log
sqlplus / as sysdba <<EOF
-- uncomment the line below to start apply in mounted mode
-- startup mount force
alter database recover managed standby database using current logfile disconnect;
exit;
EOF
echo "$(date) enable apply complete for ${ORACLE_SID}" >>/tmp/enable.log
