Merge branch 'iojs'
This commit is contained in:
commit
863a949524
82
README.md
82
README.md
|
@ -1,39 +1,89 @@
|
||||||
node-install-script
|
# Automated node.js installers for OS X and Ubuntu
|
||||||
===================
|
|
||||||
|
|
||||||
A script to install basic development tools for node (git, node, gcc, etc)
|
A script to install basic development tools for node.js - git, node, gcc, pkg-config, etc
|
||||||
|
|
||||||
Works for any recent version of Ubuntu or OS X.
|
Pick one:
|
||||||
|
|
||||||
|
* [OS X](#apple-os-x)
|
||||||
|
* [Ubuntu Linux](#ubuntu-linux)
|
||||||
|
* [TL;DR](#tldr)
|
||||||
|
* [Important Notes](#other-things-you-should-know)
|
||||||
|
|
||||||
|
## Screencast
|
||||||
|
|
||||||
|
[How to Setup a VPS for node.js Development](https://www.youtube.com/watch?v=ypjzi1axH2A) - [(3:06 installing node.js](https://www.youtube.com/watch?v=ypjzi1axH2A#t=186))
|
||||||
|
|
||||||
|
## TL;DR
|
||||||
|
|
||||||
|
If you kinda know what you're doing already:
|
||||||
|
|
||||||
|
**node.js + dev tools**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Specify the version of node to install
|
echo "Current node.js version is $(curl -fsSL https://nodejs.org/dist/index.tab | head -2 | tail -1 | cut -f 1)"
|
||||||
echo "v0.11.14" > /tmp/NODE_VER
|
curl -fsSL bit.ly/iojs-dev -o /tmp/iojs-dev.sh; bash /tmp/iojs-dev.sh
|
||||||
|
|
||||||
# And install away!
|
|
||||||
curl -fsSL bit.ly/easy-install-node | bash
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**For older versions of Ubuntu**:
|
**node.js only** (no git, gcc, etc)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
wget -nv bit.ly/easy-install-node -O - | bash
|
# To install a specific version rather than defaulting to latest
|
||||||
|
# latest version at time of writing are v1.8.4, v2.5.0, and v3.1.0
|
||||||
|
echo "v2.5.0" > /tmp/IOJS_VER
|
||||||
|
|
||||||
|
# node.js without development dependencies
|
||||||
|
curl -fsSL bit.ly/iojs-min | bash
|
||||||
|
|
||||||
|
# Ubuntu without curl
|
||||||
|
wget -nv bit.ly/iojs-min -O - | bash
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Apple OS X
|
||||||
|
|
||||||
|
First you need to **Install XCode Command Line Tools**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
xcode-select --install
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you need to **Accept the XCode License** by running any command installed by Xcode with sudo. We'll use git.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo git --version
|
||||||
|
```
|
||||||
|
|
||||||
|
You can scroll to the bottom by hitting shift+G (capital G).
|
||||||
|
|
||||||
|
Type `agree` and hit enter to accept the license.
|
||||||
|
|
||||||
|
Now you can install node.js
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -fsSL bit.ly/iojs-dev -o /tmp/iojs-dev.sh; bash /tmp/iojs-dev.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
*TODO*: Make it easier to accepting the license (automatic?)
|
||||||
|
|
||||||
|
## Ubuntu Linux
|
||||||
|
|
||||||
|
```bash
|
||||||
|
wget -nv bit.ly/iojs-dev -O /tmp/iojs-dev.sh; bash /tmp/iojs-dev.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## Other things you should know
|
||||||
|
|
||||||
This is what gets installed:
|
This is what gets installed:
|
||||||
|
|
||||||
* fail2ban (not necessary for development, but should be on every server)
|
|
||||||
* rsync
|
* rsync
|
||||||
* curl
|
* curl
|
||||||
* wget
|
* wget
|
||||||
* git
|
* git
|
||||||
* xcode / brew / build-essential / pkg-config / gcc
|
* xcode / brew / build-essential / pkg-config / gcc
|
||||||
* node
|
* node (including npm)
|
||||||
* jshint
|
* jshint
|
||||||
|
|
||||||
Screencast
|
**NOTE**: If `fail2ban` is not already securing ssh, you will be asked to install it.
|
||||||
==========
|
|
||||||
|
|
||||||
[How to Setup a VPS for Node.js Development](https://www.youtube.com/watch?v=ypjzi1axH2A) - [(3:06 installing node](https://www.youtube.com/watch?v=ypjzi1axH2A#t=186))
|
|
||||||
|
|
||||||
Front-End Extras
|
Front-End Extras
|
||||||
================
|
================
|
||||||
|
|
|
@ -1,10 +1,19 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# curl -fsSL https://ldsconnect.org/setup-osx.bash | bash -c
|
# curl -fsSL https://ldsconnect.org/setup-osx.bash | bash -c
|
||||||
NODE_VER=${1}
|
NO_FAIL2BAN=${1}
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo ""
|
echo ""
|
||||||
|
echo "Checking for"
|
||||||
|
echo ""
|
||||||
|
echo " * XCode Command Line Tools"
|
||||||
|
echo " * wget"
|
||||||
|
echo " * pkg-config"
|
||||||
|
echo " * node"
|
||||||
|
echo " * iojs"
|
||||||
|
echo " * jshint"
|
||||||
|
echo ""
|
||||||
|
|
||||||
# XCode
|
# XCode
|
||||||
# testing for which git, gcc, etc will not work because the tools are aliased to the install script
|
# testing for which git, gcc, etc will not work because the tools are aliased to the install script
|
||||||
|
@ -31,8 +40,6 @@ if [ -z "$(xcode-select --print-path 2>/dev/null)" ] || [ -z "$(git --version 2>
|
||||||
echo "It looks like the other install is finishing up."
|
echo "It looks like the other install is finishing up."
|
||||||
echo "This installation will begin in one minute."
|
echo "This installation will begin in one minute."
|
||||||
sleep 60
|
sleep 60
|
||||||
else
|
|
||||||
echo "XCode Command Line Tools already installed"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# homebrew
|
# homebrew
|
||||||
|
@ -48,46 +55,18 @@ fi
|
||||||
if [ -z "$(which wget | grep wget)" ]; then
|
if [ -z "$(which wget | grep wget)" ]; then
|
||||||
echo "installing wget..."
|
echo "installing wget..."
|
||||||
brew install wget
|
brew install wget
|
||||||
else
|
|
||||||
echo "wget already installed"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# http://www.fail2ban.org/wiki/index.php/HOWTO_Mac_OS_X_Server_(10.5)
|
# http://www.fail2ban.org/wiki/index.php/HOWTO_Mac_OS_X_Server_(10.5)
|
||||||
if [ -z "$(which fail2ban-server | grep fail2ban)" ]; then
|
if [ -z "$(which fail2ban-server | grep fail2ban)" ]; then
|
||||||
echo "installing fail2ban..."
|
if [ -z "${NO_FAIL2BAN}" ]; then
|
||||||
brew install fail2ban
|
brew install fail2ban
|
||||||
sudo cp -fv /usr/local/opt/fail2ban/*.plist /Library/LaunchDaemons
|
sudo cp -fv /usr/local/opt/fail2ban/*.plist /Library/LaunchDaemons
|
||||||
sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.fail2ban.plist
|
sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.fail2ban.plist
|
||||||
else
|
fi
|
||||||
echo "fail2ban already installed"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$(which pkg-config | grep pkg-config)" ]; then
|
if [ -z "$(which pkg-config | grep pkg-config)" ]; then
|
||||||
echo "installing pkg-config..."
|
echo "installing pkg-config..."
|
||||||
brew install pkg-config
|
brew install pkg-config
|
||||||
else
|
|
||||||
echo "pkg-config already installed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# node
|
|
||||||
if [ -n "$(which node | grep node 2>/dev/null)" ]; then
|
|
||||||
NODE_VER=""
|
|
||||||
|
|
||||||
if [ "${NODE_VER}" == "$(node -v 2>/dev/null)" ]; then
|
|
||||||
echo node ${NODE_VER} already installed
|
|
||||||
else
|
|
||||||
echo ""
|
|
||||||
echo "HEY, LISTEN:"
|
|
||||||
echo "node is already installed as $(node -v | grep v)"
|
|
||||||
echo ""
|
|
||||||
echo "to reinstall please first run: rm $(which node)"
|
|
||||||
echo ""
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${NODE_VER}" ]; then
|
|
||||||
echo "installing node ${NODE_VER}..."
|
|
||||||
curl -fsSL "http://nodejs.org/dist/${NODE_VER}/node-${NODE_VER}.pkg" -o "/tmp/node-${NODE_VER}.pkg"
|
|
||||||
sudo /usr/sbin/installer -pkg "/tmp/node-${NODE_VER}.pkg" -target /
|
|
||||||
sudo chown -R $(whoami) /usr/local 2>/dev/null
|
|
||||||
fi
|
fi
|
|
@ -0,0 +1,37 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# curl -fsSL https://ldsconnect.org/setup-linux.bash | bash -c
|
||||||
|
|
||||||
|
NO_FAIL2BAN=${1}
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "Checking for"
|
||||||
|
echo ""
|
||||||
|
echo " * build-essential"
|
||||||
|
echo " * rsync"
|
||||||
|
echo " * wget"
|
||||||
|
echo " * curl"
|
||||||
|
echo " * pkg-config"
|
||||||
|
echo " * node"
|
||||||
|
echo " * iojs"
|
||||||
|
echo " * jshint"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
echo "updating apt-get..."
|
||||||
|
sudo bash -c "apt-get update -qq -y < /dev/null" > /dev/null
|
||||||
|
|
||||||
|
# fail2ban
|
||||||
|
if [ -z "$(which fail2ban-server | grep fail2ban)" ]; then
|
||||||
|
if [ -z "${NO_FAIL2BAN}" ]; then
|
||||||
|
echo "installing fail2ban..."
|
||||||
|
sudo bash -c "apt-get install -qq -y fail2ban < /dev/null" > /dev/null
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# git, wget, curl, build-essential
|
||||||
|
if [ -z "$(which pkg-config | grep pkg-config)" ] || [ -z "$(which git | grep git)" ] || [ -z "$(which wget | grep wget)" ] || [ -z "$(which curl | grep curl)" ] || [ -z "$(which gcc | grep gcc)" ] || [ -z "$(which rsync | grep rsync)" ]
|
||||||
|
then
|
||||||
|
echo "installing git, wget, curl, build-essential, rsync, pkg-config..."
|
||||||
|
sudo bash -c "apt-get install -qq -y git wget curl build-essential rsync pkg-config < /dev/null" > /dev/null 2>/dev/null
|
||||||
|
fi
|
|
@ -0,0 +1,226 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Installs node.js only (no development dependencies) for both Ubuntu and OS X
|
||||||
|
|
||||||
|
#
|
||||||
|
# See https://github.com/coolaj86/node-install-script
|
||||||
|
#
|
||||||
|
|
||||||
|
# curl -fsSL bit.ly/nodejs-min | bash
|
||||||
|
# wget -nv bit.ly/nodejs-min -O - | bash
|
||||||
|
|
||||||
|
# curl -fsSL https://example.com/setup-min.bash | bash
|
||||||
|
# wget -nv https://example.com/setup-min.bash -O - | bash
|
||||||
|
|
||||||
|
NODEJS_NAME="node"
|
||||||
|
NODEJS_BASE_URL="https://nodejs.org"
|
||||||
|
BASE_URL="https://raw.githubusercontent.com/coolaj86/iojs-install-script/master"
|
||||||
|
OS="unsupported"
|
||||||
|
ARCH=""
|
||||||
|
NODEJS_VER=""
|
||||||
|
SETUP_FILE=""
|
||||||
|
|
||||||
|
clear
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# Which OS and version? #
|
||||||
|
#########################
|
||||||
|
|
||||||
|
if [ "$(uname | grep -i 'Darwin')" ]; then
|
||||||
|
OSX_VER="$(sw_vers | grep ProductVersion | cut -d':' -f2 | cut -f2)"
|
||||||
|
OSX_MAJOR="$(echo ${OSX_VER} | cut -d'.' -f1)"
|
||||||
|
OSX_MINOR="$(echo ${OSX_VER} | cut -d'.' -f2)"
|
||||||
|
OSX_PATCH="$(echo ${OSX_VER} | cut -d'.' -f3)"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Major
|
||||||
|
#
|
||||||
|
if [ "$OSX_MAJOR" -lt 10 ]; then
|
||||||
|
echo "unsupported OS X version (os 9-)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$OSX_MAJOR" -gt 10 ]; then
|
||||||
|
echo "unsupported OS X version (os 11+)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Minor
|
||||||
|
#
|
||||||
|
if [ "$OSX_MINOR" -le 5 ]; then
|
||||||
|
echo "unsupported OS X version (os 10.5-)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Snow
|
||||||
|
if [ "$OSX_MINOR" -eq 6 ]; then
|
||||||
|
OS='snow'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Lion
|
||||||
|
if [ $OSX_MINOR -eq 7 ]; then
|
||||||
|
OS='lion'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Mountain Lion
|
||||||
|
if [ "$OSX_MINOR" -eq 8 ]; then
|
||||||
|
OS='mountain'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Mavericks, Yosemite
|
||||||
|
if [ "$OSX_MINOR" -ge 9 ]; then
|
||||||
|
OS='mavericks'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$(sysctl hw | grep 64bit | grep ': 1')" ]; then
|
||||||
|
ARCH="64"
|
||||||
|
else
|
||||||
|
ARCH="32"
|
||||||
|
fi
|
||||||
|
elif [ "$(uname | grep -i 'Linux')" ]; then
|
||||||
|
if [ ! -f "/etc/issue" ]; then
|
||||||
|
echo "unsupported linux os"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$(arch | grep 64)" ]; then
|
||||||
|
ARCH="64"
|
||||||
|
else
|
||||||
|
ARCH="32"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$(cat /etc/issue | grep -i 'Ubuntu')" ]; then
|
||||||
|
OS='ubuntu'
|
||||||
|
elif [ "$(cat /etc/issue | grep -i 'Raspbian')" ]; then
|
||||||
|
OS='raspbian'
|
||||||
|
elif [ "$(cat /etc/issue | grep -i 'Fedora')" ]; then
|
||||||
|
OS='fedora'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "unsupported unknown os (non-mac, non-linux)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "${OS}" in
|
||||||
|
fedora)
|
||||||
|
echo "FEDORA not yet supported (feel free to pull request)"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
ubuntu)
|
||||||
|
SETUP_FILE="ubuntu"
|
||||||
|
;;
|
||||||
|
raspbian)
|
||||||
|
SETUP_FILE="ubuntu"
|
||||||
|
;;
|
||||||
|
yosemite)
|
||||||
|
# mavericks
|
||||||
|
SETUP_FILE="mavericks"
|
||||||
|
;;
|
||||||
|
mavericks)
|
||||||
|
SETUP_FILE="mavericks"
|
||||||
|
;;
|
||||||
|
mountain)
|
||||||
|
echo "Mountain Lion not yet supported (feel free to pull request)"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
lion)
|
||||||
|
echo "Lion not yet supported (feel free to pull request)"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
snow)
|
||||||
|
echo "Snow Leopard not yet supported (feel free to pull request)"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "unsupported unknown os ${OS}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# Download installers #
|
||||||
|
#######################
|
||||||
|
|
||||||
|
echo "Preparing to install io.js (and common development dependencies) for ${OS}" "${ARCH}"
|
||||||
|
|
||||||
|
INSTALL_FILE="setup-node-${SETUP_FILE}.bash"
|
||||||
|
if [ ! -e "/tmp/${INSTALL_FILE}" ]
|
||||||
|
then
|
||||||
|
if [ -n "$(which curl)" ]; then
|
||||||
|
curl --silent "${BASE_URL}/${INSTALL_FILE}" \
|
||||||
|
-o "/tmp/${INSTALL_FILE}" || echo 'error downloading os setup script'
|
||||||
|
elif [ -n "$(which wget)" ]; then
|
||||||
|
wget --quiet "${BASE_URL}/${INSTALL_FILE}" \
|
||||||
|
-O "/tmp/${INSTALL_FILE}" || echo 'error downloading os setup script'
|
||||||
|
else
|
||||||
|
echo "Found neither 'curl' nor 'wget'. Can't Continue."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e "/tmp/${INSTALL_FILE}" ]
|
||||||
|
then
|
||||||
|
echo "Error Downloading Install File"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# Which io.js VERSION ? #
|
||||||
|
#########################
|
||||||
|
|
||||||
|
if [ -f "/tmp/NODEJS_VER" ]; then
|
||||||
|
NODEJS_VER=$(cat /tmp/NODEJS_VER | grep v)
|
||||||
|
elif [ -f "/tmp/IOJS_VER" ]; then
|
||||||
|
NODEJS_VER=$(cat /tmp/IOJS_VER | grep v)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$NODEJS_VER" ]; then
|
||||||
|
NODEJS_VERT=$(echo ${NODEJS_VER} | cut -c 2- | cut -d '.' -f1)
|
||||||
|
|
||||||
|
if [ $NODEJS_VERT -ge 1 ] && [ $NODEJS_VERT -lt 4 ]
|
||||||
|
then
|
||||||
|
echo "Selecting io.js instead of node.js for this version (>= 1.0.0 < 4.0.0)"
|
||||||
|
NODEJS_BASE_URL="https://iojs.org"
|
||||||
|
NODEJS_NAME="iojs"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$NODEJS_VER" ]; then
|
||||||
|
if [ -n "$(which curl)" ]; then
|
||||||
|
NODEJS_VER=$(curl -fsSL "$NODEJS_BASE_URL/dist/index.tab" | head -2 | tail -1 | cut -f 1) \
|
||||||
|
|| echo 'error automatically determining current io.js version'
|
||||||
|
elif [ -n "$(which wget)" ]; then
|
||||||
|
NODEJS_VER=$(wget --quiet "$NODEJS_BASE_URL/dist/index.tab" -O - | head -2 | tail -1 | cut -f 1) \
|
||||||
|
|| echo 'error automatically determining current io.js version'
|
||||||
|
else
|
||||||
|
echo "Found neither 'curl' nor 'wget'. Can't Continue."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# node
|
||||||
|
#
|
||||||
|
if [ -n "$(which node | grep node 2>/dev/null)" ]; then
|
||||||
|
# node of some version is already installed
|
||||||
|
if [ "${NODEJS_VER}" == "$(node -v 2>/dev/null)" ]; then
|
||||||
|
echo node ${NODEJS_VER} is already installed
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
echo "HEY, LISTEN:"
|
||||||
|
echo ""
|
||||||
|
echo "node.js is already installed as node $(node -v | grep v)"
|
||||||
|
echo ""
|
||||||
|
echo "to reinstall please first run: rm $(which node)"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
NODEJS_VER=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${NODEJS_VER}" ]; then
|
||||||
|
bash "/tmp/${INSTALL_FILE}" "${NODEJS_VER}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
|
@ -0,0 +1,24 @@
|
||||||
|
NODEJS_VER=${1}
|
||||||
|
NODEJS_VERT=$(echo ${NODEJS_VER} | cut -c 2- | cut -d '.' -f1)
|
||||||
|
|
||||||
|
NODEJS_NAME="node"
|
||||||
|
NODEJS_BASE_URL="https://nodejs.org"
|
||||||
|
|
||||||
|
|
||||||
|
if [ $NODEJS_VERT -ge 1 ] && [ $NODEJS_VERT -lt 4 ]
|
||||||
|
then
|
||||||
|
echo "Selecting io.js instead of node.js for this version (>= 1.0.0 < 4.0.0)"
|
||||||
|
NODEJS_BASE_URL="https://iojs.org"
|
||||||
|
NODEJS_NAME="iojs"
|
||||||
|
fi
|
||||||
|
|
||||||
|
NODEJS_REMOTE="$NODEJS_BASE_URL/dist/${NODEJS_VER}/${NODEJS_NAME}-${NODEJS_VER}.pkg"
|
||||||
|
NODEJS_PKG="/tmp/${NODEJS_NAME}-${NODEJS_VER}.pkg"
|
||||||
|
|
||||||
|
if [ -n "${NODEJS_VER}" ]; then
|
||||||
|
echo "installing ${NODEJS_NAME} as ${NODEJS_NAME} ${NODEJS_VER}..."
|
||||||
|
curl -fsSL "${NODEJS_REMOTE}" -o "${NODEJS_PKG}"
|
||||||
|
sudo /usr/sbin/installer -pkg "${NODEJS_PKG}" -target /
|
||||||
|
|
||||||
|
sudo chown -R $(whoami) /usr/local 2>/dev/null
|
||||||
|
fi
|
|
@ -0,0 +1,47 @@
|
||||||
|
NODEJS_VER=${1}
|
||||||
|
NODEJS_VERT=$(echo ${NODEJS_VER} | cut -c 2- | cut -d '.' -f1)
|
||||||
|
|
||||||
|
NODEJS_NAME="node"
|
||||||
|
NODEJS_BASE_URL="https://nodejs.org"
|
||||||
|
|
||||||
|
if [ $NODEJS_VERT -ge 1 ] && [ $NODEJS_VERT -lt 4 ]
|
||||||
|
then
|
||||||
|
echo "Selecting io.js instead of node.js for this version (>= 1.0.0 < 4.0.0)"
|
||||||
|
NODEJS_BASE_URL="https://iojs.org"
|
||||||
|
NODEJS_NAME="iojs"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$(arch | grep 64)" ]; then
|
||||||
|
ARCH="x64"
|
||||||
|
elif [ -n "$(arch | grep armv7l)" ]; then
|
||||||
|
ARCH="armv7l"
|
||||||
|
elif [ -n "$(arch | grep armv6l)" ]; then
|
||||||
|
ARCH="armv6l"
|
||||||
|
else
|
||||||
|
ARCH="x86"
|
||||||
|
fi
|
||||||
|
|
||||||
|
NODEJS_REMOTE="${NODEJS_BASE_URL}/dist/${NODEJS_VER}/${NODEJS_NAME}-${NODEJS_VER}-linux-${ARCH}.tar.gz"
|
||||||
|
NODEJS_LOCAL="/tmp/${NODEJS_NAME}-${NODEJS_VER}-linux-${ARCH}.tar.gz"
|
||||||
|
NODEJS_UNTAR="/tmp/${NODEJS_NAME}-${NODEJS_VER}-linux-${ARCH}"
|
||||||
|
|
||||||
|
if [ -n "${NODEJS_VER}" ]; then
|
||||||
|
echo "installing ${NODEJS_NAME} as ${NODEJS_NAME} ${NODEJS_VER}..."
|
||||||
|
|
||||||
|
if [ -n "$(which curl 2>/dev/null)" ]; then
|
||||||
|
curl -fsSL ${NODEJS_REMOTE} -o ${NODEJS_LOCAL} || echo 'error downloading ${NODEJS_NAME}'
|
||||||
|
elif [ -n "$(which wget 2>/dev/null)" ]; then
|
||||||
|
wget --quiet ${NODEJS_REMOTE} -O ${NODEJS_LOCAL} || echo 'error downloading ${NODEJS_NAME}'
|
||||||
|
else
|
||||||
|
echo "'wget' and 'curl' are missing. Please run the following command and try again"
|
||||||
|
echo "\tsudo apt-get install --yes curl wget"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
tar xf ${NODEJS_LOCAL} -C /tmp/
|
||||||
|
rm ${NODEJS_UNTAR}/{LICENSE,CHANGELOG.md,README.md}
|
||||||
|
sudo rsync -a "${NODEJS_UNTAR}/" /usr/local/
|
||||||
|
|
||||||
|
|
||||||
|
sudo chown -R $(whoami) /usr/local
|
||||||
|
fi
|
|
@ -1,56 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# curl -fsSL https://ldsconnect.org/setup-linux.bash | bash -c
|
|
||||||
|
|
||||||
NODE_VER=${1}
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
echo "updating apt-get..."
|
|
||||||
sudo bash -c "apt-get update -qq -y < /dev/null" > /dev/null
|
|
||||||
|
|
||||||
# fail2ban
|
|
||||||
if [ -z "$(which fail2ban-server | grep fail2ban)" ]; then
|
|
||||||
echo "installing fail2ban..."
|
|
||||||
sudo bash -c "apt-get install -qq -y fail2ban < /dev/null" > /dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
# git, wget, curl, build-essential
|
|
||||||
if [ -z "$(which pkg-config | grep pkg-config)" ] || [ -z "$(which git | grep git)" ] || [ -z "$(which wget | grep wget)" ] || [ -z "$(which curl | grep curl)" ] || [ -z "$(which gcc | grep gcc)" ] || [ -z "$(which rsync | grep rsync)" ]
|
|
||||||
then
|
|
||||||
echo "installing git, wget, curl, build-essential, rsync, pkg-config..."
|
|
||||||
sudo bash -c "apt-get install -qq -y git wget curl build-essential rsync pkg-config < /dev/null" > /dev/null 2>/dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
# node
|
|
||||||
if [ -n "$(which node | grep node 2>/dev/null)" ]; then
|
|
||||||
NODE_VER=""
|
|
||||||
|
|
||||||
if [ "${NODE_VER}" == "$(node -v 2>/dev/null)" ]; then
|
|
||||||
echo node ${NODE_VER} already installed
|
|
||||||
else
|
|
||||||
echo ""
|
|
||||||
echo "HEY, LISTEN:"
|
|
||||||
echo "node is already installed as $(node -v | grep v)"
|
|
||||||
echo ""
|
|
||||||
echo "to reinstall please first run: rm $(which node)"
|
|
||||||
echo ""
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${NODE_VER}" ]; then
|
|
||||||
if [ -n "$(arch | grep 64)" ]; then
|
|
||||||
ARCH="x64"
|
|
||||||
else
|
|
||||||
ARCH="x86"
|
|
||||||
fi
|
|
||||||
echo "installing node ${NODE_VER}..."
|
|
||||||
curl -fsSL "http://nodejs.org/dist/${NODE_VER}/node-${NODE_VER}-linux-${ARCH}.tar.gz" \
|
|
||||||
-o "/tmp/node-${NODE_VER}-linux-${ARCH}.tar.gz"
|
|
||||||
pushd /tmp
|
|
||||||
tar xf /tmp/node-${NODE_VER}-linux-${ARCH}.tar.gz
|
|
||||||
rm node-${NODE_VER}-linux-x64/{LICENSE,ChangeLog,README.md}
|
|
||||||
sudo rsync -a "/tmp/node-${NODE_VER}-linux-${ARCH}/" /usr/local/
|
|
||||||
sudo chown -R $(whoami) /usr/local
|
|
||||||
fi
|
|
206
setup.bash
206
setup.bash
|
@ -1,27 +1,30 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Installs node.js + dependencies for both Ubuntu and OS X
|
||||||
|
|
||||||
|
#
|
||||||
|
# See https://github.com/coolaj86/node-install-script
|
||||||
|
#
|
||||||
|
|
||||||
# curl -fsSL https://example.com/setup.bash | bash
|
# curl -fsSL https://example.com/setup.bash | bash
|
||||||
# wget -nv https://example.com/setup.bash -O - | bash
|
# wget -nv https://example.com/setup.bash -O - | bash
|
||||||
|
|
||||||
BASE_URL="https://raw.githubusercontent.com/coolaj86/node-install-script/master"
|
NODEJS_NAME="node"
|
||||||
|
NODEJS_BASE_URL="https://nodejs.org"
|
||||||
if [ -n "$(which node 2>/dev/null || false)" ]; then
|
BASE_URL="https://raw.githubusercontent.com/coolaj86/iojs-install-script/master"
|
||||||
echo ""
|
NO_FAIL2BAN=""
|
||||||
echo "HEY, LISTEN:"
|
|
||||||
echo "node is already install as $(node -v | grep v)"
|
|
||||||
echo ""
|
|
||||||
echo "to reinstall please first run: rm $(which node)"
|
|
||||||
echo ""
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f "/tmp/NODE_VER" ]; then
|
|
||||||
NODE_VER=$(cat /tmp/NODE_VER | grep v)
|
|
||||||
fi
|
|
||||||
if [ -z "$NODE_VER" ]; then
|
|
||||||
NODE_VER="v0.11.14"
|
|
||||||
fi
|
|
||||||
OS="unsupported"
|
OS="unsupported"
|
||||||
ARCH=""
|
ARCH=""
|
||||||
|
NODEJS_VER=""
|
||||||
|
SETUP_FILE=""
|
||||||
|
|
||||||
|
clear
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# Which OS and version? #
|
||||||
|
#########################
|
||||||
|
|
||||||
if [ "$(uname | grep -i 'Darwin')" ]; then
|
if [ "$(uname | grep -i 'Darwin')" ]; then
|
||||||
OSX_VER="$(sw_vers | grep ProductVersion | cut -d':' -f2 | cut -f2)"
|
OSX_VER="$(sw_vers | grep ProductVersion | cut -d':' -f2 | cut -f2)"
|
||||||
|
@ -75,9 +78,7 @@ if [ "$(uname | grep -i 'Darwin')" ]; then
|
||||||
else
|
else
|
||||||
ARCH="32"
|
ARCH="32"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elif [ "$(uname | grep -i 'Linux')" ]; then
|
elif [ "$(uname | grep -i 'Linux')" ]; then
|
||||||
|
|
||||||
if [ ! -f "/etc/issue" ]; then
|
if [ ! -f "/etc/issue" ]; then
|
||||||
echo "unsupported linux os"
|
echo "unsupported linux os"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -91,43 +92,45 @@ elif [ "$(uname | grep -i 'Linux')" ]; then
|
||||||
|
|
||||||
if [ "$(cat /etc/issue | grep -i 'Ubuntu')" ]; then
|
if [ "$(cat /etc/issue | grep -i 'Ubuntu')" ]; then
|
||||||
OS='ubuntu'
|
OS='ubuntu'
|
||||||
|
elif [ "$(cat /etc/issue | grep -i 'Raspbian')" ]; then
|
||||||
|
OS='raspbian'
|
||||||
elif [ "$(cat /etc/issue | grep -i 'Fedora')" ]; then
|
elif [ "$(cat /etc/issue | grep -i 'Fedora')" ]; then
|
||||||
OS='fedora'
|
OS='fedora'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
echo "unsupported unknown os (non-mac, non-linux)"
|
echo "unsupported unknown os (non-mac, non-linux)"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "${OS}" in
|
case "${OS}" in
|
||||||
fedora)
|
fedora)
|
||||||
echo "sudo yum"
|
echo "FEDORA not yet supported (feel free to pull request)"
|
||||||
echo "wget --quiet ${BASE_URL}/setup-fedora.bash -O /tmp/install-node.bash || echo 'error downloading os setup script'"
|
exit 1
|
||||||
;;
|
;;
|
||||||
ubuntu)
|
ubuntu)
|
||||||
wget --quiet "${BASE_URL}/setup-ubuntu.bash" -O /tmp/install-node.bash || echo 'error downloading os setup script'
|
SETUP_FILE="ubuntu"
|
||||||
|
;;
|
||||||
|
raspbian)
|
||||||
|
SETUP_FILE="ubuntu"
|
||||||
;;
|
;;
|
||||||
yosemite)
|
yosemite)
|
||||||
# mavericks
|
# mavericks
|
||||||
curl --silent "${BASE_URL}/setup-mavericks.bash" -o /tmp/install-node.bash || echo 'error downloading os setup script'
|
SETUP_FILE="mavericks"
|
||||||
;;
|
;;
|
||||||
mavericks)
|
mavericks)
|
||||||
curl --silent "${BASE_URL}/setup-mavericks.bash" -o /tmp/install-node.bash || echo 'error downloading os setup script'
|
SETUP_FILE="mavericks"
|
||||||
;;
|
;;
|
||||||
mountain)
|
mountain)
|
||||||
echo "wget cltools"
|
echo "Mountain Lion not yet supported (feel free to pull request)"
|
||||||
echo "curl --silent ${BASE_URL}/setup-mountain.bash -o /tmp/install-node.bash || echo 'error downloading os setup script'"
|
exit 1
|
||||||
;;
|
;;
|
||||||
lion)
|
lion)
|
||||||
echo "wget cltools"
|
echo "Lion not yet supported (feel free to pull request)"
|
||||||
echo "curl --silent ${BASE_URL}/setup-lion.bash -o /tmp/install-node.bash || echo 'error downloading os setup script'"
|
exit 1
|
||||||
;;
|
;;
|
||||||
snow)
|
snow)
|
||||||
echo "wget gcc-0.6.pkg"
|
echo "Snow Leopard not yet supported (feel free to pull request)"
|
||||||
echo "curl --silent ${BASE_URL}/setup-snow.bash -o /tmp/install-node.bash || echo 'error downloading os setup script'"
|
exit 1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "unsupported unknown os ${OS}"
|
echo "unsupported unknown os ${OS}"
|
||||||
|
@ -135,15 +138,144 @@ case "${OS}" in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo "${OS}" "${ARCH}"
|
|
||||||
bash /tmp/install-node.bash "${NODE_VER}"
|
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# Download installers #
|
||||||
|
#######################
|
||||||
|
|
||||||
|
echo "Preparing to install ${NODEJS_NAME} (and common development dependencies) for ${OS}" "${ARCH}"
|
||||||
|
|
||||||
|
INSTALL_DEPS_FILE="setup-deps-${SETUP_FILE}.bash"
|
||||||
|
INSTALL_FILE="setup-node-${SETUP_FILE}.bash"
|
||||||
|
if [ ! -e "/tmp/${INSTALL_DEPS_FILE}" ]
|
||||||
|
then
|
||||||
|
if [ -n "$(which curl)" ]; then
|
||||||
|
curl --silent "${BASE_URL}/${INSTALL_DEPS_FILE}" \
|
||||||
|
-o "/tmp/${INSTALL_DEPS_FILE}" || echo 'error downloading os deps script: '"${BASE_URL}/${INSTALL_DEPS_FILE}"
|
||||||
|
curl --silent "${BASE_URL}/${INSTALL_FILE}" \
|
||||||
|
-o "/tmp/${INSTALL_FILE}" || echo 'error downloading os setup script: '"${BASE_URL}/${INSTALL_FILE}"
|
||||||
|
elif [ -n "$(which wget)" ]; then
|
||||||
|
wget --quiet "${BASE_URL}/${INSTALL_DEPS_FILE}" \
|
||||||
|
-O "/tmp/${INSTALL_DEPS_FILE}" || echo 'error downloading os deps script: '"${BASE_URL}/${INSTALL_DEPS_FILE}"
|
||||||
|
wget --quiet "${BASE_URL}/${INSTALL_FILE}" \
|
||||||
|
-O "/tmp/${INSTALL_FILE}" || echo 'error downloading os setup script: '"${BASE_URL}/${INSTALL_FILE}"
|
||||||
|
else
|
||||||
|
echo "Found neither 'curl' nor 'wget'. Can't Continue."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e "/tmp/${INSTALL_DEPS_FILE}" ]
|
||||||
|
then
|
||||||
|
echo "Error Downloading Install File"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
################
|
||||||
|
# DEPENDENCIES #
|
||||||
|
################
|
||||||
|
|
||||||
|
if [ -z "$(which fail2ban-server | grep fail2ban)" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "Your server didn't come with fail2ban preinstalled!!!"
|
||||||
|
echo "Among other things, fail2ban secures ssh so that your server isn't reaped by botnets."
|
||||||
|
echo ""
|
||||||
|
echo "Since you're obviosly connecting this computer to a network, you should install fail2ban before continuing"
|
||||||
|
echo ""
|
||||||
|
echo "Install fail2ban? [Y/n]"
|
||||||
|
echo "(if unsure, just hit [enter])"
|
||||||
|
read INSTALL_FAIL2BAN
|
||||||
|
|
||||||
|
if [ "n" == "${INSTALL_FAIL2BAN}" ] || [ "no" == "${INSTALL_FAIL2BAN}" ] || [ "N" == "${INSTALL_FAIL2BAN}" ] || [ "NO" == "${INSTALL_FAIL2BAN}" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "I don't think you understand: This is important."
|
||||||
|
echo ""
|
||||||
|
echo "Your server will be under constant attack by botnets via ssh."
|
||||||
|
echo "It only takes a few extra seconds to install and the defaults are adequate for protecting you."
|
||||||
|
echo ""
|
||||||
|
echo "Change your mind?"
|
||||||
|
echo "Ready to install fail2ban? [Y/n]"
|
||||||
|
read INSTALL_FAIL2BAN
|
||||||
|
if [ "n" == "${INSTALL_FAIL2BAN}" ] || [ "no" == "${INSTALL_FAIL2BAN}" ] || [ "N" == "${INSTALL_FAIL2BAN}" ] || [ "NO" == "${INSTALL_FAIL2BAN}" ]; then
|
||||||
|
clear
|
||||||
|
echo "you make me sad :-("
|
||||||
|
sleep 0.5
|
||||||
|
echo "but whatever, it's your funeral..."
|
||||||
|
sleep 1
|
||||||
|
NO_FAIL2BAN="nope"
|
||||||
|
else
|
||||||
|
echo "Phew, dodged the bullet on that one... Will install fail2ban.. :-)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
bash "/tmp/${INSTALL_DEPS_FILE}" "${NO_FAIL2BAN}"
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# Which node.js VERSION ? #
|
||||||
|
#########################
|
||||||
|
|
||||||
|
if [ -f "/tmp/NODEJS_VER" ]; then
|
||||||
|
NODEJS_VER=$(cat /tmp/NODEJS_VER | grep v)
|
||||||
|
elif [ -f "/tmp/IOJS_VER" ]; then
|
||||||
|
NODEJS_VER=$(cat /tmp/IOJS_VER | grep v)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$NODEJS_VER" ]; then
|
||||||
|
NODEJS_VERT=$(echo ${NODEJS_VER} | cut -c 2- | cut -d '.' -f1)
|
||||||
|
|
||||||
|
if [ $NODEJS_VERT -ge 1 ] && [ $NODEJS_VERT -lt 4 ]
|
||||||
|
then
|
||||||
|
echo "Selecting io.js instead of node.js for this version (>= 1.0.0 < 4.0.0)"
|
||||||
|
NODEJS_BASE_URL="https://iojs.org"
|
||||||
|
NODEJS_NAME="iojs"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$NODEJS_VER" ]; then
|
||||||
|
if [ -n "$(which curl)" ]; then
|
||||||
|
NODEJS_VER=$(curl -fsSL "$NODEJS_BASE_URL/dist/index.tab" | head -2 | tail -1 | cut -f 1) \
|
||||||
|
|| echo "error automatically determining current ${NODEJS_NAME} version"
|
||||||
|
elif [ -n "$(which wget)" ]; then
|
||||||
|
NODEJS_VER=$(wget --quiet "$NODEJS_BASE_URL/dist/index.tab" -O - | head -2 | tail -1 | cut -f 1) \
|
||||||
|
|| echo "error automatically determining current ${NODEJS_NAME} version"
|
||||||
|
else
|
||||||
|
echo "Found neither 'curl' nor 'wget'. Can't Continue."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# node
|
||||||
|
#
|
||||||
|
if [ -n "$(which node | grep node 2>/dev/null)" ]; then
|
||||||
|
# node of some version is already installed
|
||||||
|
if [ "${NODEJS_VER}" == "$(node -v 2>/dev/null)" ]; then
|
||||||
|
echo node ${NODEJS_VER} is already installed
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
echo "HEY, LISTEN:"
|
||||||
|
echo ""
|
||||||
|
echo "node.js is already installed as node $(node -v | grep v)"
|
||||||
|
echo ""
|
||||||
|
echo "to reinstall please first run: rm $(which node)"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
NODEJS_VER=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${NODEJS_VER}" ]; then
|
||||||
|
bash "/tmp/${INSTALL_FILE}" "${NODEJS_VER}"
|
||||||
|
fi
|
||||||
|
|
||||||
# jshint
|
# jshint
|
||||||
if [ -z "$(which jshint | grep jshint)" ]; then
|
if [ -z "$(which jshint | grep jshint)" ]; then
|
||||||
echo "installing jshint..."
|
echo "installing jshint..."
|
||||||
npm install --silent jshint -g > /dev/null
|
npm install --silent jshint -g > /dev/null
|
||||||
else
|
|
||||||
echo "jshint already installed"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
Loading…
Reference in New Issue