-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathsgx_detect.sh
executable file
·103 lines (86 loc) · 2.49 KB
/
sgx_detect.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
#!/bin/bash
source /opt/crust/crust-node/scripts/utils.sh
install_sgx_driver()
{
is_16=`cat /etc/issue | grep 16.04`
is_18=`cat /etc/issue | grep 18.04`
is_20=`cat /etc/issue | grep 20.04`
if [ x"$is_16" != x"" ]; then
driverbin=sgx_linux_x64_driver_2.6.0_b0a445b.bin
driverurl=https://download.01.org/intel-sgx/sgx-linux/2.11/distro/ubuntu16.04-server/$driverbin
log_info "Current system is ubuntu 16.04"
elif [ x"$is_18" != x"" ]; then
driverbin=sgx_linux_x64_driver_2.6.0_b0a445b.bin
driverurl=https://download.01.org/intel-sgx/sgx-linux/2.11/distro/ubuntu18.04-server/$driverbin
log_info "Current system is ubuntu 18.04"
elif [ x"$is_20" != x"" ]; then
driverbin=sgx_linux_x64_driver_2.11.0_4505f07.bin
driverurl=https://download.01.org/intel-sgx/sgx-linux/2.12/distro/ubuntu20.04-server/$driverbin
log_info "Current system is ubuntu 20.04"
else
log_err "Crust sworker can't support this system!"
exit 1
fi
log_info "Download sgx driver"
if [ -f "$driverbin" ]; then
rm $driverbin
fi
wget $driverurl
if [ $? -ne 0 ]; then
log_err "Download sgx dirver failed"
exit 1
fi
log_info "Installing denpendencies..."
apt-get install -y wget build-essential kmod linux-headers-`uname -r`
if [ $? -ne 0 ]; then
log_err "Install sgx driver dependencies failed"
exit 1
fi
log_info "Give sgx driver executable permission"
chmod +x $driverbin
log_info "Installing sgx driver..."
./$driverbin
if [ $? -ne 0 ]; then
log_err "Install sgx dirver bin failed"
exit 1
fi
log_info "Clear sgx dirver resource"
rm $driverbin
}
install_docker()
{
docker -v
if [ $? -ne 0 ]; then
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
if [ $? -ne 0 ]; then
log_err "Install docker failed"
exit 1
fi
fi
docker pull registry.cn-hangzhou.aliyuncs.com/crustio/sgx-detect:latest
}
function echo_c()
{
printf "\033[0;$1m$2\033[0m\n"
}
function log_info()
{
echo_c 33 "$1"
}
function log_success()
{
echo_c 32 "$1"
}
function log_err()
{
echo_c 35 "$1"
}
install_sgx_driver
install_docker
sgx_type=$(getSGXENCLAVEMODE)
device_path="/dev/isgx"
if [ x"$sgx_type" = x"ecdsa" ]; then
device_path="/dev/sgx"
fi
docker run -it --rm=true --device=$device_path registry.cn-hangzhou.aliyuncs.com/crustio/sgx-detect:latest
exit $?