# Dependency setup script

You could run the following bash script as normal user to automate installation of all dependencies - you will still need to setup your own AWS account though :D&#x20;

```bash
#!/bin/bash

# Ensure the script is not run as root
if [ "$EUID" -eq 0 ]; then
  echo "[ERROR] This script must not be run as root. Please run it with sudo." >&2
  exit 1
fi

# Function to check internet connectivity
check_internet() {
  echo "Checking internet connectivity..."
  if ping -c 1 google.com &>/dev/null; then
    echo "Internet connectivity verified."
  else
    echo "No internet connectivity. Please check your connection and try again."
    exit 1
  fi
}

# Function to check if a command exists
command_exists() {
  command -v "$1" &>/dev/null
}

# Function to run commands as root
run_as_root() {
  echo "[INFO] Running as root: $*"
  sudo "$@"
}

# Function to install Terraform
install_terraform() {
  echo "Terraform not found. Installing Terraform 1.10.4..."
  wget https://releases.hashicorp.com/terraform/1.10.4/terraform_1.10.4_linux_amd64.zip -O /tmp/terraform.zip
  run_as_root apt-get update && run_as_root apt-get install -y unzip wget
  run_as_root unzip /tmp/terraform.zip -d /usr/local/bin/
  rm /tmp/terraform.zip
  echo "Terraform 1.10.4 installed successfully."
}

# Function to install Ansible
install_ansible() {
  echo "Ansible not found. Installing Ansible..."
  run_as_root apt-get update && run_as_root apt-get install -y ansible
  echo "Ansible installed successfully."
}

# Function to install Git
install_git() {
  echo "Git not found. Installing Git..."
  run_as_root apt-get update && run_as_root apt-get install -y git
  echo "Git installed successfully."
}

# Function to install Empire
install_empire() {
  echo "Empire not found. Installing Empire..."
  run_as_root mkdir -p /opt/Empire
  run_as_root chown -R "$USER:$USER" /opt/Empire/
  cd /opt/Empire/
  git clone --recursive https://github.com/BC-SECURITY/Empire.git /opt/Empire
  cd /opt/Empire || exit
  ./setup/checkout-latest-tag.sh
  ./ps-empire install -y
  echo "Empire installed successfully."
}

# Main script execution

# Check for Internet Connectivity
check_internet

# Check for Git
if command_exists git; then
  echo "Git is already installed."
else
  install_git
fi

# Check for Terraform
if command_exists terraform; then
  echo "Terraform is already installed."
else
  install_terraform
fi

# Check for Ansible
if command_exists ansible; then
  echo "Ansible is already installed."
else
  install_ansible
fi

# Check for Empire
if [ -f /opt/Empire/ps-empire ]; then
  echo "Empire is already installed."
else
  install_empire
fi

echo "All checks and installations completed successfully."

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sec565.gitbook.io/ad-privesc-with-empire/installing-the-environment/dependency-setup-script.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
