Nicolas De Loof | d606438 | 2014-10-04 08:17:28 +0200 | [diff] [blame] | 1 | #! /bin/bash |
| 2 | |
Mike Dillon | 1f9d73c | 2015-04-06 17:17:40 -0700 | [diff] [blame] | 3 | set -e |
| 4 | |
Nicolas De Loof | acb8649 | 2014-10-24 13:43:13 +0200 | [diff] [blame] | 5 | # Copy files from /usr/share/jenkins/ref into /var/jenkins_home |
Bastiaan Bakker | 45b0f67 | 2016-01-11 17:37:53 +0100 | [diff] [blame] | 6 | # So the initial JENKINS-HOME is set with expected content. |
| 7 | # Don't override, as this is just a reference setup, and use from UI |
Nicolas De Loof | acb8649 | 2014-10-24 13:43:13 +0200 | [diff] [blame] | 8 | # can then change this, upgrade plugins, etc. |
| 9 | copy_reference_file() { |
Kanstantsin Shautsou | 4409632 | 2015-12-11 02:21:20 +0300 | [diff] [blame] | 10 | f="${1%/}" |
Bastiaan Bakker | 45b0f67 | 2016-01-11 17:37:53 +0100 | [diff] [blame] | 11 | b="${f%.override}" |
Kanstantsin Shautsou | 4409632 | 2015-12-11 02:21:20 +0300 | [diff] [blame] | 12 | echo "$f" >> "$COPY_REFERENCE_FILE_LOG" |
Bastiaan Bakker | 45b0f67 | 2016-01-11 17:37:53 +0100 | [diff] [blame] | 13 | rel="${b:23}" |
| 14 | dir=$(dirname "${b}") |
| 15 | echo " $f -> $rel" >> "$COPY_REFERENCE_FILE_LOG" |
| 16 | if [[ ! -e /var/jenkins_home/${rel} || $f = *.override ]] |
Nicolas De Loof | acb8649 | 2014-10-24 13:43:13 +0200 | [diff] [blame] | 17 | then |
Kanstantsin Shautsou | 4409632 | 2015-12-11 02:21:20 +0300 | [diff] [blame] | 18 | echo "copy $rel to JENKINS_HOME" >> "$COPY_REFERENCE_FILE_LOG" |
| 19 | mkdir -p "/var/jenkins_home/${dir:23}" |
Bastiaan Bakker | 45b0f67 | 2016-01-11 17:37:53 +0100 | [diff] [blame] | 20 | cp -r "${f}" "/var/jenkins_home/${rel}"; |
Carlos Sanchez | 69d55cd | 2015-05-15 10:45:13 +0200 | [diff] [blame] | 21 | # pin plugins on initial copy |
Kanstantsin Shautsou | 4409632 | 2015-12-11 02:21:20 +0300 | [diff] [blame] | 22 | [[ ${rel} == plugins/*.jpi ]] && touch "/var/jenkins_home/${rel}.pinned" |
Bastiaan Bakker | 45b0f67 | 2016-01-11 17:37:53 +0100 | [diff] [blame] | 23 | fi; |
Nicolas De Loof | acb8649 | 2014-10-24 13:43:13 +0200 | [diff] [blame] | 24 | } |
| 25 | export -f copy_reference_file |
Carlos Sanchez | bd2f6c9 | 2016-01-14 09:15:47 +0100 | [diff] [blame] | 26 | 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] | 27 | echo "--- Copying files at $(date)" >> "$COPY_REFERENCE_FILE_LOG" |
Vincent Latombe | aa2b354 | 2015-08-04 14:10:24 +0200 | [diff] [blame] | 28 | find /usr/share/jenkins/ref/ -type f -exec bash -c "copy_reference_file '{}'" \; |
Nicolas De Loof | acb8649 | 2014-10-24 13:43:13 +0200 | [diff] [blame] | 29 | |
Nicolas De Loof | 07c307d | 2014-10-07 14:02:42 +0200 | [diff] [blame] | 30 | # if `docker run` first argument start with `--` the user is passing jenkins launcher arguments |
| 31 | if [[ $# -lt 1 ]] || [[ "$1" == "--"* ]]; then |
Carlos Sanchez | e7d56fa | 2016-02-29 13:55:33 +0100 | [diff] [blame^] | 32 | eval "exec java $JAVA_OPTS -jar /usr/share/jenkins/jenkins.war $JENKINS_OPTS \"\$@\"" |
Nicolas De Loof | 07c307d | 2014-10-07 14:02:42 +0200 | [diff] [blame] | 33 | fi |
| 34 | |
| 35 | # 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] | 36 | exec "$@" |