blob: eeed64b230dbf3f546ed424a0ea28b3022a5fc0a [file] [log] [blame]
Nicolas De Loofd6064382014-10-04 08:17:28 +02001#! /bin/bash
2
Mike Dillon1f9d73c2015-04-06 17:17:40 -07003set -e
4
Nicolas De Loofacb86492014-10-24 13:43:13 +02005# 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.
9copy_reference_file() {
Kanstantsin Shautsou44096322015-12-11 02:21:20 +030010 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 Loofacb86492014-10-24 13:43:13 +020015 if [[ ! -e /var/jenkins_home/${rel} ]]
16 then
Kanstantsin Shautsou44096322015-12-11 02:21:20 +030017 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 Sanchez69d55cd2015-05-15 10:45:13 +020020 # pin plugins on initial copy
Kanstantsin Shautsou44096322015-12-11 02:21:20 +030021 [[ ${rel} == plugins/*.jpi ]] && touch "/var/jenkins_home/${rel}.pinned"
Nicolas De Loofacb86492014-10-24 13:43:13 +020022 fi;
23}
24export -f copy_reference_file
Kanstantsin Shautsou44096322015-12-11 02:21:20 +030025echo "--- Copying files at $(date)" >> "$COPY_REFERENCE_FILE_LOG"
Vincent Latombeaa2b3542015-08-04 14:10:24 +020026find /usr/share/jenkins/ref/ -type f -exec bash -c "copy_reference_file '{}'" \;
Nicolas De Loofacb86492014-10-24 13:43:13 +020027
Nicolas De Loof07c307d2014-10-07 14:02:42 +020028# if `docker run` first argument start with `--` the user is passing jenkins launcher arguments
29if [[ $# -lt 1 ]] || [[ "$1" == "--"* ]]; then
Nicolas De Looff744bdb2014-10-23 14:23:58 +020030 exec java $JAVA_OPTS -jar /usr/share/jenkins/jenkins.war $JENKINS_OPTS "$@"
Nicolas De Loof07c307d2014-10-07 14:02:42 +020031fi
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 loofb2b442e2014-10-08 08:05:02 +020034exec "$@"
Nicolas De Loofd6064382014-10-04 08:17:28 +020035