From 9c3c5c1e319ed1fbda12d210dd88870941d02e1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20G=C3=B6hler?= Date: Wed, 26 Oct 2016 16:33:40 +0200 Subject: [PATCH] Vagrantfile improvement (apt-get) (#8762) * use privileged provisioner to simplify setup script * fix 'not a tty' error when running privileged shell * run apt-get non-interactively do not install suggested/recommended packages suppress verbose output on stdout * beautifying shell code and output * fixed exidently overwritten .bashrc --- Vagrantfile | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 88958c5fc..fb4f5cb6f 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -10,47 +10,54 @@ SRCROOT="/opt/go" SRCPATH="/opt/gopath" # Get the ARCH -ARCH=`uname -m | sed 's|i686|386|' | sed 's|x86_64|amd64|'` +ARCH="$(uname -m | sed 's|i686|386|' | sed 's|x86_64|amd64|')" # Install Prereq Packages -sudo apt-get update -sudo apt-get upgrade -y -sudo apt-get install -y build-essential curl git-core libpcre3-dev mercurial pkg-config zip +export DEBIAN_PRIORITY=critical +export DEBIAN_FRONTEND=noninteractive +export DEBCONF_NONINTERACTIVE_SEEN=true +APT_OPTS="--yes --force-yes --no-install-suggests --no-install-recommends" +echo "Upgrading packages ..." +apt-get update ${APT_OPTS} >/dev/null +apt-get upgrade ${APT_OPTS} >/dev/null +echo "Installing prerequisites ..." +apt-get install ${APT_OPTS} build-essential curl git-core libpcre3-dev mercurial pkg-config zip >/dev/null # Install Go -cd /tmp -wget --quiet https://storage.googleapis.com/golang/go${GOVERSION}.linux-${ARCH}.tar.gz -tar -xvf go${GOVERSION}.linux-${ARCH}.tar.gz -sudo mv go $SRCROOT -sudo chmod 775 $SRCROOT -sudo chown vagrant:vagrant $SRCROOT +echo "Downloading go (${GOVERSION}) ..." +wget -P /tmp --quiet "https://storage.googleapis.com/golang/go${GOVERSION}.linux-${ARCH}.tar.gz" +echo "Setting up go (${GOVERSION}) ..." +tar -C /opt -xf "/tmp/go${GOVERSION}.linux-${ARCH}.tar.gz" +chmod 775 "$SRCROOT" +chown vagrant:vagrant "$SRCROOT" # Setup the GOPATH; even though the shared folder spec gives the working # directory the right user/group, we need to set it properly on the # parent path to allow subsequent "go get" commands to work. -sudo mkdir -p $SRCPATH -sudo chown -R vagrant:vagrant $SRCPATH 2>/dev/null || true +mkdir -p "$SRCPATH" +chown -R vagrant:vagrant "$SRCPATH" 2>/dev/null || true # ^^ silencing errors here because we expect this to fail for the shared folder -cat </tmp/gopath.sh +install -m0755 /dev/stdin /etc/profile.d/gopath.sh <>~/.bashrc + +cat >>/home/vagrant/.bashrc <