Skip to content

Instantly share code, notes, and snippets.

@rnwilson
Created April 25, 2018 03:01
Show Gist options
  • Save rnwilson/090aebb33a01639cad2ec02165f3f163 to your computer and use it in GitHub Desktop.
Save rnwilson/090aebb33a01639cad2ec02165f3f163 to your computer and use it in GitHub Desktop.
nodejs-linux-installer
#!/bin/bash
echo "Node Linux Installer by www.github.com/taaem"
echo "Need Root for installing NodeJS"
sudo sh -c 'echo "Got Root!"'
echo "Get Latest Version Number..."
{
wget --output-document=node-updater.html https://nodejs.org/dist/latest/
ARCH=$(uname -m)
if [ $ARCH = x86_64 ]
then
grep -o '>node-v.*-linux-x64.tar.gz' node-updater.html > node-cache.txt 2>&1
VER=$(grep -o 'node-v.*-linux-x64.tar.gz' node-cache.txt)
else
grep -o '>node-v.*-linux-x86.tar.gz' node-updater.html > node-cache.txt 2>&1
VER=$(grep -o 'node-v.*-linux-x86.tar.gz' node-cache.txt)
fi
rm ./node-cache.txt
rm ./node-updater.html
} &> /dev/null
echo "Done"
DIR=$( cd "$( dirname $0 )" && pwd )
echo "Downloading latest stable Version $VER..."
{
wget https://nodejs.org/dist/latest/$VER -O $DIR/$VER
} &> /dev/null
echo "Done"
echo "Installing..."
cd /usr/local && sudo tar --strip-components 1 -xzf $DIR/$VER
rm $DIR/$VER
echo "Finished installing!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment