-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1022 from scrtlabs/getting-started-docs
Getting started docs
- Loading branch information
Showing
3 changed files
with
233 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
#! /bin/bash | ||
|
||
set -e | ||
|
||
INSTALL_DEPS=${1:-"true"} | ||
INSTALL_SDK=${2:-"true"} | ||
INSTALL_PSW=${3:-"true"} | ||
INSTALL_DRIVER=${4:-"true"} | ||
UBUNTUVERSION=$(lsb_release -r -s | cut -d '.' -f 1) | ||
|
||
if [ "$(id -u)" -ne 0 ]; then | ||
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' | ||
exit 1 | ||
fi | ||
|
||
if (($UBUNTUVERSION < 16)); then | ||
echo "Your version of Ubuntu is not supported. Must have Ubuntu 16.04 and up. Aborting installation script..." | ||
exit 1 | ||
elif (($UBUNTUVERSION < 18)); then | ||
DISTRO='xenial' | ||
elif (($UBUNTUVERSION < 20)); then | ||
DISTRO='bionic' | ||
OS='ubuntu18.04-server' | ||
else | ||
DISTRO='focal' | ||
OS='ubuntu20.04-server' | ||
fi | ||
|
||
deps() { | ||
echo "\n\n#######################################" | ||
echo "##### Installing missing packages #####" | ||
echo "#######################################\n\n" | ||
|
||
# Install needed packages for script | ||
sudo apt install -y make wget | ||
} | ||
|
||
install_sdk(){ | ||
# Create a working directory to download and install the SDK inside | ||
mkdir -p "$HOME/.sgxsdk" | ||
|
||
# In a new sub-shell cd into our working directory so to no pollute the | ||
# original shell's working directory | ||
cd "$HOME/.sgxsdk" | ||
|
||
wget -O https://download.01.org/intel-sgx/sgx-linux/2.13/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.13.100.4.bin | ||
|
||
# Make the driver and SDK installers executable | ||
chmod +x ./sgx_linux_*.bin | ||
} | ||
|
||
install_sgx_driver(){ | ||
echo "\n\n###############################################" | ||
echo "##### Installing Intel SGX driver #####" | ||
echo "###############################################\n\n" | ||
|
||
wget -O https://download.01.org/intel-sgx/sgx-linux/2.13/distro/ubuntu20.04-server/sgx_linux_x64_driver_2.11.0_0373e2e.bin | ||
|
||
# Install the driver | ||
sudo ./sgx_linux_x64_driver_*.bin | ||
|
||
# Remount /dev as exec, also at system startup | ||
sudo tee /etc/systemd/system/remount-dev-exec.service >/dev/null <<EOF | ||
[Unit] | ||
Description=Remount /dev as exec to allow AESM service to boot and load enclaves into SGX | ||
[Service] | ||
Type=oneshot | ||
ExecStart=/bin/mount -o remount,exec /dev | ||
RemainAfterExit=true | ||
[Install] | ||
WantedBy=multi-user.target | ||
EOF | ||
|
||
sudo systemctl enable remount-dev-exec | ||
sudo systemctl start remount-dev-exec | ||
|
||
# Install the SDK inside ./sgxsdk/ which is inside $HOME/.sgxsdk | ||
echo yes | ./sgx_linux_x64_sdk_*.bin | ||
|
||
# Setup the environment variables for every new shell | ||
echo "source '$HOME/.sgxsdk/sgxsdk/environment'" | | ||
tee -a "$HOME/.bashrc" "$HOME/.zshrc" > /dev/null | ||
|
||
} | ||
|
||
install_psw(){ | ||
echo "\n\n##############################################" | ||
echo "##### Installing additional dependencies #####" | ||
echo "##############################################\n\n" | ||
|
||
# Add Intel's SGX PPA | ||
echo "deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu $DISTRO main" | | ||
sudo tee /etc/apt/sources.list.d/intel-sgx.list | ||
wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | | ||
sudo apt-key add - | ||
sudo apt update | ||
|
||
# Install all the additional necessary dependencies (besides the driver and the SDK) | ||
# for building a rust enclave | ||
wget -O /tmp/libprotobuf10_3.0.0-9_amd64.deb http://ftp.br.debian.org/debian/pool/main/p/protobuf/libprotobuf10_3.0.0-9_amd64.deb | ||
(sleep 3 ; echo y) | sudo gdebi /tmp/libprotobuf10_3.0.0-9_amd64.deb | ||
|
||
sudo apt install -y libsgx-enclave-common libsgx-enclave-common-dev libsgx-urts sgx-aesm-service libsgx-uae-service libsgx-launch libsgx-aesm-launch-plugin libsgx-ae-le autoconf libtool | ||
} | ||
|
||
deps | ||
|
||
if [ "${INSTALL_SDK}" = "true" ]; then | ||
install_sdk | ||
fi | ||
|
||
if [ "${INSTALL_PSW}" = "true" ]; then | ||
install_psw | ||
fi | ||
|
||
if [ "${INSTALL_DRIVER}" = "true" ]; then | ||
install_sgx_driver | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit -o nounset | ||
|
||
CHAINID=$1 | ||
GENACCT=$2 | ||
|
||
if [ -z "$1" ]; then | ||
echo "Need to input chain id..." | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$2" ]; then | ||
echo "Need to input genesis account address..." | ||
exit 1 | ||
fi | ||
|
||
# Build genesis file incl account for passed address | ||
coins="10000000000uscrt,100000000000stake" | ||
secretd init --chain-id $CHAINID $CHAINID | ||
secretd keys add validator --keyring-backend="test" | ||
secretd add-genesis-account $(secretd keys show validator -a --keyring-backend="test") $coins | ||
secretd add-genesis-account $GENACCT $coins | ||
secretd gentx validator 5000000000uscrt --keyring-backend="test" --chain-id $CHAINID | ||
secretd collect-gentxs | ||
|
||
# Set proper defaults and change ports | ||
sed -i 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' ~/.secretd/config/config.toml | ||
sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' ~/.secretd/config/config.toml | ||
sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' ~/.secretd/config/config.toml | ||
sed -i 's/index_all_keys = false/index_all_keys = true/g' ~/.secretd/config/config.toml | ||
|
||
# Start the secretd | ||
secretd start --pruning=nothing --bootstrap |