PSoft clone script, 2nd part


#!/bin/ksh -x
#
# Script:    clone_ASM_cleanout.ksh
# Purpose:   to clear out the ASM filesystems for a clone prep. this
#            file does not get called unless the “asm_SID.tmp” file is
#            a non-zero file sitting in /tmp. That file gets
#            populated with a SID from the main clone script. this
#            script will run every 60 seconds from root’s cron as the
#            GRID user.
# Created:   10/26/2012, CWMack
# Modified:
#
#######################################################################
#
#
HOSTNAME=nrac01.hsc.net.ou.edu
export ORACLE_SID=+ASM1
export ORACLE_HOME=/opt/app/11.2.0/grid
export ASMCMD=/opt/app/11.2.0/grid/bin/asmcmd
export CLONE_DIR=/s01/shared_scripts/clone_pfiles
#
#
#
# if this script is running, we don’t want it running again…. bail if it’s running
#
if [[ -e $CLONE_DIR/asm_cleanout_running.tmp ]]
then
   echo “”
   echo “Script already running, exiting….” > /tmp/asm_already_running.tmp
   echo “”
   exit
fi
#
rm /tmp/asm_done.tmp
#
# let’s make sure the file is there and has a SID in it…..
#
#
if [[ -e $CLONE_DIR/asm_SID.tmp && -s $CLONE_DIR/asm_SID.tmp ]]
   then
      if grep CT90 $CLONE_DIR/asm_SID.tmp
         then
            SID=`cat $CLONE_DIR/asm_SID.tmp`
            #cp /dev/null $CLONE_DIR/asm_SID.tmp
            set CSDATA CSFLASH
      elif grep FT90 $CLONE_DIR/asm_SID.tmp
         then
            SID=`cat $CLONE_DIR/asm_SID.tmp`
            #cp /dev/null $CLONE_DIR/asm_SID.tmp
            set FSDATA FSFLASH
      elif grep HT90 $CLONE_DIR/asm_SID.tmp
         then
            SID=`cat $CLONE_DIR/asm_SID.tmp`
            #cp /dev/null $CLONE_DIR/asm_SID.tmp
            set HCDATA HCFLASH
      else
         echo “The trigger file does not have a valid database name” > /tmp/asm_error_cleanout.tmp
         echo “”
         exit
      fi
else
      exit
fi
#
echo $SID > $CLONE_DIR/asm_cleanout_running.tmp
chmod 777 $CLONE_DIR/asm_cleanout_running.tmp
rm -f $CLONE_DIR/asm_SID.tmp
#
# clear out the ASM filesystem so we can continue on with the clone
#
#
for i in $*
do
$ASMCMD >> /tmp/asm_clean.out <<EOF
rm -rf +$i/$SID/CONTROLFILE
rm -rf +$i/$SID/DATAFILE
rm -rf +$i/$SID/ONLINELOG
rm -rf +$i/$SID/TEMPFILE
mkdir +$i/$SID/CONTROLFILE
mkdir +$i/$SID/DATAFILE
mkdir +$i/$SID/ONLINELOG
mkdir +$i/$SID/TEMPFILE
EOF
done
#
# create 2nd trigger file so clone script will continue on….
#
#
rm /tmp/asm_clean*
touch /tmp/asm_done.tmp

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s