将JIRA加入到系统服务内(不是简单的添加)

这个脚本里面内容有些不是最新的,刚才隔壁的一个人跟我聊天,是做销售的。我还不好意思打断他,没办法,让他聊了一个小时~所以配置的那个文件我也没有来得及写,现在现写。不过觉得这个脚本也有危险,因为停止服务在启动时会马上去删除掉.jira-home.lock,可能如果某些异常宕机会有些影响,不过应该不大!请斟酌使用,此问仅提供想法使用

目的:主要是为了方便以后管理,以及其他不懂的人管理;
环境:Centos 5.5 ,shell支持:bash,JIRA;
注意:如需使用,请下载文本文件,若复制,请将下面脚本信息复制为UTF-8格式文本
执行方法:脚本一步执行配置(下载“配置脚本”,下载后执行(file为下载到你本地的文件名) 
unzip file&& chmod +x file&& sh file),如不需要可直接到下一代码处Jira Service Shell Script
复制如下内容:保存为任意名称,如kinggoo.config
然后执行如下命令:
会让你输入jira-application.properties 文件里配置jira.home的路径请输入jira的安装目录

chmod +x kinggoo.config&& sh kinggoo.config

#!/bin/bash
# WebSite:
http://www.kinggoo.com , WeiBo Sina : @tscccn   #
#配置jira.home
echo  -n "请输入你在jira-application.properties 文件里配置jira.home的路径"
echo -n "jira.home="&&read DATA_HOME
echo  "请输入jira的安装目录,如你把jira放在/opt/local/jira"
echo -n "PATH_HOME=" && read PATH_HOME
if [[ ! -z $DATA_HOME && ! –z $PATH_HOME ]];then
    wet
http://www.kinggoo.com/wp-content/upload/2011/08/server_jira_kinggoo.com_.zip
    unzip server_jira_kinggoo.com_.zip –d /etc/init.d/ &&mv /etc/init.d/server_jira_kinggoo.com.sh /etc/init.d/jira
    sed ‘s@PATH_HOME.$@’${PATH_HOME}’@/g’ server_jira_kinggoo.com.sh > temp
    sed ‘s@DATA_HOME.$@’${DATA_HOME}’@/g’ temp > /etc/init.d/jira && cd /etc/init.d/
    chmod +x jira && chkconfig –add jira
    #如果需要在某个init下启动
    #chkconfig  –level 234 jira on
    echo "已经配置完成,试试使用service jira status有效果吗!"
else   
    echo "Please configure “DATA_HOME” or “PATH_HOME” PATH"
fi
    unset DATA_HOME PATH_HOME
#########################################

Jira Service Shell Script (下载JIRA服务脚本)

#!/bin/bash
# chkconfig: – 23 99
# description: Savas and restores system entropy pool for higher\
quality randomnumber generation
#
######################################################
# WebSite:

http://www.kinggoo.com , WeiBo Sina : @tscccn        #
######################################################
 
CHAR="JIRA -Dorg.apache"
JUDGE=`ps -fe |grep "$CHAR"|grep -v grep`
PATH_HOME="/opt/local/jira"
DATA_HOME="/opt/local/DATA_HOME/JIRA"
JIRA_STATUS=$1
CUOUNT_JUDGE=""
COUNT_SUM_AGO=""
COUNT_JUDGE=""
TIME=`date +%m%d%H%M`
./etc/rc.d/init.d/functions
count ()
    {
        COUNT_SUM_AGO=`cat $PATH_HOME/logs/catalina.out|wc -l`
        while [[ -z $COUNT_JUDGE ]]
        do
            COUNT_SUM_NEW=`cat $PATH_HOME/logs/catalina.out|wc -l`
            COUNT_JUDGE=`sed -n "$COUNT_SUM_AGO,$COUNT_SUM_NEW p" $PATH_HOME/logs/catalina.out|grep ‘You can now access JIRA through your web browser.’`
        done   
        unset COUNT_JUDGE COUNT_SUM_AGO COUNT_JUDGE
        echo  -e "Server Jira Running… [ \e[1;49;36mOK\e[0m ] "
    }

start ()
    {
        if [[ -z $JUDGE ]];then    
            if [[ -e "$DATA_HOME/.jira-home.lock" ]];then
                cd $PATH_HOME &&  mv $DATA_HOME/.jira-home.lock $DATA_HOME/$TIME.jira-home.lock
                $PATH_HOME/bin/startup.sh>/dev/null && count
            else
                $PATH_HOME/bin/startup.sh >/dev/null &&count
            fi
        fi
        unset JUDGE
    }
stop ()
    {
        if [[ ! -z $JUDGE ]];then
            $PATH_HOME/bin/shutdown.sh >/dev/null&& echo  -e "Server Jira Stopped… [ \e[1;49;36mOK\e[0m ] "
        fi   
        unset JUDGE
    }   

status ()
    {
        if [[ ! -z $JUDGE ]];then echo "Jira Service …[ Running ]";else echo "Jira Service …[ Stopped ]";fi
        unset JUDGE
    }

case $JIRA_STATUS in
start)
    start
    status
    ;;
stop)
    stop
    ;;
restart)
    stop
    sleep 5
    start
    ;;
status)
    status
    ;;
*)
    echo "Usage: service jira {start|stop|restart|status}"
;;
esac
unset JIRA_STATUS
#############################

单独执行JIRA服务脚本的步骤:

unzip server_jira_kinggoo.com_.zip -d /etc/init.d/&&cd /etc/init.d/ && \
mv server_jira_kinggoo.com.sh  jira && chmod +x jira && chkconfig –add jira \
然后就可以service  jira  status|start|restart|*

 

THE END欢迎访问kinggoo.com

- THE END -
版权声明:
转载原创文章请注明,文章出处://kinggoo.com
原文地址:https://kinggoo.com/app-jira-jiraservicescript.htm
发表评论?

2 条评论。

  1. Whoa, whoa, get out the way with that good infoarmtion.

发表评论


此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据