20090901 odisrv control scripts - plembo/onemoretech GitHub Wiki

title: odisrv control scripts link: https://onemoretech.wordpress.com/2009/09/01/odisrv-control-scripts/ author: lembobro description: post_id: 261 created: 2009/09/01 19:32:17 created_gmt: 2009/09/01 19:32:17 comment_status: open post_name: odisrv-control-scripts status: publish post_type: post

odisrv control scripts

I’m embarrassed to admit it, but I haven’t done much UNIX shell scripting over the years. While a lot of my work in the early days involved programming to the DOS and Windows shells, when it came time to move over to UNIX system administration I jumped right over the shell and went directly to perl.

As with all things, there comes a time when you have to push yourself to stretch a little. The following bash shell code will start and stop Oracle’s OAS (Oracle Application Server) 10g odisrv daemon, also known as the “DIP” (Directory Integration Platform). While theoretically odisrv should get started and stopped along with the other components in the stack when an admin invokes the opmnctl command, in practice things get out of sync and often require an independent start/stop of the service.

First, start_odisrv.sh:

`

#!/bin/bash
# Starts odisrv, the Directory Integration Platform Server
# Created 9/1/09 by P Lembo
echo "start_odisrv.sh starts DIP server"
. $HOME/oid.env
FILE=$ORACLE_HOME/config/ias.properties
	
INFRDB=`grep 'InfrastructureDBCommonName' $FILE | cut -d= -f2`
echo "Infrastructure database is $INFRDB"
	
echo "Starting odisrv..."
oidctl connect=$INFRDB server=odisrv instance=1 start

`

Next, stop_odisrv.sh:

`

#!/bin/bash
# Stops odisrv, the Directory Integration Platform Server
# Created 9/1/09 by P Lembo
echo "stop_odisrv.sh stops the DIP server"
. $HOME/oid.env
FILE=$ORACLE_HOME/config/ias.properties
	
INFRDB=`grep 'InfrastructureDBCommonName' $FILE | cut -d= -f2`
echo "Infrastructure database is $INFRDB"
	
echo "Stopping odisrv..."
oidctl connect=$INFRDB server=odisrv instance=1 stop

`

Note that the first operational line of the script sources an .env file to set all special application variables in keeping with Oracle’s standard practice. This is the only practical way to do things when a single system user account is used to manage multiple application homes (e.g. OID and SSO installed to separate homes on the same box using the same “oracle” shell account).

A useful technique I picked up while writing these is how to parse the ias.properties file for the infrastructure database SID using grep and cut. The most obvious alternative to this would be to hardcode the SID into each copy of the script. That’s not a very palatable solution when you’ve got more than a dozen instances running on your network though. Another option would have been to have the script prompt the user for this value. Again, that seemed too damn tedious to me.

(I considered writing a single script with “case” blocks to enable invoking with a start or stop option, but we’d already widely deployed the separate start and stop scripts in our environment and I wanted to minimize the need for redoing more of our procedural documentation than necessary)

Copyright 2004-2019 Phil Lembo