48 lines
2.0 KiB
Bash
48 lines
2.0 KiB
Bash
#!/bin/sh
|
|
|
|
JENKINS_WAR="/usr/lib/jenkins/jenkins.war"
|
|
JENKINS_CONFIG="/usr/etc/jenkins.conf"
|
|
JENKINS_PID_FILE="/var/run/jenkins.pid"
|
|
|
|
[ -f "$JENKINS_CONFIG" ] && . "$JENKINS_CONFIG"
|
|
|
|
JAVA_CMD="/usr/bin/java $JENKINS_JAVA_OPTIONS -DJENKINS_HOME=$JENKINS_HOME -jar $JENKINS_WAR"
|
|
PARAMS="--daemon --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins"
|
|
[ -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_AJP_PORT" ] && PARAMS="$PARAMS --ajp13Port=$JENKINS_AJP_PORT"
|
|
[ -n "$JENKINS_AJP_LISTEN_ADDRESS" ] && PARAMS="$PARAMS --ajp13ListenAddress=$JENKINS_AJP_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
|
|
|
|
case $1 in
|
|
start)
|
|
/usr/bin/su -c "$JAVA_CMD $PARAMS >/dev/null" jenkins
|
|
/usr/bin/pgrep -a java | grep jenkins | cut -d' ' -f1 >$JENKINS_PID_FILE
|
|
;;
|
|
stop)
|
|
kill -9 $(cat $JENKINS_PID_FILE) 2>/dev/null
|
|
;;
|
|
restart)
|
|
$0 stop
|
|
sleep 2
|
|
$0 start
|
|
;;
|
|
*)
|
|
echo "Usage: $0 [start|stop|restart]"
|
|
;;
|
|
esac
|
|
|
|
# End of file
|