#!/bin/sh
if ![ $1 ]; then
        echo "Must specify a full version number"
	exit 1
fi

nodeversion="$1"

echo "Installing node.js version $nodeversion 64-bit for Linux..."
wget https://nodejs.org/dist/v$nodeversion/node-v$nodeversion-linux-x64.tar.gz
tar -xzf node-v$nodeversion-linux-x64.tar.gz
rm node-v$nodeversion-linux-x64.tar.gz

echo "Copying node runtime to /usr/local..."
cp -P node-v$nodeversion-linux-x64/bin/node /usr/local/bin
rm -rf node-v$nodeversion-linux-x64

echo "Running npm installer..."
wget -qO- https://www.npmjs.com/install.sh | bash
