Last active
July 24, 2023 13:40
-
-
Save jdunkerley/0546b07d1cf1f4ff61f7e4f0ef541ad7 to your computer and use it in GitHub Desktop.
Amazon Linux EC2 Set Up For Enso
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
#!/bin/bash | |
instanceid=`aws ec2 describe-instances --query 'Reservations[0].Instances[*].InstanceId' --output text` | |
aws ssm start-session --target $instanceid |
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
#!/bin/bash -xe | |
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1 | |
yum update -y | |
yum upgrade -y | |
yum install git -y | |
yum groupinstall "Development Tools" -y | |
yum install openssl-devel -y | |
yum install cmake -y | |
export HOME="/root" | |
mkdir "$HOME/repos" -p | |
pushd "$HOME/repos" | |
git clone https://github.com/enso-org/enso.git | |
graalVersion=$( grep "val graalVersion " ./enso/build.sbt | awk '{print $4}' | sed -e 's/^"//' -e 's/"$//' ) | |
sbtVersion=$( grep "sbt.version=" ./enso/project/build.properties | sed -e 's/sbt.version=//' ) | |
popd | |
# Rust | |
curl https://sh.rustup.rs -sSf | sh -s -- -y | |
source $HOME/.cargo/env | |
rustup toolchain install stable # Stable toolchain required for the following tools. | |
cargo +stable install wasm-pack --version 0.10.2 # Install the wasm-pack toolkit. | |
cargo +stable install cargo-watch # To enable ./run watch utility | |
# NVM | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion | |
nvm install --lts | |
nvm use --lts | |
# Graal | |
mkdir "$HOME/.graalvm/" -p | |
pushd "$HOME/.graalvm/" | |
graalFile="graalvm-community-jdk-${graalVersion}_linux-x64_bin.tar.gz" | |
graalUrl="https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-$graalVersion/$graalFile" | |
wget -c $graalUrl | |
tar -xf $graalFile | |
graalPath=$( ls -1 | grep graalvm-community-openjdk-* ) | |
export PATH=$HOME/.graalvm/$graalPath/bin:$PATH | |
echo "export PATH=$HOME/.graalvm/$graalPath/bin:\$PATH" >> ~/.bashrc | |
export JAVA_HOME=$HOME/.graalvm/$graalPath | |
echo "export JAVA_HOME=$HOME/.graalvm/$graalPath" >> ~/.bashrc | |
popd | |
# SBT | |
mkdir "$HOME/.sbt/" -p | |
pushd "$HOME/.sbt/" | |
sbtFile="sbt-$sbtVersion.tgz" | |
sbtUrl="https://github.com/sbt/sbt/releases/download/v$sbtVersion/$sbtFile" | |
wget -c $sbtUrl | |
tar -xf $sbtFile | |
export PATH=$HOME/.sbt/sbt/bin:$PATH | |
echo "export PATH=$HOME/.sbt/sbt/bin:\$PATH" >> ~/.bashrc | |
popd | |
# FlatBuffers | |
flatcUrl="https://github.com/google/flatbuffers/archive/refs/tags/v1.12.0.tar.gz" | |
mkdir /tmp -p | |
pushd /tmp | |
wget -c $flatcUrl | |
tar -xf v1.12.0.tar.gz | |
cd flatbuffers-1.12.0/ | |
sed -i '156s/ std::memset(d_, 0, sizeof(d_));/ \\/\\/std::memset(d_, 0, sizeof(d_));/' tests/arrays_test_generated.h | |
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release | |
make | |
make install | |
popd | |
# Build What We Have | |
pushd "$HOME/repos/enso" | |
sbt bootstrap | |
sbt buildEngineDistribution | |
popd |
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
#!/bin/bash | |
instanceid=`aws ec2 describe-instances --query 'Reservations[0].Instances[*].InstanceId' --output text` | |
aws ec2 terminate-instances --instance-ids $instanceid |
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
#!/bin/bash | |
name=`whoami` | |
NOW=$( date '+%Y%m%d_%H%M%S' ) | |
volume=30 | |
tags="ResourceType=instance,Tags=[{Key=Name,Value=$name$NOW}" | |
instancetype='m6a.xlarge' # 4 vCPU 16GB RAM | |
while [[ $# -gt 0 ]] | |
do | |
key="$1" | |
case $key in | |
--volume) | |
volume=$2 | |
shift | |
shift | |
;; | |
--instancetype) | |
instancetype=$2 | |
shift | |
shift | |
;; | |
*) | |
tags="$tags,{Key=$1,Value=branch}" | |
shift | |
;; | |
esac | |
done | |
tags="$tags]" | |
templateid=`aws ec2 describe-launch-templates --output text --launch-template-names jdunkerley-enso --query 'LaunchTemplates[*].LaunchTemplateId'` | |
version=`aws ec2 describe-launch-template-versions --launch-template-id $templateid --query 'LaunchTemplateVersions[0].VersionNumber'` | |
instanceid=`aws ec2 run-instances --output text --instance-type $instancetype --launch-template LaunchTemplateId=$templateid,Version=$version --query 'Instances[*].InstanceId' --block-device-mapping "[ { \"DeviceName\": \"/dev/sda1\", \"Ebs\": { \"VolumeSize\": $volume } } ]" --tag-specification $tags` | |
echo "Instance ID - $instanceid created" | |
state=`aws ec2 describe-instance-status --output text --instance-ids $instanceid --query 'InstanceStatuses[*].InstanceState.Name'` | |
while [[ "$state" != "running" ]] | |
do | |
echo $state | |
sleep 1 | |
state=`aws ec2 describe-instance-status --output text --instance-ids $instanceid --query 'InstanceStatuses[*].InstanceState.Name'` | |
done | |
export ipaddress=`aws ec2 describe-instances --output text --instance-ids $instanceid --query 'Reservations[*].Instances[*].PublicIpAddress'` | |
echo "Instance IP $instanceid" | |
echo "Public IP Address $ipaddress" | |
echo "Connect with 'aws ssm start-session --target $instanceid'" | |
connected=`aws ssm list-inventory-entries --instance-id $instanceid --type-name "AWS:InstanceInformation" --query 'Entries[0].ResourceType'` | |
while [[ "$connected" != "\"EC2Instance\"" ]] | |
do | |
sleep 1 | |
connected=`aws ssm list-inventory-entries --instance-id $instanceid --type-name "AWS:InstanceInformation" --query 'Entries[0].ResourceType'` | |
done | |
aws ssm start-session --target $instanceid |
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
#!/bin/bash | |
templateid=`aws ec2 describe-launch-templates --output text --launch-template-names jdunkerley-enso --query 'LaunchTemplates[*].LaunchTemplateId'` | |
versionid=`aws ec2 describe-launch-templates --output text --launch-template-names jdunkerley-enso --query 'LaunchTemplates[*].LatestVersionNumber'` | |
base64=`base64 init.sh -w0` | |
aws ec2 create-launch-template-version --launch-template-id $templateid --source-version $versionid --launch-template-data "{\"UserData\":\"$base64\"}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment