11#! /usr/bin/env bash
22set -e
33shopt -s expand_aliasas
4+ thisdir=" $( dirname " $0 " ) "
45
56packages=" " # a space separated list of packages to install
67function add-pkg()
@@ -12,24 +13,53 @@ if [ -f /etc/os-release ]; then
1213 source /etc/os-release
1314 if grep -q rhel /etc/os-release; then
1415 yum update --assumeyes
15- alias software =' yum install --assumeyes'
16+ alias packages =' yum install --assumeyes'
1617 elif grep -q debian /etc/os-release; then
17- alias software =' DEBIAN_FRONTEND=noninteractive apt install --yes'
18+ alias packages =' DEBIAN_FRONTEND=noninteractive apt install --yes'
1819 elif grep -q suse /etc/os-release; then
19- alias software =' zypper install -y'
20+ alias packages =' zypper install -y'
2021 else
2122 echo " Unknown platform ID $ID . Need this information in order to update/upgrade distribution packages."
2223 exit 1
2324 fi
2425elif [ -f /etc/redhat-release ]; then
25- alias software =' yum install --assumeyes'
26+ alias packages =' yum install --assumeyes'
2627 # shellcheck disable=SC1091
2728 source /etc/redhat-release
2829else
2930 echo " No /etc/os-release or /etc/redhat-release so cant determine platform."
3031 exit 1
3132fi
3233
34+ if [ -f /etc/cfengine-containers-host.flag ]; then
35+ if echo " $ID_LIKE " | grep debian && [ " $VERSION_ID " -ge " 12" ]; then
36+ # in jenkins, CONTAINER labeled nodes are capable of running container builds like valgrind-check and static-check
37+ add-pkg unzip # linux-install-groovy.sh needs unzip to unpack the groovy distribution archive
38+ add-pkg buildah
39+ add-pkg jq
40+ add-pkg make
41+ add-pkg parallel
42+ add-pkg podman
43+ if ! command -v groovy; then
44+ bash " $thisdir " /linux-install-groovy.sh
45+ fi
46+
47+ # NOPASSWD is needed for various tools related to container jobs
48+ rm -rf /etc/sudoers.d/999-local
49+ cat > /etc/sudoers.d/999-local << EOF
50+ %wheel ALL=NOPASSWD: /usr/bin/lvm-cache-stats
51+ %wheel ALL=NOPASSWD: /usr/bin/podman
52+ %sudo ALL=NOPASSWD: /usr/bin/lvm-cache-stats
53+ %sudo ALL=NOPASSWD: /usr/bin/podman
54+ %sudo ALL=NOPASSWD: /usr/sbin/lvs
55+ %sudo ALL=NOPASSWD: /usr/bin/journalctl
56+ jenkins ALL=NOPASSWD: /usr/bin/podman
57+ EOF
58+ chmod 400 /etc/sudoers.d/999-local
59+ chown root:root /etc/sudoers.d/999-local
60+ fi
61+ fi
62+
3363if echo " $ID_LIKE " | grep rhel; then
3464 if [ " $VERSION_ID " != " 6" ] && [ " $VERSION_ID " != " 7" ]; then
3565 if ! grep best=False /etc/yum.conf; then
@@ -118,4 +148,7 @@ if echo "$ID_LIKE" | grep rhel; then
118148
119149fi
120150
121- software $packages
151+ # packages is a dynamic alias set near the top of this script
152+ # shellcheck disable=SC2086
153+ # ^^^ we want space separated package names as separate args, not one arg with the space separated list
154+ packages $packages
0 commit comments