#!/usr/bin/env bash # # Copyright (C) 2011-2019 Intel Corporation. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # * Neither the name of Intel Corporation nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # grep 'sgx\.ko$\|intel_sgx\.ko$' /lib/modules/$(uname -r)/modules.builtin &> /dev/null if [[ $? != "0" ]]; then /sbin/modinfo isgx &> /dev/null if [[ $? != "0" ]]; then /sbin/modinfo intel_sgx &> /dev/null if [[ $? != "0" ]]; then lsmod | grep 'isgx\|intel_sgx' &> /dev/null if [[ $? = "0" ]]; then echo "Warning: You did not follow the document to install the driver package." echo elif [[ ! -e /dev/isgx ]] && [[ ! -e /dev/sgx ]]; then echo -e "\033[31;49;1mWarning: You may need to activate the SGX module if SGX is enabled in the kernel (e.g., sudo modprobe sgx) or download and install the SGX driver if the kernel doesn't have SGX support.\033[39;49;0m" echo fi fi fi fi set -e PKG_NAME="Intel SGX PSW Package" if test $(id -u) -ne 0; then echo "Root privilege is required to install $PKG_NAME." exit 4 fi PKG_ARCH=x64 ARCH=$(uname -m) if [ $ARCH == "i386" ] || [ $ARCH == "i586" ] || [ $ARCH == "i686" ]; then ARCH=x86 fi if [ $ARCH == "x86_64" ]; then ARCH=x64 fi if [[ $ARCH != $PKG_ARCH ]]; then echo "$PKG_ARCH $PKG_NAME can not be installed on $ARCH platform." exit 4 fi INSTALL_PATH=/opt/intel/sgxpsw if [ -d "$INSTALL_PATH" ]; then echo "$PKG_NAME already exists in $INSTALL_PATH, please uninstall it first!" exit 4 fi PATH=/usr/bin:/bin umask 022 PSWPKG=`mktemp -t sgx-psw-pkg.XXXXXX` PSW_TEMP_FOLDER=`mktemp -d sgx-psw-XXXXXX -p /tmp` trap "rm -fr $PSWPKG $PSW_TEMP_FOLDER= 2>/dev/null; exit 3" HUP INT QUIT TERM # The number of lines in this script (plus 1). Using this number to # calculate the start address of the payload. NR_SCRIPT_LINES=134 # Run /usr/bin/md5sum on the binary payload to get the MD5 check sum. CHKSUM=ed2bd989132249ca1a3b623c5a27ba2b # Get the install payload from this shell script. echo -n "Unpacking $PKG_NAME ..." tail -n +$NR_SCRIPT_LINES "$0" > $PSWPKG echo " done." echo -n "Verifying the integrity of the install package ..." if test $(md5sum $PSWPKG | awk '{print $1}') != $CHKSUM; then echo " The install package appears to be corrupted." exit 1 fi echo " done." echo -n "Installing $PKG_NAME ..." tar zxf $PSWPKG -C $PSW_TEMP_FOLDER >/dev/null 2>&1 retcode=$? # Save the return code # Clean-up the temporary tarball. rm -f $PSWPKG 2>/dev/null if test $retcode -ne 0; then echo " failed." exit 2 fi echo " done." pushd $PSW_TEMP_FOLDER source scripts/installConfig make install popd ${SGX_PACKAGES_PATH}/${PSW_PKG_N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