-The files in this directory are for initializing a Jenkins minion just before
-the cloud plugin hands the minion over to Jenkins.
+The files in this directory are for initializing a Jenkins minion just
+before the cloud plugin hands the minion over to Jenkins.
-init.sh is the entry point script which then calls all other scripts.
+The Jenkins 'init.sh' script will check for a project specific init
+script: '$ciman_root/jenkins-init-scripts/local-init.sh'. If the file
+exits and is executable, it will be executed. Note the local init
+script will be executed before the 'jenkins' user has been created.
+You can also call a project specific script from the Jenkins Manged
+File after the call to 'init.sh'.
-init.sh also provides a local init script entry point by checking for the
-existance of the file CIMAN_ROOT/jenkins-init-scripts/local-init.sh. If this
-file exists it can be used to further customize the server node before handing
-it to Jenkins for job use.
-
-To use this create a managed file in Jenkins with the contents:
+To use this create a Jenkins Managed File with the contents:
#!/bin/bash
- git clone --recurse-submodules https://gerrit.example.org/r/ci-management.git /opt/ciman
- /opt/ciman/jjb/global-jjb/jenkins-init-scripts/init.sh
+
+ gerrit_host=gerrit.example.org
+ ciman_root=/opt/ciman
+
+ until host $gerrit_host &>/dev/null ; do
+ echo "Waiting until $gerrit_host is resolvable..."
+ sleep 1
+ done
+
+ git clone --recurse-submodules https://$gerrit_host/r/ci-management $ciman_root
+
+ # Specify swapspace on the minion
+ # SWAP_SIZE specifies the size of swapspace in GB If set to '0' no
+ # swapspace will be allocated If unset, 1GB swapspace will be
+ # allocated
+ #export SWAP_SIZE=0
+
+ $ciman_root/global-jjb/jenkins-init-scripts/init.sh
+
+ rm -rf $ciman_root
OS=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
OS_RELEASE=$(facter lsbdistrelease | tr '[:upper:]' '[:lower:]')
-if [[ "$OS_RELEASE" == "18.04" ]] && [[ "$OS" == 'ubuntu' ]]
-then
- echo 'PATH=$HOME/.local/bin:$PATH
-export PATH' >> /etc/profile
+if [[ "$OS_RELEASE" == "18.04" && "$OS" == 'ubuntu' ]]; then
+ echo 'export PATH=$HOME/.local/bin:$PATH' >> /etc/profile
fi
useradd -m -s /bin/bash jenkins
fi
mkdir /home/jenkins/.ssh
-cp -r "/home/${OS}/.ssh/authorized_keys" /home/jenkins/.ssh/authorized_keys
+cp "/home/${OS}/.ssh/authorized_keys" /home/jenkins/.ssh/authorized_keys
+chmod 0600 /home/jenkins/.ssh/authorized_keys
# Generate ssh key for use by Robot jobs
echo -e 'y\n' | ssh-keygen -N "" -f /home/jenkins/.ssh/id_rsa -t rsa
chown -R jenkins:jenkins /home/jenkins/.ssh
-chmod 700 /home/jenkins/.ssh
+chmod 0700 /home/jenkins/.ssh
# The '/w' volume may already be part of image
[[ ! -d '/w' ]] && mkdir /w
# http://www.eclipse.org/legal/epl-v10.html
##############################################################################
-INIT_SCRIPTS_DIR="/opt/ciman/global-jjb/jenkins-init-scripts"
+ciman_init_scripts=$(readlink -f "$(dirname "$0")"/../../jenkins-init-scripts)
+jjb_init_scripts=$(readlink -f "$(dirname "$0")")
-"$INIT_SCRIPTS_DIR/package-listing.sh"
-"$INIT_SCRIPTS_DIR/basic-settings.sh"
-"$INIT_SCRIPTS_DIR/disable-firewall.sh"
-"$INIT_SCRIPTS_DIR/create-swap-file.sh"
+"$jjb_init_scripts/package-listing.sh"
+"$jjb_init_scripts/basic-settings.sh"
+"$jjb_init_scripts/disable-firewall.sh"
+"$jjb_init_scripts/create-swap-file.sh"
# Entry point for additional local minion customization
-# Eg. OpenDaylight has additional bootstrap scripts depending on minion type.
-if [ -f "/opt/ciman/jenkins-init-scripts/local-init.sh" ]; then
- /opt/ciman/jenkins-init-scripts/local-init.sh
+# Note this is called before the 'jenkins' account is created
+if [ -e "$ciman_init_scripts/local-init.sh" ]; then
+ "$ciman_init_scripts/local-init.sh"
fi
# Create the jenkins user last so that hopefully we DO NOT have to deal with
# guard files
-"$INIT_SCRIPTS_DIR/create-jenkins-user.sh"
+"$jjb_init_scripts/create-jenkins-user.sh"
# http://www.eclipse.org/legal/epl-v10.html
##############################################################################
-# Share script with JJB jobs so we only have to maintain it in one place
-JJB_SHELL_DIR="$(dirname $0)/../shell"
+# The 'init' scripts are located in 'jenkins-init-scripts' directory.
+# The 'global-jjb' scripts are located in 'shell' directory. The
+# 'package-listing' script is used by both, this is a simple wrapper
+# for 'shell/package-listing.sh'. Arguments would be quietly discarded.
-# Make sure the script is executable and then run it
-chmod +x "${JJB_SHELL_DIR}/package-listing.sh"
-"${JJB_SHELL_DIR}/package-listing.sh"
+jjb_init_scripts="$(dirname "$0")/../shell"
+
+"$jjb_init_scripts/package-listing.sh"
--- /dev/null
+---
+features:
+ - |
+ **jenkiins-init-scripts** The 'ciman' repo is not longer required to be
+ located in '/opt/ciman'.