I am working on a new script/set of scripts for single-instance database cloning and came across the need to shut down and restart the application by calling a second script. Here, I am sharing it with you today. Copy it to a fresh .sh file, name it whatever you want, and enjoy! :) Do not forget to adjust the passwords!
#!/bin/sh
: <<'END'
This script is ran as "root"
This script is meant for single instances.
This script expects both ORACLE, APPLMGR users bash profiles sourcing environment files.
This script was last tested against Oracle EBS R12 12.2.10/19c
Last modified on: 2nd October 2024
Author: Rajesh Thampi
License: Public
END
me=$(basename "$0")
ORACLE_SID=$(su - oracle -c 'echo "$ORACLE_SID"')
APPS_ORACLE_CONTEXT=$(su - applmgr -c 'echo "$CONTEXT_NAME"')
APPS_SCRIPTS_HOME=$(su - applmgr -c 'echo "$RUN_BASE/inst/apps/$CONTEXT_NAME/admin/scripts"')
DB_SCRIPTS_HOME=$(su - oracle -c 'echo "$ORACLE_HOME"')/appsutil/scripts/$APPS_ORACLE_CONTEXT
if [[ -z $1 ]]; then
echo "No parameter was passed"
exit 1
else
if [[ "$1" == "start" ]]; then
echo "All Oracle EBS R12 Services will be started now."
su - oracle -c "sh $DB_SCRIPTS_HOME/adcdbctl.sh start;"
if [ $? -ne 0 ]; then
echo "Couldn't start the database services successfully. Aborting"
exit 1
else
su - oracle -c "sh $DB_SCRIPTS_HOME/adcdblnctl.sh start $ORACLE_SID;"
fi
if [ $? -ne 0 ]; then
echo "Couldn't start the listener services successfully. Aborting"
exit 1
else
su - applmgr -c "cd $APPS_SCRIPTS_HOME;{ echo apps; echo apps; echo password123; } | adstrtal.sh;"
fi
if [ $? -ne 0 ]; then
echo "Couldn't start the Application services successfully. Check log files for errors and try again"
else
echo "All EBS Services were successfully started."
fi
elif [[ "$1" == "stop" ]]; then
echo "All Oracle EBS R12 Services will be stopped now."
su - applmgr -c "cd $APPS_SCRIPTS_HOME;{ echo apps; echo apps; echo password123; } | adstpall.sh;"
if [ $? -ne 0 ]; then
echo "Couldn't stop the application services successfully. Aborting"
exit 1
else
su - oracle -c "sh $DB_SCRIPTS_HOME/adcdblnctl.sh stop $ORACLE_SID;"
fi
if [ $? -ne 0 ]; then
echo "Couldn't stop the Listener services successfully. Aborting"
exit 1
else
su - oracle -c "sh $DB_SCRIPTS_HOME/adcdbctl.sh stop immediate;"
fi
if [ $? -ne 0 ]; then
echo "Couldn't stop the Database services successfully. Check log files for errors and try again."
exit 1
else
echo "All EBS Services were successfully stopped."
fi
else
echo "Syntax: sh $me start/stop"
fi
fi
That’s all folks. Have comments? let me know



