oracle in /etc/init.d

Just for my own reference 😉

Based on Tim Hall’s “dbora” post, but a little bit more to my licking, /etc/init.d/oracle (fna “dbora”). For info about the how/what/why, have a look a Tim’s post.

Use “chkconfig” to install and set run levels in Linux. Use prio 97 97 so it will always start before or shutdown after app servers etc. which have by default most likely prio 99 99 set (as well).

#!/bin/sh
#
# chkconfig: 345 97 97
# description: Oracle auto start-stop script.
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.

# Source function library.
. /etc/init.d/functions

RETVAL=0

ORA_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
ORA_OWNER=oracle

if [ ! -f $ORA_HOME/bin/dbstart ]
then
    echo "Oracle startup: cannot start"
    exit
fi

if [ ! -f $ORA_HOME/bin/dbshut ]
then
    echo "Oracle startup: cannot start"
    exit
fi

start() {
        # Check that networking is up.
        [ "$NETWORKING" = "no" ] && exit 1

        echo -n $"Starting $ORA_OWNER database(s) and listener: "
        echo
        # Start the Oracle databases:
        # The following command assumes that the oracle login
        # will not prompt the user for any values

        su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME"
        touch /var/lock/subsys/oracle
        RETVAL=$?
        echo
}

stop() {
        echo -n $"Stopping $ORA_OWNER database(s) and listener: "
        echo
        # Stop the Oracle databases:
        # The following command assumes that the oracle login
        # will not prompt the user for any values

        su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME"
        rm -f /var/lock/subsys/oracle
        RETVAL=$?
        echo
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart|reload)
        stop
        start
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart}"
        RETVAL=3
esac

exit $RETVAL

HTH (that is, my fuzzy mind first). That is:

“Download ASCII version here Marco (but it’s far from complete/neat) and next time don’t re-invent the wheel.”

😎

Marco Gralike Written by:

3 Comments

    • September 13

      I haven’t read that one from Frits, yet/thanks for the URL, but indeed I noticed that I had forgotten the sym file bit in my scripting, and, to be honest, will add it in do in time.

      When I posted it, I was to tired to add it. As said its more a place holder for me here and over time I will adjust it to hopefully more perfection (= to my licking!)

      😉

    • September 13

      The nasty thing, of course, now you have noticed it, I had to change it to the better alternative. That is, now, still too tired to breath.

      😎

Comments are closed.