[root@localhost system]# cat /etc/init.d/jenkins
#!/bin/sh
#
# SUSE system statup script for Jenkins
# Copyright (C) Pascal Bleser
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or (at
# your option) any later version.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., Temple Place, Suite , Boston, MA -,
# USA.
#
### BEGIN INIT INFO
# Provides: jenkins
# Required-Start: $local_fs $remote_fs $network $time $named
# Should-Start: $time sendmail
# Required-Stop: $local_fs $remote_fs $network $time $named
# Should-Stop: $time sendmail
# Default-Start:
# Default-Stop:
# Short-Description: Jenkins Automation Server
# Description: Jenkins Automation Server
### END INIT INFO # Check for missing binaries (stale symlinks should not happen)
JENKINS_WAR="/usr/lib/jenkins/jenkins.war"
test -r "$JENKINS_WAR" || { echo "$JENKINS_WAR not installed";
if [ "$1" = "stop" ]; then exit ;
else exit ; fi; } # Check for existence of needed config file and read it
JENKINS_CONFIG=/etc/sysconfig/jenkins
test -e "$JENKINS_CONFIG" || { echo "$JENKINS_CONFIG not existing";
if [ "$1" = "stop" ]; then exit ;
else exit ; fi; }
test -r "$JENKINS_CONFIG" || { echo "$JENKINS_CONFIG not readable. Perhaps you forgot 'sudo'?";
if [ "$1" = "stop" ]; then exit ;
else exit ; fi; } JENKINS_PID_FILE="/var/run/jenkins.pid" # Source function library.
. /etc/init.d/functions # Read config
[ -f "$JENKINS_CONFIG" ] && . "$JENKINS_CONFIG" # Set up environment accordingly to the configuration settings
[ -n "$JENKINS_HOME" ] || { echo "JENKINS_HOME not configured in $JENKINS_CONFIG";
if [ "$1" = "stop" ]; then exit ;
else exit ; fi; }
[ -d "$JENKINS_HOME" ] || { echo "JENKINS_HOME directory does not exist: $JENKINS_HOME";
if [ "$1" = "stop" ]; then exit ;
else exit ; fi; } # Search usable Java as /usr/bin/java might not point to minimal version required by Jenkins.
# see http://www.nabble.com/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.html
candidates="
/etc/alternatives/java
/usr/lib/jvm/java-1.8./bin/java
/usr/lib/jvm/jre-1.8./bin/java
/usr/lib/jvm/java-1.7./bin/java
/usr/lib/jvm/jre-1.7./bin/java
/usr/bin/java
"
for candidate in $candidates
do
[ -x "$JENKINS_JAVA_CMD" ] && break
JENKINS_JAVA_CMD="$candidate"
done JAVA_CMD="$JENKINS_JAVA_CMD $JENKINS_JAVA_OPTIONS -DJENKINS_HOME=$JENKINS_HOME -jar $JENKINS_WAR"
PARAMS="--logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --daemon"
[ -n "$JENKINS_PORT" ] && PARAMS="$PARAMS --httpPort=$JENKINS_PORT"
[ -n "$JENKINS_LISTEN_ADDRESS" ] && PARAMS="$PARAMS --httpListenAddress=$JENKINS_LISTEN_ADDRESS"
[ -n "$JENKINS_HTTPS_PORT" ] && PARAMS="$PARAMS --httpsPort=$JENKINS_HTTPS_PORT"
[ -n "$JENKINS_HTTPS_KEYSTORE" ] && PARAMS="$PARAMS --httpsKeyStore=$JENKINS_HTTPS_KEYSTORE"
[ -n "$JENKINS_HTTPS_KEYSTORE_PASSWORD" ] && PARAMS="$PARAMS --httpsKeyStorePassword='$JENKINS_HTTPS_KEYSTORE_PASSWORD'"
[ -n "$JENKINS_HTTPS_LISTEN_ADDRESS" ] && PARAMS="$PARAMS --httpsListenAddress=$JENKINS_HTTPS_LISTEN_ADDRESS"
[ -n "$JENKINS_DEBUG_LEVEL" ] && PARAMS="$PARAMS --debug=$JENKINS_DEBUG_LEVEL"
[ -n "$JENKINS_HANDLER_STARTUP" ] && PARAMS="$PARAMS --handlerCountStartup=$JENKINS_HANDLER_STARTUP"
[ -n "$JENKINS_HANDLER_MAX" ] && PARAMS="$PARAMS --handlerCountMax=$JENKINS_HANDLER_MAX"
[ -n "$JENKINS_HANDLER_IDLE" ] && PARAMS="$PARAMS --handlerCountMaxIdle=$JENKINS_HANDLER_IDLE"
[ -n "$JENKINS_ARGS" ] && PARAMS="$PARAMS $JENKINS_ARGS" if [ "$JENKINS_ENABLE_ACCESS_LOG" = "yes" ]; then
PARAMS="$PARAMS --accessLoggerClassName=winstone.accesslog.SimpleAccessLogger --simpleAccessLogger.format=combined --simpleAccessLogger.file=/var/log/jenkins/access_log"
fi RETVAL= case "$1" in
start)
echo -n "Starting Jenkins "
daemon --user "$JENKINS_USER" --pidfile "$JENKINS_PID_FILE" $JAVA_CMD $PARAMS > /dev/null
RETVAL=$?
if [ $RETVAL = ]; then
success
echo > "$JENKINS_PID_FILE" # just in case we fail to find it
MY_SESSION_ID=`/bin/ps h -o sess -p $$`
# get PID
/bin/ps hww -u "$JENKINS_USER" -o sess,ppid,pid,cmd | \
while read sess ppid pid cmd; do
[ "$ppid" = ] || continue
# this test doesn't work because Jenkins sets a new Session ID
# [ "$sess" = "$MY_SESSION_ID" ] || continue
echo "$cmd" | grep $JENKINS_WAR > /dev/null
[ $? = ] || continue
# found a PID
echo $pid > "$JENKINS_PID_FILE"
done
else
failure
fi
echo
;;
stop)
echo -n "Shutting down Jenkins "
killproc jenkins
RETVAL=$?
echo
;;
try-restart|condrestart)
if test "$1" = "condrestart"; then
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
fi
$ status
if test $? = ; then
$ restart
else
: # Not running is not a failure.
fi
;;
restart)
$ stop
$ start
;;
force-reload)
echo -n "Reload service Jenkins "
$ try-restart
;;
reload)
$ restart
;;
status)
status jenkins
RETVAL=$?
;;
probe)
## Optional: Probe for the necessity of a reload, print out the
## argument to this init script which is required for a reload.
## Note: probe is not (yet) part of LSB (as of 1.9) test "$JENKINS_CONFIG" -nt "$JENKINS_PID_FILE" && echo reload
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
exit
;;
esac
exit $RETVAL

