The Wayback Machine - https://web.archive.org/web/20220625011333/https://github.com/clong/DetectionLab/commit/master
Skip to content
Permalink
Browse files
Remove mirrors
  • Loading branch information
clong committed Jun 20, 2022
1 parent 5025d06 commit 670622bcab6eb8aa51d93bbc5ca609cb267bc852
Showing 2 changed files with 48 additions and 5 deletions.
@@ -32,10 +32,6 @@ export DEBIAN_FRONTEND=noninteractive
echo "apt-fast apt-fast/maxdownloads string 10" | debconf-set-selections
echo "apt-fast apt-fast/dlflag boolean true" | debconf-set-selections

if ! grep 'mirrors.ubuntu.com/mirrors.txt' /etc/apt/sources.list; then
sed -i "2ideb mirror://mirrors.ubuntu.com/mirrors.txt focal main restricted universe multiverse\ndeb mirror://mirrors.ubuntu.com/mirrors.txt focal-updates main restricted universe multiverse\ndeb mirror://mirrors.ubuntu.com/mirrors.txt focal-backports main restricted universe multiverse\ndeb mirror://mirrors.ubuntu.com/mirrors.txt focal-security main restricted universe multiverse" /etc/apt/sources.list
fi

apt_install_prerequisites() {
echo "[$(date +%H:%M:%S)]: Adding apt repositories..."
# Add repository for apt-fast
@@ -52,7 +48,7 @@ apt_install_prerequisites() {
echo "[$(date +%H:%M:%S)]: Installing apt-fast..."
apt-get -qq install -y apt-fast
echo "[$(date +%H:%M:%S)]: Using apt-fast to install packages..."
apt-fast install -y jq whois build-essential git unzip htop yq mysql-server redis-server python3-pip libcairo2-dev libjpeg-turbo8-dev libpng-dev libtool-bin libossp-uuid-dev libavcodec-dev libavutil-dev libswscale-dev freerdp2-dev libpango1.0-dev libssh2-1-dev libvncserver-dev libtelnet-dev libssl-dev libvorbis-dev libwebp-dev tomcat9 tomcat9-admin tomcat9-user tomcat9-common
apt-fast install -y jq whois build-essential git unzip htop yq mysql-server redis-server python3-pip libcairo2-dev libjpeg-turbo8-dev libpng-dev libtool-bin libossp-uuid-dev libavcodec-dev libavutil-dev libswscale-dev freerdp2-dev libpango1.0-dev libssh2-1-dev libvncserver-dev libtelnet-dev libssl-dev libvorbis-dev libwebp-dev tomcat9 tomcat9-admin tomcat9-user tomcat9-common net-tools
}

modify_motd() {
@@ -0,0 +1,47 @@
#!/usr/bin/env bash

# This script is used to prepare DetectionLab to be imported as VM in AWS

if ! which aws > /dev/null; then
apt-get install -y python-pip
pip install awscli --upgrade --user
cp /root/.local/bin/aws /usr/local/bin/aws && chmod +x /usr/local/bin/aws
fi

# Configure credentials for awscli
aws configure set aws_access_key_id $AWS_ACCESS_KEY
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
aws configure set default.region us-west-1
export BUCKET_NAME="FILL_ME_IN"

cd /opt/DetectionLab/Vagrant || exit 1
# Stop logger and export box as an OVA
cd /opt/DetectionLab/Vagrant || exit 1
echo "Halting all VMs..."
vagrant halt

vboxmanage export logger -o /root/logger.ova && echo -n "success" > /root/logger.export || echo "failed" > /root/logger.export

# Sleep until all exports are complete
while [[ ! -f /root/logger.export ]];
do sleep 5
echo "Waiting for the OVA export to complete. Sleeping for 5."
done

# Copy each OVA into S3
if [[ "$(cat /root/logger.export)" == "success" ]]; then
aws s3 cp /root/logger.ova s3://$BUCKET_NAME/disks/
fi

# Fix the bucket
cd /opt/DetectionLab/AWS/Terraform/vm_import || exit 1
for file in *.json;
do sed -i "s/YOUR_BUCKET_GOES_HERE/$BUCKET_NAME/g" "$file";
done

# Fix the key names
for file in *.json;
do sed -i 's#"S3Key": "#"S3Key": "disks/#g' "$file";
done

aws ec2 import-image --description "logger" --license-type byol --disk-containers file:///opt/DetectionLab/AWS/Terraform/vm_import/logger.json

0 comments on commit 670622b

Please sign in to comment.