forked from lwyeluo/tpm-emulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
174 lines (152 loc) · 3.34 KB
/
install.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
#!/bin/bash
basename=$(cd `dirname $0`; pwd)
echo "$basename"
sudo apt-get install m4 build-essential pkg-config devhelp libglib2.0-doc libgtk2.0-doc glade libglade2-dev libgtk2.0* openssl libssl-dev -y
if [ $? -ne 0 ]; then
echo "[ERROR] apt-get install failed"
exit 1
fi
cd $basename
install_cmake()
{
echo "[INFO] install cmake"
cd $basename
tar -xzvf cmake-3.0.2.tar.gz
cd cmake-3.0.2
./bootstrap
if [ $? -ne 0 ]; then
echo "[ERROR] configure cmake failed"
exit 1
fi
make
if [ $? -ne 0 ]; then
echo "[ERROR] make cmake failed"
exit 1
fi
sudo make install
if [ $? -ne 0 ]; then
echo "[ERROR] install cmake failed"
exit 1
fi
}
install_gmp()
{
echo "[INFO] install gmp"
cd $basename
tar -xjvf gmp-6.0.0a.tar.bz2
cd gmp-6.0.0/
./configure
if [ $? -ne 0 ]; then
echo "[ERROR] configure gmp failed"
exit 1
fi
make
if [ $? -ne 0 ]; then
echo "[ERROR] make gmp failed"
exit 1
fi
sudo make install
if [ $? -ne 0 ]; then
echo "[ERROR] install gmp failed"
exit 1
fi
}
install_tpm()
{
echo "[INFO] install tpm"
cd $basename/tpm-emulator
sh build.sh
if [ $? -ne 0 ]; then
echo "[ERROR] build tpm failed"
exit 1
fi
cd build/
sudo make install
if [ $? -ne 0 ]; then
echo "[ERROR] make install tpm failed"
exit 1
fi
}
init_tpm()
{
echo "[INFO] init tpm"
cd $basename/tpm-emulator
tpmd deactivated
killall tpmd
tpmd clear
depmod -a
modprobe tpmd_dev
if [ $? -ne 0 ]; then
echo "[ERROR] modprobe tpmd_dev failed"
exit 1
fi
}
install_trousers()
{
echo "[INFO] install trousers"
cd $basename
tar -xzvf trousers-0.3.13.tar.gz
cd trousers-0.3.13
#sed -i "s%\${top_builddir}/src/tddl/libtddl.a%/usr/local/lib/libtddl.so%g" src/tcsd/Makefile.am
#sed -i "s%\${top_builddir}/src/tddl/libtddl.a%/usr/local/lib/libtddl.so%g" src/tcsd/Makefile.in
cp $basename/replace-files/ps_utils.c src/tcs/ps
cp $basename/replace-files/tspps.h src/include
echo "/usr/local/lib" | sudo tee /etc/ld.so.conf.d/tddl.conf
sudo ldconfig
./configure
if [ $? -ne 0 ]; then
echo "[ERROR] configure trousers failed"
exit 1
fi
make
if [ $? -ne 0 ]; then
echo "[ERROR] make trousers failed"
exit 1
fi
sudo make install
if [ $? -ne 0 ]; then
echo "[ERROR] make install trousers failed"
exit 1
fi
}
install_tpm_tools()
{
echo "[INFO] install tpm-tools"
cd $basename
tar -xzvf tpm-tools-1.3.8.tar.gz
cd tpm-tools-1.3.8
./configure
if [ $? -ne 0 ]; then
echo "[ERROR] configure tpm-tools failed"
exit 1
fi
make
if [ $? -ne 0 ]; then
echo "[ERROR] make tpm-tools failed"
exit 1
fi
sudo make install
if [ $? -ne 0 ]; then
echo "[ERROR] make install tpm-tools failed"
exit 1
fi
}
ret=$(cmake --version | grep 3.0.2 | wc -l)
if [ "$ret" -eq "0" ]; then
install_cmake
install_gmp
fi
ret=$(which tpmd | wc -l)
if [ "$ret" -eq "0" ]; then
install_tpm
init_tpm
fi
ret=$(which tcsd | wc -l)
if [ "$ret" -eq "0" ]; then
install_trousers
fi
#ret=$(which tpm_version | wc -l)
#if [ "$ret" -eq "0" ]; then
# install_tpm_tools
#fi
echo "[INFO] done!"