On Fri, Feb 11, 2005 at 03:01:33PM -0500, Smith, Ann (ISD, IT) wrote:
> [... example oldstyle BSD init script ...]

FYI, you REALLY  want to update this. This script will
*seriously* mess up insserv and the SuSE runlevel processing the next
time you do a RPM install using YaST or possibly render your system
unbootable if the startup order of the scripts gets munged badly enough.

Appended below are 4 files which are a insserv-safe version of
your script, modified to take advantage of the "standard" Yast
features and /etc/sysconfig support. I also split up the database
startup and the SQL*net startup by putting each into a separate script
and adding a dependency on the database startup for sqlnet to
initialize. All the configuration variables are pulled out into
/etc/sysconfig files, and you can edit them individually with the YaST
sysconfig editor.

Note that the /etc/sysconfig file related to each script is the same
name as the init script, allowing you to use the same scripts for
multiple database instances by renaming the script to a new name (eg,
oracledb1, oracledb2, etc), doing an insserv on the renamed script,
and the associated parameters are drawn automagically from the
/etc/sysconfig file of the same name. Leads to a little bit of
duplication, but it also means that you can't screw up the entire
environment by mangling one config file.


To use these, just 'insserv oracledb; insserv sqlnet; cp oracledb
/etc/sysconfig/oracledb; cp sqlnet /etc/sysconfig/sqlnet' and you can
issue 'oracledb start; sqlnet start' and watch the fun. They even get
the nice colored status indicators that the SuSE-supplied scripts
get...8-)

Warning: check where lines end -- mailing these may have munged them
somewhat.


/etc/init.d/oracledb:  (the actual init script itself)
---------------------------------------------------------------

#! /bin/sh
# Oracle database startup script
# Mutated from PostGres example in SuSE distribution
#
# Author (of the Postgres version):
#         Karl Eichwalder <[EMAIL PROTECTED]>, 1998
#         Reinhard Max <[email protected]>, 2000
# Tweaked: David Boyes <[EMAIL PROTECTED]>, 2005
#
# Caveat: Trivially tested. Don't blame me if it makes your
#         system sick. After all, what did you pay for it?
#
# /etc/init.d/oracledb
#
#   and symbolic its link
#
# /usr/sbin/oracledb
#
### BEGIN INIT INFO
# Provides:       oracle
# Required-Start: $network $remote_fs
# Required-Stop:
# Default-Start:  3 5
# Default-Stop:
# Description:    Start Oracle Databases
### END INIT INFO

# Source SuSE config
ORA_SYSCONFIG=/etc/sysconfig/$0

if [ -f $ORA_SYSCONFIG ]; then
    . $ORA_SYSCONFIG
fi

#
# All the environment variable settings go in ORA_SYSCONFIG
#
#

# Shell functions sourced from /etc/rc.status:
#      rc_check         check and set local and overall rc status
#      rc_status        check and set local and overall rc status
#      rc_status -v     ditto but be verbose in local rc status
#      rc_status -v -r  ditto and clear the local rc status
#      rc_failed        set local and overall rc status to failed
#      rc_reset         clear local rc status (overall remains)
#      rc_exit          exit appropriate to overall rc status
. /etc/rc.status

#
# check for external Oracle startup script and bail if not present.
#
H=/tech/oracle/admin/sys/orasetup.sh
test -x $H || exit 5

SUBIN=/bin/su
        
# The echo return value for success (defined in /etc/rc.config).
rc_reset

# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.

case "$1" in
    start)
        echo -n "Starting Oracle Database Engine"
        ## create logfile
        ##
        touch $LOGDIR/$LOGFILE
        ##
        ## set up oracle profile environment
        . /tech/oracle/admin/environment/oracleprofile $MOUNT_PT \
               $ORACLE_SID >> $LOGDIR/$LOGFILE 2>&1
        ##
        ## and start 'er up, Clancy
        ##
        startproc $SUBIN $ORACLE_USER -c $ORACLE_HOME/bin/dbstart >> \
               $LOGDIR/$LOGFILE 2>&1
        rc_status -v
    ;;

    stop)
        echo -n "Stopping Oracle Database Engine"
        ## Stop daemon with killproc(8) and if this fails
        ## set the echo return value.

        killproc -INT $H
        rc_status -v
    ;;

    try-restart)
        ## Stop the service and if this succeeds (i.e. the
        ## service was running before), start it again.
        ## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
        $0 status &&  $0 restart
    ;;

    restart)
        ## Stop the service and regardless of whether it was
        ## running or not, start it again.
        $0 stop
        $0 start
        rc_status
    ;;

    force-reload | reload)
        echo -n "Reloading configuration for PostgreSQL"
        killproc -HUP $H
        rc_status -v
    ;;

    status)
        echo -n "Checking for PostgreSQL: "
        ## Check status with checkproc(8), if process is running
        ## checkproc will return with exit status 0.

        # Status has a slightly different for the status command:
        # 0 - service running
        # 1 - service dead, but /var/run/  pid  file exists
        # 2 - service dead, but /var/lock/ lock file exists
        # 3 - service not running

        # NOTE: checkproc returns LSB compliant status values.
        checkproc $H
        rc_status -v
    ;;

    probe)
        rc_failed 3
        rc_status -v
    ;;

    *)
        echo "Usage: $0 
{start|stop|status|try-restart|restart|force-reload|reload|probe}"
        exit 1
    ;;
