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() { |
| 10 | f=${1%/} |
Jesse Glick | 8cdfb1f | 2015-04-28 09:32:11 -0400 | [diff] [blame] | 11 | echo "$f" >> $COPY_REFERENCE_FILE_LOG |
Nicolas De Loof | acb8649 | 2014-10-24 13:43:13 +0200 | [diff] [blame] | 12 | rel=${f:23} |
Jesse Glick | eaad361 | 2015-04-27 16:08:29 -0400 | [diff] [blame] | 13 | dir=$(dirname ${f}) |
Jesse Glick | 8cdfb1f | 2015-04-28 09:32:11 -0400 | [diff] [blame] | 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 |
Jesse Glick | 8cdfb1f | 2015-04-28 09:32:11 -0400 | [diff] [blame] | 17 | echo "copy $rel to JENKINS_HOME" >> $COPY_REFERENCE_FILE_LOG |
Nicolas De Loof | acb8649 | 2014-10-24 13:43:13 +0200 | [diff] [blame] | 18 | mkdir -p /var/jenkins_home/${dir:23} |
| 19 | cp -r /usr/share/jenkins/ref/${rel} /var/jenkins_home/${rel}; |
| 20 | fi; |
| 21 | } |
| 22 | export -f copy_reference_file |
Jesse Glick | 8cdfb1f | 2015-04-28 09:32:11 -0400 | [diff] [blame] | 23 | echo "--- Copying files at $(date)" >> $COPY_REFERENCE_FILE_LOG |
Nicolas De Loof | acb8649 | 2014-10-24 13:43:13 +0200 | [diff] [blame] | 24 | find /usr/share/jenkins/ref/ -type f -exec bash -c 'copy_reference_file {}' \; |
| 25 | |
Nicolas De Loof | 07c307d | 2014-10-07 14:02:42 +0200 | [diff] [blame] | 26 | # if `docker run` first argument start with `--` the user is passing jenkins launcher arguments |
| 27 | if [[ $# -lt 1 ]] || [[ "$1" == "--"* ]]; then |
Nicolas De Loof | f744bdb | 2014-10-23 14:23:58 +0200 | [diff] [blame] | 28 | 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] | 29 | fi |
| 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 loof | b2b442e | 2014-10-08 08:05:02 +0200 | [diff] [blame] | 32 | exec "$@" |
Nicolas De Loof | d606438 | 2014-10-04 08:17:28 +0200 | [diff] [blame] | 33 | |