Created
February 18, 2014 13:29
-
-
Save ptitfred/9070988 to your computer and use it in GitHub Desktop.
NodeJS installer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
NODE_ARCHIVE_REPOSITORY=http://nodejs.org/dist/latest/ | |
# Move to a temp directory | |
BUILD_DIR=$(mktemp -t -d "nodejs-installer.XXXXX") | |
cd $BUILD_DIR | |
archive=$(curl "${NODE_ARCHIVE_REPOSITORY}SHASUMS.txt" 2>/dev/null | egrep "node-v[0-9.]*.tar.gz" | cut -f3 -d" ") | |
download_archive="$NODE_ARCHIVE_REPOSITORY$archive" | |
directory=${archive%.tar.gz} | |
version=${directory#node-} | |
installed_version=$(node --version) | |
if [ $installed_version = $version ]; then | |
echo "${version} already installed, aborting..." | |
exit 1 | |
else | |
echo "Installed: ${installed_version}" | |
echo "Lastest: ${version}" | |
echo "" | |
echo "About to installing new version..." | |
fi | |
# Require root privilegies right now to have it at install (final step) | |
sudo ls > /dev/null | |
echo "Downloading" | |
wget "$download_archive" | |
tar -zxf $archive | |
echo "Start building node $version" | |
cd $directory | |
./configure | |
make | |
sudo make install | |
echo "$directory successfully installed" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment