Init script not called during system shutdown

Phil Peart wizman2007 at gmail.com
Tue Dec 9 14:07:23 UTC 2008


Hey there...

Try this...Oracle 10g needs dbstart/dbshut to be called with $ORACLE_HOME as
an argument. The echo $? dont seem to work but the script starts and stops
Oracle OK. Every DB listed in /etc/oratab with last field as Y will be
stopped and started with this script.

Here's my script:

#!/bin/sh
# chkconfig: 35 99 10
# description: Oracle auto start-stop script.
#
# Set ORACLE_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORACLE_OWNER to the user id of the owner of the
# Oracle database in ORACLE_HOME.
ORACLE_HOME=/oracle/product/10g
ORACLE_OWNER=oracle
export ORACLE_HOME ORACLE_OWNER
if [ ! -f ${ORACLE_HOME}/bin/dbstart ]
then
    echo "Oracle startup: cannot start"
    exit
fi
case "$1" in
    'start')
        # Start the Oracle databases:
        # The following command assumes that the oracle login
        # will not prompt the user for any values
 su - ${ORACLE_OWNER} -c
'ORACLE_HOME_LISTNER=$ORACLE_HOME;${ORACLE_HOME}/bin/dbstart
${ORACLE_HOME}';ret=$?
 if ((ret==0))
 then
  echo "OK"
 else
  echo "FAILED"
 fi
        ;;
    'stop')
        # Stop the Oracle databases:
        # The following command assumes that the oracle login
        # will not prompt the user for any values
        su - ${ORACLE_OWNER} -c
'ORACLE_HOME_LISTNER=$ORACLE_HOME;${ORACLE_HOME}/bin/dbshut
${ORACLE_HOME}';ret=$?
 if ((ret==0))
 then
  echo "OK"
 else
  echo "FAILED"
 fi
         ;;
esac

#End of script

Cheers,


Phil


On Tue, Dec 9, 2008 at 8:59 PM, SIG - Pédagogie <sigpedag at univ-paris1.fr>wrote:

> Hello,
>
> I'm using an up-to-date Red Hat Enterprise Linux 4.7 (64 bits) system and
> I'd like to setup a startup/shutdown script to manage an Oracle AS 10g R2
> installation.
>
> The script works fine (start/stop/restart) when called from a bash
> prompt and it's launched at system startup with no problem.
>
> The issue is that it's no called at all when the system shuts down, I
> checked runlevels, permissions for the script, I even put some "wall" and
> "echo" in it...
>
> I try different priorities, different script names, different shells, it's
> always the same. The only particularity of the script is that the commands I
> launch need to run under a user with no privileges, I use "su" for that.
>
> (Once again, everything works when it's called from a shell, so doesn't
> seem to be "su"-related and the "wall" and "echo" command that should be
> exectued in root aren't executed)
>
> I have absolutely no idea why this happens...
>
> =========================================================================
>
> # ls -l /etc/init.d/ora-as1
> -rwxr-xr-x  1 root root 617 Dec  9 14:45 /etc/init.d/ora-as1
>
> =========================================================================
>
> # cat /etc/init.d/ora-as1
> #!/bin/sh
> #
> # Startup script for Oracle AS 10g R2
> # chkconfig: 345 86 14
> #
> # description:  Bla bla bla
>
> start() {
>        su -c "opmnctl startall" - ora-as1
>        su -c "emctl start iasconsole" - ora-as1
> }
>
> stop() {
>        wall "Stopping ora-as1"
>        echo "`date` - Stopping ora-as1" >> /var/log/oracleas10gr2.log
>        su -c "emctl stop iasconsole" - ora-as1
>        su -c "opmnctl stopall" - ora-as1
> }
>
> # See how we were called
> case "$1" in
>  start)
>        start
>        ;;
>  stop)
>        stop
>        ;;
>  restart)
>        stop
>        start
>        ;;
>  *)
>        echo "Usage: $0 {start|stop|restart}"
> esac
>
> exit 0
>
> =========================================================================
>
> # find /etc/rc* -type l -name "*ora-as1*"
> /etc/rc.d/rc1.d/K14ora-as1
> /etc/rc.d/rc2.d/K14ora-as1
> /etc/rc.d/rc3.d/S86ora-as1
> /etc/rc.d/rc4.d/S86ora-as1
> /etc/rc.d/rc0.d/K14ora-as1
> /etc/rc.d/rc5.d/S86ora-as1
> /etc/rc.d/rc6.d/K14ora-as1
>
> =========================================================================
>
> # chkconfig --list ora-as1
> ora-as1         0:off   1:off   2:off   3:on    4:on    5:on    6:off
>
> =========================================================================
>
> Any idea?
> --
> Nicolas
>
>
> --
> Ce message a ete verifie par MailScanner
> pour des virus ou des polluriels et rien de
> suspect n'a ete trouve.
>
> --
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request at redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list
>



More information about the redhat-list mailing list