From 65994f307f981fb9e3e8a9e2a3cb0e46dbd7c46d Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Wed, 10 Aug 2016 12:45:23 +0200 Subject: [PATCH] Make infra_version.js option and fix base image on DO --- baseimage/createDOImage | 2 +- baseimage/createEC2Image | 2 +- baseimage/initializeBaseUbuntuImage.sh | 21 +++++++++++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/baseimage/createDOImage b/baseimage/createDOImage index 2746afdb9..9d427aead 100755 --- a/baseimage/createDOImage +++ b/baseimage/createDOImage @@ -138,7 +138,7 @@ cd "${SOURCE_DIR}" git archive --format=tar HEAD | $ssh22 "root@${server_ip}" "cat - > /tmp/box.tar.gz" echo "Executing init script" -if ! $ssh22 "root@${server_ip}" "/bin/bash /root/initializeBaseUbuntuImage.sh ${installer_revision}"; then +if ! $ssh22 "root@${server_ip}" "/bin/bash /root/initializeBaseUbuntuImage.sh ${installer_revision} caas"; then echo "Init script failed" exit 1 fi diff --git a/baseimage/createEC2Image b/baseimage/createEC2Image index 0799f770c..4ee4fbb30 100755 --- a/baseimage/createEC2Image +++ b/baseimage/createEC2Image @@ -106,7 +106,7 @@ if ! $ssh22 "ubuntu@${server_ip}" "sudo sed -e 's/.* \(ssh-rsa.*\)/\1/' -i /root fi echo "Executing init script" -if ! $ssh22 "root@${server_ip}" "/bin/bash /home/ubuntu/initializeBaseUbuntuImage.sh ${installer_revision}"; then +if ! $ssh22 "root@${server_ip}" "/bin/bash /home/ubuntu/initializeBaseUbuntuImage.sh ${installer_revision} ec2"; then echo "Init script failed" echo "Make sure to cleanup the ec2 instance ${instance_id}" exit 1 diff --git a/baseimage/initializeBaseUbuntuImage.sh b/baseimage/initializeBaseUbuntuImage.sh index 914c7c3d1..c2b2d2f5c 100644 --- a/baseimage/initializeBaseUbuntuImage.sh +++ b/baseimage/initializeBaseUbuntuImage.sh @@ -6,6 +6,7 @@ readonly USER=yellowtent readonly USER_HOME="/home/${USER}" readonly INSTALLER_SOURCE_DIR="${USER_HOME}/installer" readonly INSTALLER_REVISION="$1" +readonly PROVIDER="$2" readonly USER_DATA_FILE="/root/user_data.img" readonly USER_DATA_DIR="/home/yellowtent/data" @@ -133,7 +134,11 @@ iptables -I FORWARD -d 169.254.169.254 -j DROP mkdir /etc/iptables && iptables-save > /etc/iptables/rules.v4 echo "=== Enable memory accounting ==" -sed -e 's/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1 panic_on_oops=1 panic=5"/' -i /etc/default/grub +if [[ "${PROVIDER}" == "digitalocean" ]] || [[ "${PROVIDER}" == "caas" ]]; then + sed -e 's/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX="console=tty1 root=LABEL=DOROOT notsc clocksource=kvm-clock net.ifnames=0 cgroup_enable=memory swapaccount=1 panic_on_oops=1 panic=5"/' -i /etc/default/grub +else + sed -e 's/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1 panic_on_oops=1 panic=5"/' -i /etc/default/grub +fi update-grub # now add the user to the docker group @@ -149,12 +154,16 @@ apt-get install -y python # Install python which is required for npm rebuild [[ "$(python --version 2>&1)" == "Python 2.7."* ]] || die "Expecting python version to be 2.7.x" echo "==== Downloading docker images ====" -images=$(node -e "var i = require('${SOURCE_DIR}/infra_version.js'); console.log(i.baseImage, Object.keys(i.images).map(function (x) { return i.images[x].tag; }).join(' '));") +if [ -f ${SOURCE_DIR}/infra_version.js ]; then + images=$(node -e "var i = require('${SOURCE_DIR}/infra_version.js'); console.log(i.baseImage, Object.keys(i.images).map(function (x) { return i.images[x].tag; }).join(' '));") -echo "Pulling images: ${images}" -for image in ${images}; do - docker pull "${image}" -done + echo "Pulling images: ${images}" + for image in ${images}; do + docker pull "${image}" + done +else + echo "No infra_versions.js found, skipping image download" +fi echo "==== Install nginx ====" apt-get -y install nginx-full