blob: 96db0638fa89ed4cd07819963d02b01a71d6d878 [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}
19 cp -r /usr/share/jenkins/ref/${rel} /var/jenkins_home/${rel};
20 fi;
21}
22export -f copy_reference_file
Jesse Glick8cdfb1f2015-04-28 09:32:11 -040023echo "--- Copying files at $(date)" >> $COPY_REFERENCE_FILE_LOG
Nicolas De Loofacb86492014-10-24 13:43:13 +020024find /usr/share/jenkins/ref/ -type f -exec bash -c 'copy_reference_file {}' \;
25
Nicolas De Loof07c307d2014-10-07 14:02:42 +020026# if `docker run` first argument start with `--` the user is passing jenkins launcher arguments
27if [[ $# -lt 1 ]] || [[ "$1" == "--"* ]]; then
Nicolas De Looff744bdb2014-10-23 14:23:58 +020028 exec java $JAVA_OPTS -jar /usr/share/jenkins/jenkins.war $JENKINS_OPTS "$@"
Nicolas De Loof07c307d2014-10-07 14:02:42 +020029fi
30
31# 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 +020032exec "$@"
Nicolas De Loofd6064382014-10-04 08:17:28 +020033