Last active
August 29, 2015 14:15
-
-
Save NanoAi/051188b0d61ce01cf53e to your computer and use it in GitHub Desktop.
Shell script for installing NodeJS
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
echo "Hello, we will now install NodeJS & NPM." | |
read -p "Would you like to remove an old install first? (Y/n) " -n 1 -r && echo "" | |
if [[ $REPLY =~ ^[Yy]$ || ! $REPLY ]] | |
then | |
sudo apt-get remove nodejs | |
sudo apt-get remove npm | |
sudo apt-get autoremove | |
echo "" | |
fi | |
echo "Outputing held packages, if you have anything here then please abort, and clean." | |
dpkg --get-selections | grep hold | |
apt-mark showhold | |
echo "" | |
echo "----------------" && echo "If you see anything above this line please abort, and clean." | |
read -p "Continue? (Y/n) " -n 1 -r && echo "" | |
if [[ $REPLY =~ ^[Nn]$ && $REPLY ]] | |
then | |
echo "" | |
exit | |
fi | |
sudo apt-get clean | |
curl -sL https://deb.nodesource.com/setup | sudo bash - | |
echo "----------------" && echo "If the above failed, please abort." | |
read -p "Continue? (Y/n) " -n 1 -r && echo "" | |
if [[ $REPLY =~ ^[Nn]$ && $REPLY ]] | |
then | |
echo "" | |
exit | |
fi | |
sudo apt-get install nodejs | |
sudo apt-get install build-essential | |
sudo apt-get install npm | |
echo "" && echo "Getting the latest version of NPM." | |
npm install -g npm | |
sleep 2 | |
sudo apt-get clean | |
npm install -g bower | |
npm install -g grunt-cli | |
read -p "Auto append --allow-root to bower? ( This will make changes to ~/.bashrc ) (Y/n) " -n 1 -r && echo "" | |
if [[ $REPLY =~ ^[Yy]$ || ! $REPLY ]] | |
then | |
echo '' | |
echo '' >> ~/.bashrc | |
echo "# Added by Node & NPM Install Script. (Please delete any repeates.)" >> ~/.bashrc | |
echo 'function bower { command bower "$@" --allow-root; }' >> ~/.bashrc | |
. ~/.bashrc | |
echo "" && echo "Please review the following changes to your .bashrc" | |
cat ~/.bashrc && echo "" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment