#!/bin/bash -eu
#
# Revision: 2015-04-01
#
# Additional provisioning for integration slaves running Ubuntu Trusty.
# This assumes "role::ci::slave::labs" is already enabled and applied.
#
err() {
echo $1
exit 1
}
# Assert: Node version
node_version=$(node --version)
if [[ "$node_version" != "v0.10.25" ]]; then
err "Error: Unexpected Node $node_version"
fi
# Patch: Upgrade outdated npm that ships with Ubuntu
npm_version=$(npm --version)
if [[ "$npm_version" != "2.4.1" ]]; then
if [[ "$npm_version" != "1.3.10" ]]; then
err "Error: Unexpected npm $npm_version"
fi
npm_bin=$(which npm)
if [[ "$npm_bin" != "/usr/bin/npm" ]]; then
err "Error: Unexpected npm path: $npm_bin"
fi
test -L "$npm_bin" || err "Error: No symlink at $npm_bin"
npm_full_bin=$(readlink -f "$npm_bin")
test -f "$npm_full_bin" || err "Error: No file at $npm_full_bin"
sudo rm "$npm_bin"
sudo $npm_full_bin install -g npm@2.4.1
npm_version=$(npm --version)
if [[ "$npm_version" != "2.4.1" ]]; then
err "Error: Failed to upgrade npm"
fi
fi
# Patch: Ensure grunt-cli is installed
sudo npm install -g grunt-cli@0.1.13
grunt_version=$(grunt --version)
if [[ "$grunt_version" != "grunt-cli v0.1.13" ]]; then
err "Error: Unexpected Grunt $grunt_version"
fi