Forum OpenACS Q&A: Re: Oracle /etc/init.d scripts should use shutdown immediate

There's another bug in Oracle's dbshut script - each instance is shut down only if it is configured in oratab to automatically start up on boot. Here's a patch gainst the stock version, with both fixes (I ran ns_quotehtml over it, so it should display properly here on the web):

$ pwd
/ora8/m01/app/oracle/product/8.1.7/bin

$ cvs diff -u -r 1.1 -r 1.2 dbshut 
Index: dbshut
===================================================================
RCS file: /home/cvsroot/ora8-koudelka/product/8.1.7/bin/dbshut,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- dbshut	28 Nov 2002 07:03:25 -0000	1.1
+++ dbshut	15 May 2003 00:01:42 -0000	1.2
@@ -1,6 +1,7 @@
 :
 #
-# $Header: /home/cvsroot/ora8-koudelka/product/8.1.7/bin/dbshut,v 1.1 2002/11/28 07:03:25 atp Exp $ dbshut.sh.pp Copyr (c) 1991 Oracle
+# Header: dbshut.sh.pp 30-may-2000.14:31:09 jboyce Exp $ dbshut.sh.pp Copyr (c) 1991 Oracle
+# $Header: /home/cvsroot/ora8-koudelka/product/8.1.7/bin/dbshut,v 1.2 2003/05/15 00:01:42 atp Exp $
 #
 
 ###################################
@@ -38,7 +39,23 @@
         \#*) ;;        #comment-line in oratab
         *)
 #       Proceed only if third field is 'Y'.
-        if [ "`echo $LINE | awk -F: '{print $3}' -`" = "Y" ] ; then
+
+        # That's a VERY bad idea!  When the unix box goes down, want
+        # ALL Oracle instances to be shut down cleanly, whether
+        # they're configured to start up on system boot or not!
+        # --atp@piskorski.com, 2003/05/14 19:29 EDT
+
+        # TOOD: This is also going to shut each instance down
+        # sequentially, which is kind of slow.  Might be much better
+        # to do them all in parallel.  --atp@piskorski.com, 2003/05/14
+        # 19:52 EDT
+
+        dbstart_p=`echo $LINE | awk -F: '{print $3}' -`
+        # Shutdown only if oratab start field is Y:
+        #if [ "$dbstart_p" = "Y" ]
+        # Shutdown as long as oratab field is not empty string:
+        if [ "$dbstart_p" ]
+        then
             ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
             if [ "$ORACLE_SID" = '*' ] ; then
                 ORACLE_SID=""
@@ -71,7 +88,7 @@
                   6)  sqldba command=shutdown ;;
                   *)  $SQLDBA <<EOF
 connect internal
-shutdown
+shutdown immediate
 EOF
                     ;;
               esac