blob: 97d7fcc8d1b1e3c7136d7c3515040cb8e767b503 [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() {
10 f=${1%/}
Jesse Glick8cdfb1f2015-04-28 09:32:11 -040011 echo "$f" >> $COPY_REFERENCE_FILE_LOG
Nicolas De Loofacb86492014-10-24 13:43:13 +020012 rel=${f:23}
Jesse Glickeaad3612015-04-27 16:08:29 -040013 dir=$(dirname ${f})
Jesse Glick8cdfb1f2015-04-28 09:32:11 -040014 echo " $f -> $rel" >> $COPY_REFERENCE_FILE_LOG
Nicolas De Loofacb86492014-10-24 13:43:13 +020015 if [[ ! -e /var/jenkins_home/${rel} ]]
16 then
Jesse Glick8cdfb1f2015-04-28 09:32:11 -040017 echo "copy $rel to JENKINS_HOME" >> $COPY_REFERENCE_FILE_LOG
Nicolas De Loofacb86492014-10-24 13:43:13 +020018 mkdir -p /var/jenkins_home/${dir:23}
Carlos Sanchez69d55cd2015-05-15 10:45:13 +020019 cp -r /usr/share/jenkins/ref/${rel} /var/jenkins_home/${rel};
20 # pin plugins on initial copy
21 [[ ${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
Jesse Glick8cdfb1f2015-04-28 09:32:11 -040025echo "--- 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