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 | |
Nicolas De Loof | 07c307d | 2014-10-07 14:02:42 +0200 | [diff] [blame] | 8 | # if `docker run` first argument start with `--` the user is passing jenkins launcher arguments |
| 9 | if [[ $# -lt 1 ]] || [[ "$1" == "--"* ]]; then |
Charles Duffy | bbbb76d | 2016-09-20 11:42:02 -0500 | [diff] [blame] | 10 | |
| 11 | # read JAVA_OPTS and JENKINS_OPTS into arrays to avoid need for eval (and associated vulnerabilities) |
| 12 | java_opts_array=() |
| 13 | while IFS= read -r -d '' item; do |
| 14 | java_opts_array+=( "$item" ) |
| 15 | done < <(xargs printf '%s\0' <<<"$JAVA_OPTS") |
| 16 | |
| 17 | jenkins_opts_array=( ) |
| 18 | while IFS= read -r -d '' item; do |
| 19 | jenkins_opts_array+=( "$item" ) |
| 20 | done < <(xargs printf '%s\0' <<<"$JENKINS_OPTS") |
| 21 | |
| 22 | 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] | 23 | fi |
| 24 | |
| 25 | # As argument is not jenkins, assume user want to run his own process, for sample a `bash` shell to explore this image |
Nicolas De loof | b2b442e | 2014-10-08 08:05:02 +0200 | [diff] [blame] | 26 | exec "$@" |