Created
April 4, 2017 18:05
-
-
Save dbehnke/6d6303d9e4feb197c60125864c266734 to your computer and use it in GitHub Desktop.
Get the latest nodejs/npm binaries and extract and create activate script (Linux 64bit)
This file contains hidden or 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 | |
getversion() { | |
curl https://nodejs.org/en/ -o index.html | |
export version=$(cat index.html | grep Current | tail -n 1 | awk -F' v' '{ print $2 }' | awk -F' Current' '{ print $1 }') | |
} | |
cleandownload() { | |
rm index.html | |
rm node.tar.xz | |
} | |
install() { | |
getversion | |
echo $version | |
curl -o node.tar.xz https://nodejs.org/dist/v${version}/node-v${version}-linux-x64.tar.xz | |
tar xvfJ node.tar.xz | |
nodedir=node-v${version}-linux-x64 | |
rm -r -f node | |
ln -s ${nodedir} node | |
cat > activate-nodejs.sh <<EOF | |
#!/bin/bash | |
export OLDPATH=$PATH | |
deactivate() { | |
export PATH=$OLDPATH | |
unset OLDPATH | |
} | |
export OLDPATH=$PATH | |
export PATH=$PWD/node/bin:$PATH | |
EOF | |
chmod +x activate-nodejs.sh | |
} | |
install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment