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
/opt/Jira/atlassian-jira-standard-3.6.3-standalone/bin/startup.sh

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 S92100Jira.sh

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

Below is the script that starts jira by way of

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

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

____________________________________________________
#!/bin/bash
#
# 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/
JIRA_HOME="/opt/Jira/atlassian-jira-enterprise-3.6.3-standalone"
# if the executables do not exist -- display error
if [ ! -f $JIRA_HOME/bin/startup.sh -o ! -d $JIRA_HOME ]
then
echo "Jira startup: cannot start"
exit 1
fi
# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display

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

_______________________________________________________