Vincent Latombe | c14af95 | 2016-07-18 10:20:12 +0200 | [diff] [blame] | 1 | #! /bin/bash -e |
Nicolas De Loof | d606438 | 2014-10-04 08:17:28 +0200 | [diff] [blame] | 2 | |
Charles Duffy | ffbd787 | 2016-09-20 11:51:35 -0500 | [diff] [blame] | 3 | : "${JENKINS_HOME:="/var/jenkins_home"}" |
Vladimir Khlyunev | cb02471 | 2022-02-28 19:50:43 +0400 | [diff] [blame] | 4 | |
| 5 | if [[ -f "/usr/local/bin/pre_startup_copy_plugins.sh" ]] ; then |
| 6 | /bin/bash /usr/local/bin/pre_startup_copy_plugins.sh |
| 7 | fi |
| 8 | |
Ivan Berezovskiy | 361a461 | 2019-05-08 16:19:28 +0400 | [diff] [blame] | 9 | cat << EOF >>/usr/share/jenkins/ref/init.groovy.d/executors.groovy |
| 10 | import jenkins.model.* |
| 11 | Jenkins.instance.setNumExecutors(${JENKINS_NUM_EXECUTORS:-2}) |
| 12 | EOF |
Charles Duffy | ffbd787 | 2016-09-20 11:51:35 -0500 | [diff] [blame] | 13 | touch "${COPY_REFERENCE_FILE_LOG}" || { echo "Can not write to ${COPY_REFERENCE_FILE_LOG}. Wrong volume permissions?"; exit 1; } |
Kanstantsin Shautsou | 4409632 | 2015-12-11 02:21:20 +0300 | [diff] [blame] | 14 | echo "--- Copying files at $(date)" >> "$COPY_REFERENCE_FILE_LOG" |
Charles Duffy | 9868358 | 2016-09-20 11:41:41 -0500 | [diff] [blame] | 15 | find /usr/share/jenkins/ref/ -type f -exec bash -c '. /usr/local/bin/jenkins-support; for arg; do copy_reference_file "$arg"; done' _ {} + |
Nicolas De Loof | acb8649 | 2014-10-24 13:43:13 +0200 | [diff] [blame] | 16 | |
Ivan Berezovskiy | 6985611 | 2019-04-02 19:23:33 +0400 | [diff] [blame] | 17 | export JENKINS_URL_PREFIX=${JENKINS_URL_PREFIX:-""} |
| 18 | export JENKINSTHEME_CSS_URL=${JENKINSTHEME_CSS_URL:-$JENKINS_URL_PREFIX/userContent/theme/mirantis.min.css} |
| 19 | export JENKINSTHEME_JS_URL=${JENKINSTHEME_JS_URL:-$JENKINS_URL_PREFIX/userContent/theme/mirantis.min.js} |
Ivan Berezovskiy | 3e05488 | 2018-11-30 15:54:26 +0400 | [diff] [blame] | 20 | [ -f $JENKINS_HOME/org.codefirst.SimpleThemeDecorator.xml ] || cat /opt/org.codefirst.SimpleThemeDecorator.xml | envsubst > $JENKINS_HOME/org.codefirst.SimpleThemeDecorator.xml |
Ivan Berezovskiy | af370ed | 2020-01-17 15:06:51 +0400 | [diff] [blame] | 21 | [ ! -e $JENKINS_HOME/secret.key ] && echo -n $(openssl rand -hex 32) > $JENKINS_HOME/secret.key # echo without EOL symbol |
| 22 | chmod 0600 $JENKINS_HOME/secret.key |
Filip Pytloun | e9e6f56 | 2016-08-31 16:30:33 +0200 | [diff] [blame] | 23 | |
Nicolas De Loof | 07c307d | 2014-10-07 14:02:42 +0200 | [diff] [blame] | 24 | # if `docker run` first argument start with `--` the user is passing jenkins launcher arguments |
| 25 | if [[ $# -lt 1 ]] || [[ "$1" == "--"* ]]; then |
Charles Duffy | bbbb76d | 2016-09-20 11:42:02 -0500 | [diff] [blame] | 26 | |
| 27 | # read JAVA_OPTS and JENKINS_OPTS into arrays to avoid need for eval (and associated vulnerabilities) |
| 28 | java_opts_array=() |
| 29 | while IFS= read -r -d '' item; do |
| 30 | java_opts_array+=( "$item" ) |
Charles Duffy | 837f9a6 | 2016-09-27 16:14:25 -0500 | [diff] [blame] | 31 | done < <([[ $JAVA_OPTS ]] && xargs printf '%s\0' <<<"$JAVA_OPTS") |
Charles Duffy | bbbb76d | 2016-09-20 11:42:02 -0500 | [diff] [blame] | 32 | |
| 33 | jenkins_opts_array=( ) |
| 34 | while IFS= read -r -d '' item; do |
| 35 | jenkins_opts_array+=( "$item" ) |
Charles Duffy | 837f9a6 | 2016-09-27 16:14:25 -0500 | [diff] [blame] | 36 | done < <([[ $JENKINS_OPTS ]] && xargs printf '%s\0' <<<"$JENKINS_OPTS") |
Charles Duffy | bbbb76d | 2016-09-20 11:42:02 -0500 | [diff] [blame] | 37 | |
| 38 | exec java "${java_opts_array[@]}" -jar /usr/share/jenkins/jenkins.war "${jenkins_opts_array[@]}" "$@" |
Nicolas De Loof | 07c307d | 2014-10-07 14:02:42 +0200 | [diff] [blame] | 39 | fi |
| 40 | |
annerajb | 4d9ddc9 | 2016-11-15 14:23:58 -0400 | [diff] [blame] | 41 | # As argument is not jenkins, assume user want to run his own process, for example a `bash` shell to explore this image |
Nicolas De loof | b2b442e | 2014-10-08 08:05:02 +0200 | [diff] [blame] | 42 | exec "$@" |