blob: bf8ece7b80b4c71df547905a66c7fd3c22c6be12 [file] [log] [blame]
Vincent Latombec14af952016-07-18 10:20:12 +02001#! /bin/bash -e
Nicolas De Loofd6064382014-10-04 08:17:28 +02002
Charles Duffyffbd7872016-09-20 11:51:35 -05003: "${JENKINS_HOME:="/var/jenkins_home"}"
4touch "${COPY_REFERENCE_FILE_LOG}" || { echo "Can not write to ${COPY_REFERENCE_FILE_LOG}. Wrong volume permissions?"; exit 1; }
Kanstantsin Shautsou44096322015-12-11 02:21:20 +03005echo "--- Copying files at $(date)" >> "$COPY_REFERENCE_FILE_LOG"
Charles Duffy98683582016-09-20 11:41:41 -05006find /usr/share/jenkins/ref/ -type f -exec bash -c '. /usr/local/bin/jenkins-support; for arg; do copy_reference_file "$arg"; done' _ {} +
Nicolas De Loofacb86492014-10-24 13:43:13 +02007
Jakub Josef32f20272018-01-16 17:46:16 +01008export JENKINSTHEME_CSS_URL=${JENKINSTHEME_CSS_URL:-/userContent/theme/mirantis.min.css}
9export JENKINSTHEME_JS_URL=${JENKINSTHEME_JS_URL:-/userContent/theme/mirantis.min.js}
Filip Pytloun64ddc402017-03-16 16:30:56 +010010[ -f $JENKINS_HOME/org.codefirst.SimpleThemeDecorator.xml ] || cat /tmp/org.codefirst.SimpleThemeDecorator.xml | envsubst > $JENKINS_HOME/org.codefirst.SimpleThemeDecorator.xml
Jakub Pavlika067c492016-09-01 15:18:03 +020011
Filip Pytloune9e6f562016-08-31 16:30:33 +020012cat << EOF >>/usr/share/jenkins/ref/init.groovy.d/executors.groovy
13import jenkins.model.*
14Jenkins.instance.setNumExecutors(${JENKINS_NUM_EXECUTORS:-2})
15EOF
16
Nicolas De Loof07c307d2014-10-07 14:02:42 +020017# if `docker run` first argument start with `--` the user is passing jenkins launcher arguments
18if [[ $# -lt 1 ]] || [[ "$1" == "--"* ]]; then
Charles Duffybbbb76d2016-09-20 11:42:02 -050019
20 # read JAVA_OPTS and JENKINS_OPTS into arrays to avoid need for eval (and associated vulnerabilities)
21 java_opts_array=()
22 while IFS= read -r -d '' item; do
23 java_opts_array+=( "$item" )
Charles Duffy837f9a62016-09-27 16:14:25 -050024 done < <([[ $JAVA_OPTS ]] && xargs printf '%s\0' <<<"$JAVA_OPTS")
Charles Duffybbbb76d2016-09-20 11:42:02 -050025
26 jenkins_opts_array=( )
27 while IFS= read -r -d '' item; do
28 jenkins_opts_array+=( "$item" )
Charles Duffy837f9a62016-09-27 16:14:25 -050029 done < <([[ $JENKINS_OPTS ]] && xargs printf '%s\0' <<<"$JENKINS_OPTS")
Charles Duffybbbb76d2016-09-20 11:42:02 -050030
31 exec java "${java_opts_array[@]}" -jar /usr/share/jenkins/jenkins.war "${jenkins_opts_array[@]}" "$@"
Nicolas De Loof07c307d2014-10-07 14:02:42 +020032fi
33
annerajb4d9ddc92016-11-15 14:23:58 -040034# As argument is not jenkins, assume user want to run his own process, for example a `bash` shell to explore this image
Nicolas De loofb2b442e2014-10-08 08:05:02 +020035exec "$@"