project-config/nodepool/elements/jenkins-slave/install.d/20-jenkins-slave
Matthew Thode 56929e4639
make a gentoo nodepool image
Depends-On: I17202de3016616ce34c8cbead7d0fb047a64e96b

Change-Id: Icf5e7e8bc4f005111cd2492d3c1a2c492b8a7a96
2017-10-18 15:20:11 -05:00

54 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# Add jenkins user and group. Note we don't want to rely on
# "useradd"'s group adding behaviour, because it might differ across
# distros.
groupadd jenkins
useradd -g jenkins -m jenkins -s /bin/bash
# a lot of caching happens in extra-data.d (for "historical" reasons).
# We've put the cache stuff into /opt/cache/files, but again, for
# "historical" reasons, ensure this is available in /home/jenkins
#
# Check if the cache exists as we don't have a strict dependency on the
# devstack-cache element. This allows you to build an image without
# incurring the cost of caching all the things.
if [ -d /opt/cache/files ] ; then
mkdir -p /home/jenkins/cache
ln -sf /opt/cache/files /home/jenkins/cache/files
chown -R jenkins:jenkins /opt/cache/files
# but make sure the cache is readable by everyone
chmod -R a+rX /opt/cache/files/*
fi
# this was copied from outside the chroot by extras.d
_pub_key=/tmp/in_target.d/jenkins-user-ssh-public-key
if [ ! -f $_pub_key ]; then
die "Can not find Jenkins public key!"
fi
mkdir -p /home/jenkins/.ssh
chmod 700 /home/jenkins/.ssh
cp $_pub_key /home/jenkins/.ssh/authorized_keys
chmod 644 /home/jenkins/.ssh/authorized_keys
cat > /home/jenkins/.gitconfig <<EOF
[user]
name = OpenStack Jenkins
email = jenkins@openstack.org
signingkey = jenkins@openstack.org
[gitreview]
rebase = false
username = jenkins
EOF
# cleanup everything to the right owner
chown -R jenkins:jenkins /home/jenkins