Merge pull request #380 from clong/update_build_1804
Update build server code
This commit is contained in:
@@ -37,7 +37,7 @@ jobs:
|
||||
command: |
|
||||
## Provision a Type1 baremetal Packet.net server
|
||||
echo "[$(date +%H:%M:%S)]: Provisioning a server on Packet.net"
|
||||
DEVICE_ID=$(curl -s -X POST --header 'Accept: application/json' --header 'Content-Type: application/json' --header 'X-Auth-Token: '"$PACKET_API_TOKEN" -d '{ "facility": "sjc1", "plan": "baremetal_1", "hostname": "detectionlab", "description": "testing", "billing_cycle": "hourly", "operating_system": "ubuntu_16_04", "userdata": "", "locked": "false", "project_ssh_keys": ["315a9565-d5b1-41b6-913d-fcf022bb89a6", "755b134a-f63c-4fc5-9103-c1b63e65fdfc"] }' 'https://api.packet.net/projects/0b3f4f2e-ff05-41a8-899d-7923f620ca85/devices' | jq ."id" | tr -d '"')
|
||||
DEVICE_ID=$(curl -s -X POST --header 'Accept: application/json' --header 'Content-Type: application/json' --header 'X-Auth-Token: '"$PACKET_API_TOKEN" -d '{ "facility": "sjc1", "plan": "baremetal_1", "hostname": "detectionlab", "description": "testing", "billing_cycle": "hourly", "operating_system": "ubuntu_18_04", "userdata": "", "locked": "false", "project_ssh_keys": ["315a9565-d5b1-41b6-913d-fcf022bb89a6", "755b134a-f63c-4fc5-9103-c1b63e65fdfc"] }' 'https://api.packet.net/projects/0b3f4f2e-ff05-41a8-899d-7923f620ca85/devices' | jq ."id" | tr -d '"')
|
||||
echo $DEVICE_ID > /tmp/device_id
|
||||
# Make sure the device ID is sane.
|
||||
# TODO: maybe make this a regex
|
||||
@@ -45,7 +45,7 @@ jobs:
|
||||
echo "[$(date +%H:%M:%S)]: Server may have failed provisionining. Device ID is set to: $DEVICE_ID"
|
||||
echo "[$(date +%H:%M:%S)]: This usually happens if there are no servers available in the selected datacenter."
|
||||
echo "[$(date +%H:%M:%S)]: Attempting to retry in another datacenter..."
|
||||
export DEVICE_ID=$(curl -s -X POST --header 'Accept: application/json' --header 'Content-Type: application/json' --header 'X-Auth-Token: '"$PACKET_API_TOKEN" -d '{ "facility": "ewr1", "plan": "baremetal_1", "hostname": "detectionlab", "description": "testing", "billing_cycle": "hourly", "operating_system": "ubuntu_16_04", "userdata": "", "locked": "false", "project_ssh_keys": ["315a9565-d5b1-41b6-913d-fcf022bb89a6", "755b134a-f63c-4fc5-9103-c1b63e65fdfc"] }' 'https://api.packet.net/projects/0b3f4f2e-ff05-41a8-899d-7923f620ca85/devices' | jq ."id" | tr -d '"')
|
||||
export DEVICE_ID=$(curl -s -X POST --header 'Accept: application/json' --header 'Content-Type: application/json' --header 'X-Auth-Token: '"$PACKET_API_TOKEN" -d '{ "facility": "ewr1", "plan": "baremetal_1", "hostname": "detectionlab", "description": "testing", "billing_cycle": "hourly", "operating_system": "ubuntu_18_04", "userdata": "", "locked": "false", "project_ssh_keys": ["315a9565-d5b1-41b6-913d-fcf022bb89a6", "755b134a-f63c-4fc5-9103-c1b63e65fdfc"] }' 'https://api.packet.net/projects/0b3f4f2e-ff05-41a8-899d-7923f620ca85/devices' | jq ."id" | tr -d '"')
|
||||
if [ "$(echo -n $DEVICE_ID | wc -c)" -ne 36 ]; then
|
||||
echo "[$(date +%H:%M:%S)]: This script was still unable to successfully provision a server. Exiting."
|
||||
exit 1
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
# the text "building". Once the test is completed, the text will be replaced
|
||||
# with "success" or "failed".
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
# Bypass prompt for libsslv1.1 https://unix.stackexchange.com/a/543706
|
||||
echo 'libssl1.1:amd64 libraries/restart-without-asking boolean true' | sudo debconf-set-selections
|
||||
|
||||
# Download Packet.net storage utilities
|
||||
echo "[$(date +%H:%M:%S)]: Downloading Packet external storage utilities..."
|
||||
wget -q -O /usr/local/bin/packet-block-storage-attach "https://raw.githubusercontent.com/packethost/packet-block-storage/master/packet-block-storage-attach"
|
||||
@@ -54,14 +58,14 @@ fi
|
||||
echo "net.ipv6.conf.all.disable_ipv6=1" >> /etc/sysctl.conf
|
||||
sysctl -p /etc/sysctl.conf > /dev/null
|
||||
|
||||
# Install Virtualbox 5.2
|
||||
echo "deb http://download.virtualbox.org/virtualbox/debian xenial contrib" >> /etc/apt/sources.list
|
||||
sed -i "2ideb mirror://mirrors.ubuntu.com/mirrors.txt xenial main restricted universe multiverse\ndeb mirror://mirrors.ubuntu.com/mirrors.txt xenial-updates main restricted universe multiverse\ndeb mirror://mirrors.ubuntu.com/mirrors.txt xenial-backports main restricted universe multiverse\ndeb mirror://mirrors.ubuntu.com/mirrors.txt xenial-security main restricted universe multiverse" /etc/apt/sources.list
|
||||
# Install Virtualbox 6.1
|
||||
echo "deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
|
||||
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
|
||||
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
|
||||
echo "[$(date +%H:%M:%S)]: Running apt-get update..."
|
||||
apt-get -qq update
|
||||
echo "[$(date +%H:%M:%S)]: Running apt-get install..."
|
||||
apt-get -qq install -y linux-headers-"$(uname -r)" virtualbox-5.2 build-essential unzip git ufw apache2
|
||||
apt-get -qq install -y linux-headers-"$(uname -r)" virtualbox-6.1 build-essential unzip git ufw apache2
|
||||
|
||||
echo "building" > /var/www/html/index.html
|
||||
|
||||
@@ -75,8 +79,8 @@ ufw --force enable
|
||||
echo "[$(date +%H:%M:%S)]: Installing Vagrant..."
|
||||
mkdir /opt/vagrant
|
||||
cd /opt/vagrant || exit 1
|
||||
wget --progress=bar:force https://releases.hashicorp.com/vagrant/2.2.6/vagrant_2.2.6_x86_64.deb
|
||||
dpkg -i vagrant_2.2.6_x86_64.deb
|
||||
wget --progress=bar:force https://releases.hashicorp.com/vagrant/2.2.7/vagrant_2.2.7_x86_64.deb
|
||||
dpkg -i vagrant_2.2.7_x86_64.deb
|
||||
echo "[$(date +%H:%M:%S)]: Installing vagrant-reload plugin..."
|
||||
vagrant plugin install vagrant-reload
|
||||
|
||||
@@ -94,6 +98,10 @@ sysctl -p /etc/sysctl.conf > /dev/null
|
||||
cd /opt/DetectionLab/Vagrant || exit 1
|
||||
sed -i 's/vb.gui = true/vb.gui = false/g' Vagrantfile
|
||||
|
||||
# Temporary workaround for VB 6.1 until this is fixed in Vagrant
|
||||
# https://github.com/clong/DetectionLab/issues/374
|
||||
sed -i 's/--clipboard/--clipboard-mode/g' /opt/DetectionLab/Vagrant/Vagrantfile
|
||||
|
||||
# If the boxes are present on external storage, we can modify the Vagrantfile to
|
||||
# point to the boxes on disk so we don't have to download them
|
||||
if [ $BOXES_PRESENT -eq 1 ]; then
|
||||
|
||||
Reference in New Issue
Block a user