Last active
October 22, 2018 13:48
-
-
Save mindesik/072e118df39617afb640b2dd58fa88bb to your computer and use it in GitHub Desktop.
Install latest node.js and yarn on Ubuntu
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 | |
ND_VERSION=8.12.0 | |
ND_FILE=node-v$ND_VERSION-linux-x64.tar.gz | |
function download { | |
wget https://nodejs.org/dist/v$ND_VERSION/$ND_FILE && sudo tar -C /usr/local --strip-components 1 -xzf $ND_FILE && rm $ND_FILE | |
} | |
PS3='Please choose platform: ' | |
options=("Ubuntu/Debian" "CentOS" "ARMv6" "Quit") | |
select opt in "${options[@]}" | |
do | |
case $opt in | |
"Ubuntu/Debian") | |
download | |
sudo curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - | |
sudo echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list | |
sudo apt update | |
sudo apt install --no-install-recommends yarn -y | |
break | |
;; | |
"CentOS") | |
yum install wget -y && | |
download && | |
sudo curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo && | |
sudo curl --silent --location https://rpm.nodesource.com/setup_6.x | bash - && | |
sudo yum install yarn -y | |
break | |
;; | |
"ARMv6") | |
ND_FILE=node-v$ND_VERSION-linux-armv6l.tar.gz | |
download | |
sudo curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - | |
sudo echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list | |
sudo apt update | |
sudo apt install --no-install-recommends yarn -y | |
break | |
;; | |
"ARMv7") | |
ND_FILE=node-v$ND_VERSION-linux-armv7l.tar.gz | |
download | |
sudo curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - | |
sudo echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list | |
sudo apt update | |
sudo apt install --no-install-recommends yarn -y | |
break | |
;; | |
"Quit") | |
break | |
;; | |
*) echo Invalid option;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment