Fri 21 Nov 2008
Simple Jira Init Script (Suse Linux SLES)
Posted by admin under Jira , Suse , linux , programming , shell1 Comment
Here a very simple init script tested on Suse SLES 10. An other good way to create one is looking at the init-Script for tomcat or using just it and installing Jira as WAR into tomcat.
#!/bin/bash # Jira startup script # install: # copy to /etc/init.d/jirad # ln -s /etc/init.d/jirad /sbin/rcmy-jirad # insserv /etc/init.d/jirad ### BEGIN INIT INFO # Provides: jirad # Required-Start: $local_fs $network # Required-Stop: # Default-Start: 3 5 # Default-Stop: 0 1 2 6 # Short-Description: Starts Jira server # Description: Starts Jira Issue Tracking ### END INIT INFO # Based on script at http://confluence.atlassian.com/pages/viewpage.action?pageId=183148 RUN_AS_USER=jico CATALINA_HOME=/opt/jira start() { echo "Starting Jira: " if [ "x$USER" != "x$RUN_AS_USER" ]; then su - $RUN_AS_USER -c "$CATALINA_HOME/bin/startup.sh" else $CATALINA_HOME/bin/startup.sh fi echo "done." } stop() { echo "Shutting down Confluence: " if [ "x$USER" != "x$RUN_AS_USER" ]; then su - $RUN_AS_USER -c "$CATALINA_HOME/bin/shutdown.sh" else $CATALINA_HOME/bin/shutdown.sh fi echo "done." } case "$1" in start) start ;; stop) stop ;; restart) stop sleep 10 #echo "Hard killing any remaining threads.." #kill -9 `cat $CATALINA_HOME/work/catalina.pid` start ;; *) echo "Usage: $0 {start|stop|restart}" esac exit 0
January 16th, 2010 at 9:28 pm
I enhanced your script a little (added status argument and check if jira is already running before starting)
#!/bin/bash
# Jira startup script
# install:
# copy to /etc/init.d/jirad
# ln -s /etc/init.d/jirad /sbin/rcjirad
# insserv /etc/init.d/jirad
### BEGIN INIT INFO
# Provides: jirad
# Required-Start: $local_fs $network
# Required-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Starts Jira server
# Description: Starts Jira Issue Tracking
### END INIT INFO
# Based on script at http://confluence.atlassian.com/pages/viewpage.action?pageId=183148
RUN_AS_USER=jira
CATALINA_HOME=/opt/jira
CATALINA_PID=${CATALINA_HOME}/work/catalina.pid
# 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
start() {
echo “Starting Jira: ”
#CATALINA_PID must be set to let jira write a pid file
export CATALINA_PID
if [ -f ${CATALINA_PID} ]
then
checkproc -p ${CATALINA_PID} /usr/lib/jvm/jre/bin/java
if [ $? -eq 0 ]
then
echo ” Jira is already running.”
exit 1
else
rm -rf ${CATALINA_PID}
fi
fi
export CATALINA_PID
if [ "x$USER" != "x$RUN_AS_USER" ]; then
su -m – $RUN_AS_USER -m -c “export CATALINA_PID=${CATALINA_PID};$CATALINA_HOME/bin/startup.sh”
else
$CATALINA_HOME/bin/startup.sh
fi
rc_status -v
}
stop() {
echo “Shutting down Jira: ”
if [ "x$USER" != "x$RUN_AS_USER" ]; then
su – $RUN_AS_USER -c “$CATALINA_HOME/bin/shutdown.sh”
else
$CATALINA_HOME/bin/shutdown.sh
fi
rc_status -v
}
status() {
echo -n “Checking for Jira: ”
checkproc -p ${CATALINA_PID} /usr/lib/jvm/jre/bin/java
rc_status -v
}
case “$1″ in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 10
start
;;
status)
status
;;
*)
echo “Usage: $0 {start|stop|restart}”
esac
exit 0