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 |
| 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 |
| 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%/}" |
| 11 | echo "$f" >> "$COPY_REFERENCE_FILE_LOG" |
| 12 | rel="${f:23}" |
| 13 | dir="$(dirname ${f})" |
| 14 | echo " $f -> $rel" >> "$COPY_REFERENCE_FILE_LOG" |
Nicolas De Loof | acb8649 | 2014-10-24 13:43:13 +0200 | [diff] [blame] | 15 | if [[ ! -e /var/jenkins_home/${rel} ]] |
| 16 | then |
Kanstantsin Shautsou | 4409632 | 2015-12-11 02:21:20 +0300 | [diff] [blame^] | 17 | echo "copy $rel to JENKINS_HOME" >> "$COPY_REFERENCE_FILE_LOG" |
| 18 | mkdir -p "/var/jenkins_home/${dir:23}" |
| 19 | cp -r "/usr/share/jenkins/ref/${rel}" "/var/jenkins_home/${rel}"; |
Carlos Sanchez | 69d55cd | 2015-05-15 10:45:13 +0200 | [diff] [blame] | 20 | # pin plugins on initial copy |
Kanstantsin Shautsou | 4409632 | 2015-12-11 02:21:20 +0300 | [diff] [blame^] | 21 | [[ ${rel} == plugins/*.jpi ]] && touch "/var/jenkins_home/${rel}.pinned" |
Nicolas De Loof | acb8649 | 2014-10-24 13:43:13 +0200 | [diff] [blame] | 22 | fi; |
| 23 | } |
| 24 | export -f copy_reference_file |
Kanstantsin Shautsou | 4409632 | 2015-12-11 02:21:20 +0300 | [diff] [blame^] | 25 | echo "--- Copying files at $(date)" >> "$COPY_REFERENCE_FILE_LOG" |
Vincent Latombe | aa2b354 | 2015-08-04 14:10:24 +0200 | [diff] [blame] | 26 | 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] | 27 | |
Nicolas De Loof | 07c307d | 2014-10-07 14:02:42 +0200 | [diff] [blame] | 28 | # if `docker run` first argument start with `--` the user is passing jenkins launcher arguments |
| 29 | if [[ $# -lt 1 ]] || [[ "$1" == "--"* ]]; then |
Nicolas De Loof | f744bdb | 2014-10-23 14:23:58 +0200 | [diff] [blame] | 30 | 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] | 31 | fi |
| 32 | |
| 33 | # 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] | 34 | exec "$@" |
Nicolas De Loof | d606438 | 2014-10-04 08:17:28 +0200 | [diff] [blame] | 35 | |