Thursday, August 31, 2006

Creating a rc3.d Script

One of my task for the day was to automate Jira that,
I have discussed here, By way of starting of Automatically
everytime the server is rebooted.

Previously I would start it by way of

I was told to create a script that could be added
to rc3.d (runlevel 3)

To do this you will need to name your script either with K or S
K - Kill a Process
S - Start a Process

and you will have to copy the script like say in my case,
I wanted the script to start everytime the server reboots

So I had given it

and this was copied to /etc/rc3.d, by doing this it will
create a link to /etc/rc.d/init.d/

Below is the script that starts jira by way of

To Start
/etc/rc.d/init.d/ start

To Stop
/etc/rc.d/init.d/ stop

# Run-level Startup script for the Jira Instance and Listener
# chkconfig: 345 91 19
# description: Startup/Shutdown Jira listener and instance
export JAVA_HOME=/usr/java/jdk1.5.0_06/
# if the executables do not exist -- display error
if [ ! -f $JIRA_HOME/bin/ -o ! -d $JIRA_HOME ]
echo "Jira startup: cannot start"
exit 1
# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display

case "$1" in
# Jira listener and instance startup
echo -n "Starting Jira: "
touch /opt/Jira/jira.lock
echo "OK"
# Jira listener and instance shutdown
echo -n "Shutdown Jira: "
rm -f /opt/Jira/jira.lock
echo "OK"
$0 stop
$0 start
echo "Usage: $0 start|stop|restart|reload"
exit 1
exit 0