This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 195
/
Copy pathsetup_env_centos.sh
executable file
·123 lines (100 loc) · 3.62 KB
/
setup_env_centos.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash
#
# Copyright (c) 2018-2019 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
set -e
cidir=$(dirname "$0")
source "/etc/os-release" || "source /usr/lib/os-release"
source "${cidir}/lib.sh"
# Obtain CentOS version
if [ -f /etc/os-release ]; then
centos_version=$(grep VERSION_ID /etc/os-release | cut -d '"' -f2)
else
centos_version=$(grep VERSION_ID /usr/lib/os-release | cut -d '"' -f2)
fi
[ "$centos_version" == 8 ] || die "This script is for CentOS 8 only"
# Send error when a package is not available in the repositories
if [ "$(tail -1 /etc/yum.conf | tr -d '\n')" != "skip_missing_names_on_install=0" ]; then
echo "skip_missing_names_on_install=0" | sudo tee -a /etc/yum.conf
fi
# Ensure EPEL repository is configured
sudo -E dnf -y install epel-release
# Enable priority to CentOS Base repo in order to
# avoid perl updating issues
for repo_file_path in /etc/yum.repos.d/CentOS-Base.repo \
/etc/yum.repos.d/CentOS-Linux-BaseOS.repo \
/etc/yum.repos.d/CentOS-Stream-BaseOS.repo; do
if [ -f "$repo_file_path" ]; then
repo_file="$repo_file_path"
break
fi
done
[ -n "${repo_file:-}" ] || die "Unable to find the CentOS base repository file"
if [ "$(tail -1 ${repo_file} | tr -d '\n')" != "priority=1" ]; then
echo "priority=1" | sudo tee -a "$repo_file"
fi
sudo -E dnf -y clean all
echo "Update repositories"
sudo -E dnf -y --nobest update
echo "Enable PowerTools repository"
sudo -E dnf install -y 'dnf-command(config-manager)'
sudo dnf config-manager --enable powertools
echo "Install chronic"
sudo -E dnf -y install moreutils
chronic sudo -E dnf install -y pkgconf-pkg-config
declare -A minimal_packages=( \
[spell-check]="hunspell hunspell-en-GB hunspell-en-US pandoc" \
[xml_validator]="libxml2" \
[yaml_validator]="yamllint" \
)
declare -A packages=( \
[kata_containers_dependencies]="libtool libtool-ltdl-devel device-mapper-persistent-data lvm2 libtool-ltdl" \
[qemu_dependencies]="libcap-devel libcap-ng-devel libattr-devel libcap-ng-devel librbd1-devel flex libfdt-devel libpmem-devel ninja-build" \
[kernel_dependencies]="elfutils-libelf-devel flex pkgconfig patch" \
[crio_dependencies]="glibc-static libseccomp-devel libassuan-devel libgpg-error-devel util-linux libselinux-devel" \
[gperf_dependencies]="gcc-c++" \
[bison_binary]="bison" \
[libgudev1-dev]="libgudev1-devel" \
[general_dependencies]="gpgme-devel glib2-devel glibc-devel bzip2 m4 gettext-devel automake autoconf pixman-devel coreutils expect" \
[build_tools]="python3 pkgconfig zlib-devel" \
[ostree]="ostree-devel" \
[metrics_dependencies]="bc jq" \
[crudini]="crudini" \
[haveged]="haveged" \
[libsystemd]="systemd-devel" \
[redis]="redis" \
[make]="make" \
[agent_shutdown_test]="tmux" \
[virtiofsd_dependencies]="unzip" \
[webhook_dependencies]="openssl" \
)
main()
{
local setup_type="$1"
[ -z "$setup_type" ] && die "need setup type"
local pkgs_to_install
local pkgs
for pkgs in "${minimal_packages[@]}"; do
info "The following package will be installed: $pkgs"
pkgs_to_install+=" $pkgs"
done
if [ "$setup_type" = "default" ]; then
for pkgs in "${packages[@]}"; do
info "The following package will be installed: $pkgs"
pkgs_to_install+=" $pkgs"
done
fi
# On centos:8 container image the installation of coreutils
# conflicts with coreutils-single because they mutually
# exclusive. Let's pass --allowerasing so that coreutils-single
# is replaced.
chronic sudo -E dnf -y install --allowerasing $pkgs_to_install
[ "$setup_type" = "minimal" ] && exit 0
if [ "$KATA_KSM_THROTTLER" == "yes" ]; then
echo "Install ${KATA_KSM_THROTTLER_JOB}"
chronic sudo -E dnf install ${KATA_KSM_THROTTLER_JOB}
fi
}
main "$@"