Skip to content

Commit

Permalink
wait for unattended-upgr to finish & don't install tools that are alr…
Browse files Browse the repository at this point in the history
…eady installed
  • Loading branch information
bohendo committed Sep 22, 2023
1 parent 54e126c commit c51a5d5
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 33 deletions.
11 changes: 9 additions & 2 deletions cmd/cloudexec/user_data.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ stderr_log="/tmp/cloudexec-stderr.log"
########################################
# Required setup

# Wait for unattended-upgr to finish install/upgrading stuff in the background
while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do
echo "Waiting for unattended-upgr to finish..."
sleep 3
done

echo "Installing prereqs..."
export DEBIAN_FRONTEND=noninteractive
apt-get update
Expand Down Expand Up @@ -66,6 +72,9 @@ for tag in ${TAGS}; do
fi
done

export BUCKET_NAME="cloudexec-${USERNAME}"
echo "Using bucket ${BUCKET_NAME}"

echo "Setting up DigitalOcean credentials..."
# ensure these are set in the environment
if [[ -z ${DIGITALOCEAN_ACCESS_TOKEN} ]]; then
Expand Down Expand Up @@ -186,8 +195,6 @@ echo "Running setup..."
mkdir -p ~/output
eval "${SETUP_COMMANDS}"

export BUCKET_NAME="cloudexec-${USERNAME}"

echo "Downloading inputs..."
s3cmd get -r "s3://${BUCKET_NAME}/job-${JOB_ID}/input" ~/

Expand Down
70 changes: 39 additions & 31 deletions example/cloudexec.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,48 @@ timeout = "48h"

[commands]
setup = '''
echo "Installing solc and slither..."
python3 -m venv ~/venv
source ~/venv/bin/activate
pip3 install solc-select slither-analyzer crytic-compile
solc-select install 0.8.6
solc-select use 0.8.6
if ! command -v slither >/dev/null 2>&1; then
echo "Installing solc and slither..."
python3 -m venv ~/venv
source ~/venv/bin/activate
pip3 install solc-select slither-analyzer crytic-compile
solc-select install 0.8.6
solc-select use 0.8.6
fi
echo "Downloading echidna..."
curl -fsSL -o /tmp/echidna.zip https://github.com/crytic/echidna/releases/download/v2.2.1/echidna-2.2.1-Linux.zip
echo "Extracting echidna..."
unzip /tmp/echidna.zip -d /tmp
tar -xzf /tmp/echidna.tar.gz -C /tmp
echo "Installing echidna..."
mv /tmp/echidna /usr/local/bin
rm /tmp/echidna.tar.gz
if ! command -v echidna >/dev/null 2>&1; then
echo "Downloading echidna..."
curl -fsSL -o /tmp/echidna.zip https://github.com/crytic/echidna/releases/download/v2.2.1/echidna-2.2.1-Linux.zip
echo "Extracting echidna..."
unzip /tmp/echidna.zip -d /tmp
tar -xzf /tmp/echidna.tar.gz -C /tmp
echo "Installing echidna..."
mv /tmp/echidna /usr/local/bin
rm /tmp/echidna.tar.gz
fi
echo "Downloading medusa..."
sudo apt-get update; sudo apt-get install -y unzip
curl -fsSL https://github.com/crytic/medusa/releases/download/v0.1.0/medusa-linux-x64.zip -o medusa.zip
unzip medusa.zip
chmod +x medusa
sudo mv medusa /usr/local/bin
if ! command -v medusa >/dev/null 2>&1; then
echo "Downloading medusa..."
sudo apt-get update; sudo apt-get install -y unzip
curl -fsSL https://github.com/crytic/medusa/releases/download/v0.1.0/medusa-linux-x64.zip -o medusa.zip
unzip medusa.zip
chmod +x medusa
sudo mv medusa /usr/local/bin
fi
echo "Installing docker and its dependencies..."
apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
docker_key="$(curl -fsSL https://download.docker.com/linux/ubuntu/gpg)"
echo "${docker_key}" | apt-key add -
release="$(lsb_release -cs)"
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu ${release} stable"
apt-get update -y
apt-get install -y docker-ce docker-ce-cli containerd.io
user="$(whoami)"
usermod -aG docker "${user}"
systemctl enable docker
if ! command -v docker >/dev/null 2>&1; then
echo "Installing docker and its dependencies..."
apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
docker_key="$(curl -fsSL https://download.docker.com/linux/ubuntu/gpg)"
echo "${docker_key}" | apt-key add -
release="$(lsb_release -cs)"
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu ${release} stable"
apt-get update -y
apt-get install -y docker-ce docker-ce-cli containerd.io
user="$(whoami)"
usermod -aG docker "${user}"
systemctl enable docker
fi
'''

# This command is run after the setup script completes.
Expand Down

0 comments on commit c51a5d5

Please sign in to comment.