1#!/bin/bash 2 3set -ex 4 5# Mirror jenkins user in container 6# jenkins user as ec2-user should have the same user-id 7echo "jenkins:x:1000:1000::/var/lib/jenkins:" >> /etc/passwd 8echo "jenkins:x:1000:" >> /etc/group 9# Needed on focal or newer 10echo "jenkins:*:19110:0:99999:7:::" >>/etc/shadow 11 12# Create $HOME 13mkdir -p /var/lib/jenkins 14chown jenkins:jenkins /var/lib/jenkins 15mkdir -p /var/lib/jenkins/.ccache 16chown jenkins:jenkins /var/lib/jenkins/.ccache 17 18# Allow writing to /usr/local (for make install) 19chown jenkins:jenkins /usr/local 20 21# Allow sudo 22# TODO: Maybe we shouldn't 23echo 'jenkins ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/jenkins 24 25# Work around bug where devtoolset replaces sudo and breaks it. 26if [ -n "$DEVTOOLSET_VERSION" ]; then 27 SUDO=/bin/sudo 28else 29 SUDO=sudo 30fi 31 32# Test that sudo works 33$SUDO -u jenkins $SUDO -v 34