Vincent Latombe | c14af95 | 2016-07-18 10:20:12 +0200 | [diff] [blame] | 1 | #! /bin/bash -e |
Nicolas De Loof | d606438 | 2014-10-04 08:17:28 +0200 | [diff] [blame] | 2 | |
Charles Duffy | ffbd787 | 2016-09-20 11:51:35 -0500 | [diff] [blame] | 3 | : "${JENKINS_HOME:="/var/jenkins_home"}" |
| 4 | touch "${COPY_REFERENCE_FILE_LOG}" || { echo "Can not write to ${COPY_REFERENCE_FILE_LOG}. Wrong volume permissions?"; exit 1; } |
Kanstantsin Shautsou | 4409632 | 2015-12-11 02:21:20 +0300 | [diff] [blame] | 5 | echo "--- Copying files at $(date)" >> "$COPY_REFERENCE_FILE_LOG" |
Charles Duffy | 9868358 | 2016-09-20 11:41:41 -0500 | [diff] [blame] | 6 | find /usr/share/jenkins/ref/ -type f -exec bash -c '. /usr/local/bin/jenkins-support; for arg; do copy_reference_file "$arg"; done' _ {} + |
Nicolas De Loof | acb8649 | 2014-10-24 13:43:13 +0200 | [diff] [blame] | 7 | |
Filip Pytloun | d17c92d | 2017-03-16 17:50:25 +0100 | [diff] [blame] | 8 | export JENKINSTHEME_CSS_URL=${JENKINSTHEME_CSS_URL:-/userContent/theme/mirantis.css} |
Filip Pytloun | 2234425 | 2017-03-16 21:15:45 +0100 | [diff] [blame] | 9 | export JENKINSTHEME_JS_URL=${JENKINSTHEME_JS_URL:-/userContent/theme/mirantis.js} |
Filip Pytloun | 64ddc40 | 2017-03-16 16:30:56 +0100 | [diff] [blame] | 10 | [ -f $JENKINS_HOME/org.codefirst.SimpleThemeDecorator.xml ] || cat /tmp/org.codefirst.SimpleThemeDecorator.xml | envsubst > $JENKINS_HOME/org.codefirst.SimpleThemeDecorator.xml |
Jakub Pavlik | a067c49 | 2016-09-01 15:18:03 +0200 | [diff] [blame] | 11 | |
Filip Pytloun | e9e6f56 | 2016-08-31 16:30:33 +0200 | [diff] [blame] | 12 | cat << EOF >>/usr/share/jenkins/ref/init.groovy.d/executors.groovy |
| 13 | import jenkins.model.* |
| 14 | Jenkins.instance.setNumExecutors(${JENKINS_NUM_EXECUTORS:-2}) |
| 15 | EOF |
| 16 | |
Nicolas De Loof | 07c307d | 2014-10-07 14:02:42 +0200 | [diff] [blame] | 17 | # if `docker run` first argument start with `--` the user is passing jenkins launcher arguments |
| 18 | if [[ $# -lt 1 ]] || [[ "$1" == "--"* ]]; then |
Charles Duffy | bbbb76d | 2016-09-20 11:42:02 -0500 | [diff] [blame] | 19 | |
| 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 Duffy | 837f9a6 | 2016-09-27 16:14:25 -0500 | [diff] [blame] | 24 | done < <([[ $JAVA_OPTS ]] && xargs printf '%s\0' <<<"$JAVA_OPTS") |
Charles Duffy | bbbb76d | 2016-09-20 11:42:02 -0500 | [diff] [blame] | 25 | |
| 26 | jenkins_opts_array=( ) |
| 27 | while IFS= read -r -d '' item; do |
| 28 | jenkins_opts_array+=( "$item" ) |
Charles Duffy | 837f9a6 | 2016-09-27 16:14:25 -0500 | [diff] [blame] | 29 | done < <([[ $JENKINS_OPTS ]] && xargs printf '%s\0' <<<"$JENKINS_OPTS") |
Charles Duffy | bbbb76d | 2016-09-20 11:42:02 -0500 | [diff] [blame] | 30 | |
| 31 | exec java "${java_opts_array[@]}" -jar /usr/share/jenkins/jenkins.war "${jenkins_opts_array[@]}" "$@" |
Nicolas De Loof | 07c307d | 2014-10-07 14:02:42 +0200 | [diff] [blame] | 32 | fi |
| 33 | |
annerajb | 4d9ddc9 | 2016-11-15 14:23:58 -0400 | [diff] [blame] | 34 | # As argument is not jenkins, assume user want to run his own process, for example a `bash` shell to explore this image |
Nicolas De loof | b2b442e | 2014-10-08 08:05:02 +0200 | [diff] [blame] | 35 | exec "$@" |