Skip to content

Instantly share code, notes, and snippets.

@SebastienElet
Created July 9, 2013 15:39
Show Gist options
  • Save SebastienElet/5958393 to your computer and use it in GitHub Desktop.
Save SebastienElet/5958393 to your computer and use it in GitHub Desktop.
Node installer
#!/bin/sh
apt-get install -y curl
CURRENT=$(node -v)
VERSION=$(curl -L -s http://nodejs.org/dist/latest/ \
| egrep -o '[0-9]+\.[0-9]+\.[0-9]+' \
| tail -n1)
PLATFORM=linux
ARCH=x64
PREFIX="/usr/local/"
if test "v$VERSION" != "$CURRENT"; then
echo "Installing node v$VERSION ..."
mkdir -p "$PREFIX" && \
curl -# -L http://nodejs.org/dist/v$VERSION/node-v$VERSION-$PLATFORM-$ARCH.tar.gz \
| tar xzvf - --strip-components=1 -C "$PREFIX"
else
echo "Latest stable version of node already installed."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment