-
Notifications
You must be signed in to change notification settings - Fork 32
/
install_tpm_libs_rhel.sh
executable file
·194 lines (170 loc) · 4.18 KB
/
install_tpm_libs_rhel.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
TPM2_TSS_VER="4.0.1"
TPM2_TSS_LINK="https://github.com/tpm2-software/tpm2-tss/releases/download/$TPM2_TSS_VER/tpm2-tss-$TPM2_TSS_VER.tar.gz"
TPM2_OPENSSL_VER="1.1.1"
TPM2_OPENSSL_LINK="https://github.com/tpm2-software/tpm2-openssl/releases/download/$TPM2_OPENSSL_VER/tpm2-openssl-$TPM2_OPENSSL_VER.tar.gz"
PARENT_DIR=`pwd`
cd $PARENT_DIR
install_dependencies()
{
echo "Install the dependencies..."
yum -y install \
autoconf-archive \
libcmocka \
libcmocka-devel \
json-c-devel \
procps \
iproute \
gcc-c++ \
kernel-devel \
make \
git \
pkg-config \
gcc \
libtool \
automake \
uthash-devel \
autoconf \
doxygen \
m4 \
pandoc \
uriparser-devel \
dbus-devel \
glib2-devel \
dbus-x11 \
libuuid-devel \
diffutils
pip3 install pyyaml PyYAML
}
install_tpm2tss()
{
echo "Build & Install tpm2-tss version : $TPM2_TSS_VER"
cd $PARENT_DIR
rm -f tpm2-tss-$TPM2_TSS_VER.tar.gz
wget $TPM2_TSS_LINK
tar -xvzf tpm2-tss-$TPM2_TSS_VER.tar.gz
cd tpm2-tss-$TPM2_TSS_VER
./configure --disable-doxygen-doc --with-udevrulesdir=/etc/udev/rules.d/ PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
make -j$(nproc)
make install
udevadm control --reload-rules
udevadm trigger
ldconfig
}
install_tpm2abrmd()
{
echo "Build & Install tpm2-abrmd"
yum -y install tpm2-abrmd
service tpm2-abrmd stop
service tpm2-abrmd start
STATUS=$(service tpm2-abrmd status)
echo $STATUS
systemctl enable tpm2-abrmd.service
}
install_tpm2tools()
{
echo "Build & Install tpm2-tools"
yum -y install tpm2-tools
}
install_tpm2openssl()
{
echo "Build & Install tpm2-openssl..."
cd $PARENT_DIR
rm -f tpm2-openssl-$TPM2_OPENSSL_VER.tar.gz
wget $TPM2_OPENSSL_LINK
tar -xvzf tpm2-openssl-$TPM2_OPENSSL_VER.tar.gz
cd tpm2-openssl-$TPM2_OPENSSL_VER
./bootstrap
./configure --with-modulesdir=/usr/local/lib/ossl-modules/ PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
make -j$(nproc)
make install
libtool --finish /usr/local/lib/ossl-modules/
ldconfig
}
uninstall_tpm2tss()
{
echo "Uninstall tpm2-tss...."
cd $PARENT_DIR
cd tpm2-tss-$TPM2_TSS_VER
make uninstall
}
uninstall_tpm2abrmd()
{
echo "Uninstall tpm2-abrmd"
service tpm2-abrmd stop
systemctl disable tpm2-abrmd.service
yum -y remove tpm2-abrmd
}
uninstall_tpm2tools()
{
echo "Uninstall tpm2-tools...."
yum -y remove tpm2-tools
}
uninstall_tpm2openssl()
{
echo "Uninstall tpm2-openssl...."
cd $PARENT_DIR
cd tpm2-openssl-$TPM2_OPENSSL_VER
make uninstall
}
install()
{
echo -e "Installing all the tpm2 libraries..\n\n"
install_dependencies
install_tpm2tss
install_tpm2abrmd
install_tpm2tools
install_tpm2openssl
}
uninstall()
{
echo -e "Uninstalling all the tpm2 libraries..\n\n"
uninstall_tpm2tss
uninstall_tpm2abrmd
uninstall_tpm2tools
uninstall_tpm2openssl
cd $PARENT_DIR
rm -rf tpm2*
}
usage()
{
echo -e "Usage:
./$0 <OPTION>\n
OPTION:
-i - Install all tpm2 libraries.
-u - Uninstall all tpm2 libraries.
-t - Install only tpm2-tss library.
-d - Uninstall only tpm2-tss library.
-h - Help."
}
parse_args()
{
#Modes
INSTALL_ALL=1
UNINSTALL_ALL=2
INSTALL_TPM2_TSS_ONLY=4
UNINSTALL_TPM2_TSS_ONLY=8
mode=0
while getopts "iutdh" opt; do
case $opt in
(i) mode=$(($mode | $INSTALL_ALL));;
(u) mode=$(($mode | $UNINSTALL_ALL));;
(t) mode=$(($mode | $INSTALL_TPM2_TSS_ONLY));;
(d) mode=$(($mode | $UNINSTALL_TPM2_TSS_ONLY_SHIFT));;
(h | *) usage;
exit;;
esac
done
if [ $mode -eq $INSTALL_ALL ]; then
install
elif [ $mode -eq $UNINSTALL_ALL ]; then
uninstall
elif [ $mode -eq $INSTALL_TPM2_TSS_ONLY ]; then
install_tpm2tss
elif [ $mode -eq $UNINSTALL_TPM2_TSS_ONLY ]; then
uninstall_tpm2tss
else
echo -e "Invalid argument!\n"
usage
fi
}
parse_args "$@"