esac

# Inform the caller not only verbosely and set an exit status.
rc_exit


/etc/init.d/sqlnet:
---------------------------------------------------------------------

#! /bin/sh
# Oracle SQL*NET  startup script
# Mutated from PostGres example in SuSE distribution
#
# Author (of the Postgres version):
#         Karl Eichwalder <[EMAIL PROTECTED]>, 1998
#         Reinhard Max <[email protected]>, 2000
# Tweaked: David Boyes <[EMAIL PROTECTED]>, 2005
#
# Caveat: Trivially tested. Don't blame me if it makes your
#         system sick. After all, what did you pay for it?
#
# /etc/init.d/sqlnet
#
#   and symbolic its link
#
# /usr/sbin/sqlnet
#
### BEGIN INIT INFO
# Provides:       sqlnet
# Required-Start: $network $remote_fs $oracle
# Required-Stop:
# Default-Start:  3 5
# Default-Stop:
# Description:    Start Oracle SQL*Net Listener
### END INIT INFO

# Source SuSE config
ORA_SYSCONFIG=/etc/sysconfig/$0

if [ -f $ORA_SYSCONFIG ]; then
    . $ORA_SYSCONFIG
fi

#
# All the environment variable settings go in ORA_SYSCONFIG
#
#

# Shell functions sourced from /etc/rc.status:
#      rc_check         check and set local and overall rc status
#      rc_status        check and set local and overall rc status
#      rc_status -v     ditto but be verbose in local rc status
#      rc_status -v -r  ditto and clear the local rc status
#      rc_failed        set local and overall rc status to failed
#      rc_reset         clear local rc status (overall remains)
#      rc_exit          exit appropriate to overall rc status
. /etc/rc.status

#
# check for external Oracle startup script and bail if not present.
#
H=/tech/oracle/admin/sys/orasetup.sh
test -x $H || exit 5

SUBIN=/bin/su
        
# The echo return value for success (defined in /etc/rc.config).
rc_reset

# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.

case "$1" in
    start)
        echo -n "Starting Oracle SQL*Net Listener"
        ## create logfile
        ##
        touch $LOGDIR/$LOGFILE
        ##
        ## set up oracle profile environment
        . /tech/oracle/admin/environment/oracleprofile $MOUNT_PT \
               $ORACLE_SID >> $LOGDIR/$LOGFILE 2>&1
        ##
        ## and start 'er up, Clancy
        ##
        startproc $SU_BIN $ORACLE_USER -c '$ORACLE_HOME/bin/lsnrctl start \
                listener' >> $LOGDIR/$LOGFILE 2>&1
        rc_status -v
    ;;

    stop)
        echo -n "Stopping Oracle SQL*Net Listener"
        ## Stop daemon with killproc(8) and if this fails
        ## set the echo return value.

        killproc -INT $H
        rc_status -v
    ;;

    try-restart)
        ## Stop the service and if this succeeds (i.e. the
        ## service was running before), start it again.
        ## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
        $0 status &&  $0 restart
    ;;

    restart)
        ## Stop the service and regardless of whether it was
        ## running or not, start it again.
        $0 stop
        $0 start
        rc_status
    ;;

    force-reload | reload)
        echo -n "Reloading configuration for Oracle SQL*Net"
        killproc -HUP $H
        rc_status -v
    ;;

    status)
        echo -n "Checking for Oracle SQL*Net: "
        ## Check status with checkproc(8), if process is running
        ## checkproc will return with exit status 0.

        # Status has a slightly different for the status command:
        # 0 - service running
        # 1 - service dead, but /var/run/  pid  file exists
        # 2 - service dead, but /var/lock/ lock file exists
        # 3 - service not running

        # NOTE: checkproc returns LSB compliant status values.
        checkproc $H
        rc_status -v
    ;;

    probe)
        rc_failed 3
        rc_status -v
    ;;

    *)
        echo "Usage: $0 
{start|stop|status|try-restart|restart|force-reload|reload|probe}"
        exit 1
    ;;
esac

# Inform the caller not only verbosely and set an exit status.
rc_exit


/etc/sysconfig/oracledb:
--------------------------------------------------------------------------


LOGFILE=orasys_strt_`date +%m%d%y`;
LOGDIR=/tech/oracle/admin/doc;
ORACLE_SID=skazal9;
MOUNT_PT=/tech/oracle;
ORAENV_ASK=NO;
ORACLE_USER=oracle;


/etc/sysconfig/sqlnet:
--------------------------------------------------------------------------

LOGFILE=orasys_strt_`date +%m%d%y`;
LOGDIR=/tech/oracle/admin/doc;
ORACLE_SID=skazal9;
MOUNT_PT=/tech/oracle;
ORAENV_ASK=NO;
ORACLE_USER=oracle;

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390

Reply via email to