-
Notifications
You must be signed in to change notification settings - Fork 5
/
prereqs.sh
102 lines (89 loc) · 2.31 KB
/
prereqs.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
declare -a PRE_REQ_URLS
PRE_REQ_URLS=(
https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/m/makeself-2.2.0-3.el7.noarch.rpm
http://mirror.centos.org/centos/8/PowerTools/x86_64/os/Packages/tpm2-abrmd-devel-2.1.1-3.el8.x86_64.rpm
http://mirror.centos.org/centos/8/PowerTools/x86_64/os/Packages/trousers-devel-0.3.14-4.el8.x86_64.rpm
https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.10-3.2.el7.x86_64.rpm
)
declare -a PRE_REQ_PACKAGES
PRE_REQ_PACKAGES=(
makeself-2.2.0-3.el7.noarch.rpm
tpm2-abrmd-devel-2.1.1-3.el8.x86_64.rpm
trousers-devel-0.3.14-4.el8.x86_64.rpm
containerd.io-1.2.10-3.2.el7.x86_64.rpm
docker-ce-19.03.5
wget
gcc
gcc-c++
ant
git
patch
zip
unzip
java-1.8.0-openjdk-devel.x86_64
make
tpm2-tss-2.0.0-4.el8.x86_64
tpm2-abrmd-2.1.1-3.el8.x86_64
openssl-devel
)
#download pre-reqs
download_prereqs() {
local error_code=0
dnf install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
for url in ${!PRE_REQ_URLS[@]}; do
local package_url=${PRE_REQ_URLS[${url}]}
wget --no-check-certificate ${package_url}
local return_code=$?
if [ ${return_code} -ne 0 ]; then
echo "ERROR: could not download [${package_url}]"
return ${return_code}
fi
done
return ${error_code}
}
#install pre-reqs
install_prereqs() {
local error_code=0
for package in ${!PRE_REQ_PACKAGES[@]}; do
local package_name=${PRE_REQ_PACKAGES[${package}]}
dnf install -y ${package_name}
local return_code=$?
if [ ${return_code} -ne 0 ]; then
echo "ERROR: could not install [${package_name}]"
return ${return_code}
fi
done
systemctl daemon-reload
systemctl enable docker.service
systemctl restart docker.service
return ${error_code}
}
# functions handling i/o on command line
print_help() {
echo "Usage: $0 [-his]"
echo " -h print help and exit"
echo " -s pre-req setup"
}
dispatch_works() {
mkdir ~/.tmp
if [[ $1 = *"s"* ]] ; then
download_prereqs
install_prereqs
fi
}
if [ $# -eq 0 ] ; then
print_help
exit 1
fi
OPTIND=1
work_list=""
while getopts his opt; do
case ${opt} in
h) print_help; exit 0 ;;
s) work_list+="s" ;;
*) print_help; exit 1 ;;
esac
done
# run commands
dispatch_works $work_list