最新文章

  1. js导出excel
  2. Jquery插件Ztree使用所遇问题
  3. Oracle中用随机数更新字段----将一张表的数据插入另一张表----环境设置
  4. Expression表达式树
  5. Bootstrap系列 -- 21. 表单提示信息
  6. tarjan算法模板
  7. java之四大皆空
  8. JS基础DOM篇之二:DOM级别与节点层次?
  9. VLAN是什么
  10. VLAN间单臂路由访问
  11. Android (1) - Activity
  12. AsyncActivity异步加载网页
  13. Vue 非父子组件通信
  14. Linux下jdk环境配置
  15. hibernate框架学习笔记12:查询优化
  16. 《javascript经典入门》-day02
  17. django之关联field 描述子
  18. php 简单的学习GD库绘制图片并传回给前端实现方式
  19. 获取本地的ip,地址,code
  20. Booksort POJ - 3460 (IDA*)

热门文章

  1. Java集合框架(Collection Framework)学习之 HashMap
  2. Windowsform datagridview选中向父窗口传值
  3. django DatabaseFunctions
  4. docker安装与基本配置
  5. AOP之 Filter实用
  6. @functools.wrapes
  7. 2016级算法第三次上机-E.ModricWang's Polygons
  8. SAP生产订单各种日期的计算说明
  9. nginx(三)-动静分离
  10. javascipt中数组的常见操作