作者:风来了.带狐狸了
jira为例 (confluence 只要把 jira.sh 中的 _ROOT 和_NAME 路径和名称修改就可以)
保存代码
把以下代码另存为 jira.sh 上传至 jira目录 /www/jira
centos
#! /bin/sh
# chkconfig: 2345 10 90
# description: jira ....
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
#prefix=/home/lanmps/jira
_ROOT=/home/lanmps/jira
_NAME=jira
#停止方法
stop(){
echo "Stoping $_NAME "
$_ROOT/bin/stop-jira.sh
}
case "$1" in
start)
echo "Starting $_NAME "
$_ROOT/bin/start-jira.sh
;;
stop)
stop
;;
restart)
stop
start
;;
status)
ps -ef|grep $_ROOT/work/catalina.pid
;;
*)
printf 'Usage: %s {start|stop|restart|status}\n' "$prog"
exit 1
;;
esac
Ubuntu下
#! /bin/sh
### BEGIN INIT INFO
# Provides: jira
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start or stop the jira.
### END INIT INFO
#prefix=/home/lanmps/jira
_ROOT=/home/lanmps/jira
_NAME=jira
#停止方法
stop(){
echo "Stoping $_NAME "
$_ROOT/bin/stop-${_NAME}.sh
}
case "$1" in
start)
echo "Starting $_NAME "
$_ROOT/bin/start-${_NAME}.sh
;;
stop)
stop
;;
restart)
stop
start
;;
status)
ps -ef|grep $_ROOT/work/catalina.pid
;;
*)
printf 'Usage: %s {start|stop|restart|status}\n' "$prog"
exit 1
;;
esac
设置权限及软连接
chmod +x jira.sh
ln -s /www/jira/jira.sh /etc/init.d/jira
设置启动项
centos下
chkconfig --add jira
chkconfig --level 345 jira on
Ubuntu下
update-rc.d -f jira defaults