Skip to content

Instantly share code, notes, and snippets.

@cjbj
Last active March 9, 2022 02:11
Show Gist options
  • Save cjbj/d2a0d9e83a05d2c1b7d36036e8dab84e to your computer and use it in GitHub Desktop.
Save cjbj/d2a0d9e83a05d2c1b7d36036e8dab84e to your computer and use it in GitHub Desktop.
#! /bin/sh -x
#
# This is my old script for auto-starting Oracle DB on Linux.
# When I'm not using Cloud Databases, I now install the Oracle Database 21c RPM which includes its own script
#
# chkconfig: 2345 80 05
# description: start and stop Oracle Databases
#
# OL7: systemctl enable dbora
#
# Note:
# Change the awk pattern to match a DB of the ORACLE_HOME to be used
# Change the autostart entry of /etc/oratab to Y for any DB you want started; this is required by dbstart
ORACLE_HOME=$(awk -F: '/^ORCLCDB:/ {print $2}' /etc/oratab )
[ -z "$ORACLE_HOME" ] && { echo "ORACLE_HOME is not set in dbora"; exit 1; }
#
# Note: Change the value of ORACLE to the login name of the oracle owner
ORACLE=oracle
PATH=${PATH}:$ORACLE_HOME/bin
export ORACLE_HOME PATH
case $1 in
'start')
echo -n $"Starting Oracle: "
su $ORACLE -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME" &
;;
'stop')
echo -n $"Shutting down Oracle: "
su $ORACLE -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME" &
;;
'restart')
echo -n $"Shutting down Oracle: "
su $ORACLE -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME" &
sleep 5
echo -n $"Starting Oracle: "
su $ORACLE -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME" &
;;
*)
echo "usage: $0 {start|stop|restart}"
exit
;;
esac
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment