Skip to content

Instantly share code, notes, and snippets.

@mbs0221
Created November 24, 2023 16:25
Show Gist options
  • Save mbs0221/c05f06ac087cf9a7f2a1727ebfc3e3b4 to your computer and use it in GitHub Desktop.
Save mbs0221/c05f06ac087cf9a7f2a1727ebfc3e3b4 to your computer and use it in GitHub Desktop.
Shell script for intel-sgx environment.
#!/bin/bash
# Update the system
sudo apt-get update
sudo apt-get upgrade -y
# Install necessary packages
sudo apt-get install -y build-essential ocaml ocamlbuild automake autoconf libtool wget python-is-python3 libssl-dev git cmake perl protobuf-compiler
# Clone the Linux SGX SDK repository
test -d linux-sgx | git clone https://github.com/intel/linux-sgx.git
# Go to the linux-sgx directory
cd linux-sgx
# Checkout the desired version
git checkout sgx_2.22
# Initialize the submodules
git submodule update --init --recursive
# Download the Intel SGX Driver
test -f sgx_linux_x64_driver_2.11.54c9c4c.bin | wget https://download.01.org/intel-sgx/sgx-linux/2.22/distro/ubuntu22.04-server/sgx_linux_x64_driver_2.11.54c9c4c.bin
# Make the driver executable
chmod +x sgx_linux_x64_driver_2.11.54c9c4c.bin
# Install the driver
sudo ./sgx_linux_x64_driver_2.11.54c9c4c.bin
VERSION=${1:-2.22.100.3}
INSTALL_PATH_PREFIX=/opt/intel
SGX_LINUX_X64_SDK=./linux/installer/bin/sgx_linux_x64_sdk_${VERSION}.bin
PSW_LINUX_X64_BIN=./linux/installer/bin/sgx_linux_x64_psw_${VERSION}.bin
# Build the SGX SDK
make preparation
make sdk -j$(nproc)
make sdk_install_pkg -j$(nproc)
# Install the SGX SDK
echo 'yes' | sudo $SGX_LINUX_X64_SDK --prefix=$INSTALL_PATH_PREFIX
source /opt/intel/sgxsdk/environment
# Build the SGX PSW
make psw -j$(nproc)
make psw_install_pkg -j$(nproc)
# Install the SGX PSW
echo 'yes' | sudo $PSW_LINUX_X64_BIN --prefix=$INSTALL_PATH_PREFIX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment