I have modified Atlassian script to support following features:
- Cleanup for leftover files – .jira-home.lock, catalina.pid
- catalina.out log backup
- Check for running process and force kill JIRA if it won’t stop on time
#!/bin/sh -e # JIRA startup script # Description: For JIRA 7.2.7 # Define some variables # Name of app ( JIRA, Confluence, etc ) APP=jira # Name of the user to run as USER=root # Location of application's bin directory BASE=/u01/jira/Prod_7.2.7 export JIRAHOME=$BASE # Location of application's home directory JHOME=/u01/jira/Prod_7.2.7_home export JIRA_HOME=$JHOME # Location of Java JDK export JAVA_HOME=/usr/java/default case "$1" in # Start command start) echo "Starting $APP" lockfile="$JHOME/.jira-home.lock" [ -e $lockfile ] && rm $lockfile pidfile="$BASE/work/catalina.pid" [ -e $pidfile ] && rm $pidfile logfile="$BASE/logs/catalina.out" [ -e $logfile ] && mv $BASE/logs/catalina.out "$BASE/logs/catalina-`date +%F`.out" /bin/su -m $USER -c "cd $BASE/bin && $BASE/bin/start-jira.sh &> /dev/null" ;; # Stop command stop) blah="" temp=`ps aux|grep java|grep jira|grep -v grep|awk '{print $2}'` pidfile="$BASE/work/catalina.pid" if [ "$temp" == "$blah" ] then echo 'JIRA is not running' exit 0 fi echo 'Shutting down JIRA' /bin/su -m $USER -c "$BASE/bin/stop-jira.sh &> /dev/null" echo 'Sleeping 30 seconds, because sleeping is good...' sleep 30 temp=`ps aux|grep java|grep jira|grep -v grep|awk '{print $2}'` echo 'Now checking if JIRA is still running...' if [ "$temp" != "$blah" ] then echo 'Force killing JIRA now...' /bin/su -m $USER -c "$BASE/bin/catalina.sh stop -force $num >/dev/null 2>&1" echo 'Killed' exit 0 else echo 'JIRA is already down' exit 0 fi echo "...done" exit 0 ;; # Restart command restart) $0 stop sleep 60 $0 start ;; *) echo "Usage: jira {start|restart|stop}" exit 1 ;; esac exit 0