2016-07-18 08:20:12 +00:00
|
|
|
#! /bin/bash -e
|
2014-10-04 06:17:28 +00:00
|
|
|
|
2016-09-20 16:51:35 +00:00
|
|
|
: "${JENKINS_HOME:="/var/jenkins_home"}"
|
|
|
|
touch "${COPY_REFERENCE_FILE_LOG}" || { echo "Can not write to ${COPY_REFERENCE_FILE_LOG}. Wrong volume permissions?"; exit 1; }
|
2015-12-10 23:21:20 +00:00
|
|
|
echo "--- Copying files at $(date)" >> "$COPY_REFERENCE_FILE_LOG"
|
2017-03-10 13:05:06 +00:00
|
|
|
find /usr/share/jenkins/ref/ \( -type f -o -type l \) -exec bash -c '. /usr/local/bin/jenkins-support; for arg; do copy_reference_file "$arg"; done' _ {} +
|
2014-10-24 11:43:13 +00:00
|
|
|
|
2014-10-07 12:02:42 +00:00
|
|
|
# if `docker run` first argument start with `--` the user is passing jenkins launcher arguments
|
|
|
|
if [[ $# -lt 1 ]] || [[ "$1" == "--"* ]]; then
|
2016-09-20 16:42:02 +00:00
|
|
|
|
|
|
|
# read JAVA_OPTS and JENKINS_OPTS into arrays to avoid need for eval (and associated vulnerabilities)
|
|
|
|
java_opts_array=()
|
|
|
|
while IFS= read -r -d '' item; do
|
|
|
|
java_opts_array+=( "$item" )
|
2016-09-27 21:14:25 +00:00
|
|
|
done < <([[ $JAVA_OPTS ]] && xargs printf '%s\0' <<<"$JAVA_OPTS")
|
2016-09-20 16:42:02 +00:00
|
|
|
|
|
|
|
jenkins_opts_array=( )
|
|
|
|
while IFS= read -r -d '' item; do
|
|
|
|
jenkins_opts_array+=( "$item" )
|
2016-09-27 21:14:25 +00:00
|
|
|
done < <([[ $JENKINS_OPTS ]] && xargs printf '%s\0' <<<"$JENKINS_OPTS")
|
2016-09-20 16:42:02 +00:00
|
|
|
|
2017-09-13 18:46:42 +00:00
|
|
|
exec java -Duser.home="$JENKINS_HOME" "${java_opts_array[@]}" -jar /usr/share/jenkins/jenkins.war "${jenkins_opts_array[@]}" "$@"
|
2014-10-07 12:02:42 +00:00
|
|
|
fi
|
|
|
|
|
2016-11-15 18:23:58 +00:00
|
|
|
# As argument is not jenkins, assume user want to run his own process, for example a `bash` shell to explore this image
|
2014-10-08 06:05:02 +00:00
|
|
|
exec "$@"
|