LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Enterprise (https://www.linuxquestions.org/questions/linux-enterprise-47/)
-   -   Scripting in init.d (https://www.linuxquestions.org/questions/linux-enterprise-47/scripting-in-init-d-347321/)

robthky 07-27-2005 11:28 AM

Scripting in init.d
 
I am runnign the following files to start two items in rc5.d/S99local:
rm -rf /opt/oracle/product/9.2.0/oracm/log/ocmstart.ts >>/tmp/startlog
export ORACLE_HOME=/opt/oracle/product/9.2.0/
/opt/oracle/product/9.2.0/oracm/bin/ocmstart.sh >>/tmp/startlog
su - oracle -c "/opt/oracle/product/9.2.0/bin/gsdctl start" >>/tmp/startlog

This seems to be working fine, but I am wanting this to work via chkconfig. I have written the following script in init.d/oracm_gsd, but I canot start or stop this as a service and it even though it pushed the appropriate K and S scripts into rc5.d and rc6.d the script(s) don't seem to be starting and stopping properly. It will not work on a reboot, nor can I use service oracm_gsd to start or stop these items. Here is the script:

#!/bin/bash

#
# chkconfig: 345 90 10
# description: This controls the oracm and the gsdctl start and stop

start() {
rm -rf /opt/oracle/product/9.2.0/oracm/log/ocmstart.ts >>/tmp/startlog
export ORACLE_HOME=/opt/oracle/product/9.2.0/
/opt/oracle/product/9.2.0/oracm/bin/ocmstart.sh >>/tmp/startlog
su - oracle -c "/opt/oracle/product/9.2.0/bin/gsdctl start" >>/tmp/startlog
touch /var/lock/subsys/oracm_gsd

}

stop() {
su - oracle -c "/opt/oracle/product/9.2.0/bin/gsdctl stop" >>/tmp/shutlog
killall oracm >>/tmp/shutlog
rm -f /var/lock/subsys/oracm_gsd

}

restart() {
stop
start
}

Any help would be appreciated.

Thanks,
Rob

jailbait 07-27-2005 01:44 PM

The script that you are having chkconfig place into init.d/oracm_gsd is incomplete. You have defined the start, stop, and restart functions but then you never actually issue a start, stop, or restart command. Therefore when init.d/oracm_gsd is executed your script does not do anything.

----------------------------
Steve Stites

robthky 07-27-2005 01:52 PM

Quote:

Originally posted by jailbait
The script that you are having chkconfig place into init.d/oracm_gsd is incomplete. You have defined the start, stop, and restart functions but then you never actually issue a start, stop, or restart command. Therefore when init.d/oracm_gsd is executed your script does not do anything.

----------------------------
Steve Stites

What do you mean "Issue a start, stop, or restart"? I thought that anything listed under the start {} ( section would run when I do a service oracm_gsd start command. What am I missing? Can you give me an example please?

jailbait 07-27-2005 03:08 PM

"What do you mean "Issue a start, stop, or restart"? I thought that anything listed under the start {} ( section would run when I do a service oracm_gsd start command."

True, but you have not enterd any commands into init.d/oracm_gsd.

"What am I missing? "

You have no commands in your script.

"Can you give me an example please?"

Here is an example of executing a start command as you define it:

#
# chkconfig: 345 90 10
# description: This controls the oracm and the gsdctl start and stop

start() {
rm -rf /opt/oracle/product/9.2.0/oracm/log/ocmstart.ts >>/tmp/startlog
export ORACLE_HOME=/opt/oracle/product/9.2.0/
/opt/oracle/product/9.2.0/oracm/bin/ocmstart.sh >>/tmp/startlog
su - oracle -c "/opt/oracle/product/9.2.0/bin/gsdctl start" >>/tmp/startlog
touch /var/lock/subsys/oracm_gsd

}

stop() {
su - oracle -c "/opt/oracle/product/9.2.0/bin/gsdctl stop" >>/tmp/shutlog
killall oracm >>/tmp/shutlog
rm -f /var/lock/subsys/oracm_gsd

}

restart() {
stop
start
}

# The following line is the only command that this script executes.
start

----------------------------
Steve Stites

robthky 07-27-2005 05:29 PM

Working
 
Thanks for your help. I added the following to the bottom of the script and it works great:

*)
echo "Usage: cworacm_gsd{start|stop|restart"
RETVAL=1
esac

exit $RETVAL


All times are GMT -5. The time now is 03:13 PM.