Last active
December 19, 2015 02:38
-
-
Save alex-alex2006hw/d2a94a53c62fa29afd2f to your computer and use it in GitHub Desktop.
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 | |
# | |
# modified from : https://github.com/taaem/nodejs-linux-installer/releases/download/v0.3/node-install.sh | |
# | |
echo "-------------- RUN -------------------" | |
echo " curl https://gist.githubusercontent.com/alex-alex2006hw/d2a94a53c62fa29afd2f/raw/7a49799320508a1b75c885ac088a4a754e9352d3/nodejs-install.sh | /bin/bash" | |
echo "--------------------------------------" | |
echo "Node Linux Installer by www.github.com/taaem modified by www.github.com/alex2006hw" | |
echo "Need Root for installing NodeJS" | |
sudo sh -c 'echo "Root access Verified."' | |
CVER="$(ls -l /usr/local| grep 'node' | grep -v nodejs | awk '{ print $9 }').tar.gz" | |
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 | |
if [ $CVER == $VER ] | |
then | |
echo "Current installed is latest version : $VER" | |
exit 1 | |
fi | |
echo "Removing other versions of nodejs" | |
sudo sh -c "(/bin/rm -rf /usr/local/node*)" | |
echo "Installing latest version: $VER" | |
DIR=$( cd /tmp && pwd ) | |
echo "Downloading latest stable Version $VER..." | |
{ | |
wget https://nodejs.org/dist/latest/$VER -O $DIR/$VER | |
} &> /dev/null | |
echo "Installing $VER to /usr/local/$VER" | |
cd /usr/local && sudo tar -xzf $DIR/$VER | |
sudo sh -c "(cd /usr/local;chown -R root: node*;ln -s /usr/local/node* /usr/local/nodejs)" | |
rm $DIR/$VER | |
echo "Finished installing!" | |
echo "make sure you added this to ~/.profile : export PATH=/usr/local/nodejs/bin:$PATH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment