Compare commits
	
		
			2 Commits
		
	
	
		
			963f551a98
			...
			b0b829fd91
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					b0b829fd91 | ||
| 
						 | 
					bacd1a4537 | 
							
								
								
									
										20
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								README.md
									
									
									
									
									
								
							@ -1,4 +1,5 @@
 | 
				
			|||||||
# Easy Install node.js
 | 
					# Easy Install node.js
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| Sponsored by [Daplie](https://daplie.com) |
 | 
					| Sponsored by [Daplie](https://daplie.com) |
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Automated node.js installers for OS X and Ubuntu
 | 
					Automated node.js installers for OS X and Ubuntu
 | 
				
			||||||
@ -7,10 +8,10 @@ Automated node.js installers for OS X and Ubuntu
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
# install node.js without development dependencies
 | 
					# install node.js without development dependencies
 | 
				
			||||||
curl -fsSL bit.ly/install-min-node | bash
 | 
					curl -fsSL bit.ly/node-installer | bash -s --no-dev-deps
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# using wget instead of curl (Ubuntu)
 | 
					# using wget instead of curl (Ubuntu)
 | 
				
			||||||
wget -nv bit.ly/install-min-node -O - | bash
 | 
					wget -nv bit.ly/node-installer -O - | bash -s --no-dev-deps
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**node.js + dev tools**
 | 
					**node.js + dev tools**
 | 
				
			||||||
@ -18,10 +19,13 @@ wget -nv bit.ly/install-min-node -O - | bash
 | 
				
			|||||||
Install node.js and basic development tools - git, node, gcc, pkg-config, etc
 | 
					Install node.js and basic development tools - git, node, gcc, pkg-config, etc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
curl -L bit.ly/install-dev-node -o ./node-dev; bash ./node-dev
 | 
					curl -fsSL bit.ly/node-installer -o ./node-installer.sh; bash ./node-installer.sh --dev-deps
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# or wget
 | 
				
			||||||
 | 
					wget -nv bit.ly/node-installer -O - ./node-installer.sh; bash ./node-installer.sh --dev-deps
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<!-- bit.ly/easy-install-node -->
 | 
					*Note*: [bit.ly/node-installer](https://bit.ly/node-installer) simple redirects to <https://git.coolaj86.com/coolaj86/node-installer.sh/raw/master/install.sh>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Screencast
 | 
					## Screencast
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -35,8 +39,8 @@ echo "Current node.js version is $(curl -fsSL https://nodejs.org/dist/index.tab
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
# To install a specific version rather than defaulting to latest
 | 
					# To install a specific version rather than defaulting to latest
 | 
				
			||||||
# latest version at time of writing are v4.4.1 and v5.9.1
 | 
					# latest version at time of writing are v8.9.0 and v9.0.0
 | 
				
			||||||
echo "v7.9.0" > /tmp/NODEJS_VER
 | 
					echo "v8.9.0" > /tmp/NODEJS_VER
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Notes
 | 
					## Notes
 | 
				
			||||||
@ -66,7 +70,7 @@ Type `agree` and hit enter to accept the license.
 | 
				
			|||||||
Now you can install node.js
 | 
					Now you can install node.js
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
curl -fsSL bit.ly/install-dev-node -o /tmp/node-dev.sh; bash /tmp/node-dev.sh
 | 
					curl -fsSL bit.ly/node-installer -o /tmp/node-installer.sh; bash /tmp/node-installer.sh --dev-deps
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
*TODO*: Make it easier to accepting the license (automatic?)
 | 
					*TODO*: Make it easier to accepting the license (automatic?)
 | 
				
			||||||
@ -74,7 +78,7 @@ curl -fsSL bit.ly/install-dev-node -o /tmp/node-dev.sh; bash /tmp/node-dev.sh
 | 
				
			|||||||
### Ubuntu Linux
 | 
					### Ubuntu Linux
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
wget -nv bit.ly/install-dev-node -O /tmp/node-dev.sh; bash /tmp/node-dev.sh
 | 
					wget -nv bit.ly/node-installer -O /tmp/node-installer.sh; bash /tmp/node-installer.sh --dev-deps
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Other things you should know
 | 
					### Other things you should know
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										345
									
								
								install.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										345
									
								
								install.sh
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,345 @@
 | 
				
			|||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Installs node.js only (no development dependencies) for both Ubuntu and OS X
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# See https://git.coolaj86.com/coolaj86/node-installer.sh
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# 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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					deps_flag="$1"
 | 
				
			||||||
 | 
					set -e
 | 
				
			||||||
 | 
					set -u
 | 
				
			||||||
 | 
					#set -o pipefail
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ -z "${PREFIX-}" ]; then
 | 
				
			||||||
 | 
					  PREFIX=""
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					NODEJS_NAME="node"
 | 
				
			||||||
 | 
					NODEJS_BASE_URL="https://nodejs.org"
 | 
				
			||||||
 | 
					BASE_URL="https://git.coolaj86.com/coolaj86/node-installer.sh/raw/master"
 | 
				
			||||||
 | 
					#NO_FAIL2BAN=""
 | 
				
			||||||
 | 
					NO_FAIL2BAN="nope"
 | 
				
			||||||
 | 
					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 'Linux Mint')" ]; then
 | 
				
			||||||
 | 
					    OS='ubuntu'
 | 
				
			||||||
 | 
					  elif [ "$(cat /etc/issue | grep -i 'elementary OS')" ]; then
 | 
				
			||||||
 | 
					    OS='ubuntu'
 | 
				
			||||||
 | 
					  elif [ "$(cat /etc/issue | grep -i 'Debian')" ]; then
 | 
				
			||||||
 | 
					    OS='ubuntu'
 | 
				
			||||||
 | 
					  elif [ "$(cat /etc/issue | grep -i 'Trisquel')" ]; then
 | 
				
			||||||
 | 
					    OS='ubuntu'
 | 
				
			||||||
 | 
					  elif [ "$(cat /etc/issue | grep -i 'Zorin')" ]; 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 #
 | 
				
			||||||
 | 
					#######################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ "--dev-deps" == "$deps_flag" ]; then
 | 
				
			||||||
 | 
					  echo "Preparing to install node.js (and common development dependencies) for ${OS}" "${ARCH}"
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					  echo "Preparing to install node.js (minimal) for ${OS}" "${ARCH}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					INSTALL_DEPS_FILE="setup-deps-${SETUP_FILE}.bash"
 | 
				
			||||||
 | 
					INSTALL_FILE="setup-node-${SETUP_FILE}.bash"
 | 
				
			||||||
 | 
					if [ ! -e "/tmp/${INSTALL_FILE}" ]; then
 | 
				
			||||||
 | 
					  if [ -n "$(type -p curl)" ]; then
 | 
				
			||||||
 | 
					    curl --silent -L "${BASE_URL}/${INSTALL_FILE}" \
 | 
				
			||||||
 | 
					      -o "/tmp/${INSTALL_FILE}" || echo 'error downloading os setup script'
 | 
				
			||||||
 | 
					  elif [ -n "$(type -p 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 [ "--dev-deps" == "$deps_flag" ]; then
 | 
				
			||||||
 | 
					  if [ ! -e "/tmp/${INSTALL_DEPS_FILE}" ]; then
 | 
				
			||||||
 | 
					    if [ -n "$(type -p curl)" ]; then
 | 
				
			||||||
 | 
					      curl --silent -L "${BASE_URL}/${INSTALL_DEPS_FILE}" \
 | 
				
			||||||
 | 
					        -o "/tmp/${INSTALL_DEPS_FILE}" || echo 'error downloading os deps script: '"${BASE_URL}/${INSTALL_DEPS_FILE}"
 | 
				
			||||||
 | 
					    elif [ -n "$(type -p 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}"
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      echo "Found neither 'curl' nor 'wget'. Can't Continue."
 | 
				
			||||||
 | 
					      exit 1
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ ! -e "/tmp/${INSTALL_FILE}" ]
 | 
				
			||||||
 | 
					then
 | 
				
			||||||
 | 
					  echo "Error Downloading Install File"
 | 
				
			||||||
 | 
					  exit 1
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ "--dev-deps" == "$deps_flag" ]; then
 | 
				
			||||||
 | 
					  if [ ! -e "/tmp/${INSTALL_DEPS_FILE}" ]
 | 
				
			||||||
 | 
					  then
 | 
				
			||||||
 | 
					    echo "Error Downloading Deps File"
 | 
				
			||||||
 | 
					    exit 1
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#########################
 | 
				
			||||||
 | 
					# 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 "$(type -p curl)" ]; then
 | 
				
			||||||
 | 
					    NODEJS_VER=$(curl -fsL "$NODEJS_BASE_URL/dist/index.tab" | head -2 | tail -1 | cut -f 1) \
 | 
				
			||||||
 | 
					      || echo 'error automatically determining current node.js version'
 | 
				
			||||||
 | 
					  elif [ -n "$(type -p 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 node.js version'
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    echo "Found neither 'curl' nor 'wget'. Can't Continue."
 | 
				
			||||||
 | 
					    exit 1
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# node
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					if [ -z "${NODE_PATH-}" ]; then
 | 
				
			||||||
 | 
					  if [ -n "$(type -p node | grep node 2>/dev/null)" ]; then
 | 
				
			||||||
 | 
					    # /usr/local/bin/node => /usr/local
 | 
				
			||||||
 | 
					    node_install_path="$(dirname $(dirname $(type -p node)))"
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    node_install_path=$PREFIX/usr/local
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					  node_install_path=$(dirname $(dirname $NODE_PATH))
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					echo "Install path is $node_install_path"
 | 
				
			||||||
 | 
					if [ -e "$node_install_path/bin/node" ]; then
 | 
				
			||||||
 | 
					# node of some version is already installed
 | 
				
			||||||
 | 
					  if [ "${NODEJS_VER}" == "$($node_install_path/bin/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_install_path/bin/node -v | grep v)"
 | 
				
			||||||
 | 
					    echo ""
 | 
				
			||||||
 | 
					    echo "to reinstall please first run: rm $node_install_path/bin/node"
 | 
				
			||||||
 | 
					    echo ""
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  NODEJS_VER=""
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ -n "${NODEJS_VER}" ]; then
 | 
				
			||||||
 | 
					  bash "/tmp/${INSTALL_FILE}" "${NODEJS_VER}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					sudo chown -R $(whoami) $node_install_path/lib/node_modules
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					echo ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ "--dev-deps" == "$deps_flag" ]; then
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ################
 | 
				
			||||||
 | 
					  # 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 obviously 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}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  # yarn
 | 
				
			||||||
 | 
					  #if [ -z "$(type -p yarn)" ]; then
 | 
				
			||||||
 | 
					  #  echo "installing yarn..."
 | 
				
			||||||
 | 
					  #  npm install --silent yarn -g > /dev/null
 | 
				
			||||||
 | 
					  #fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  # jshint
 | 
				
			||||||
 | 
					  if [ -z "$(type -p jshint)" ]; then
 | 
				
			||||||
 | 
					    echo "installing jshint..."
 | 
				
			||||||
 | 
					    #yarn global add jshint > /dev/null
 | 
				
			||||||
 | 
					    $node_install_path/bin/npm install -g jshint > /dev/null
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  echo ""
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
@ -18,8 +18,8 @@ BASE_URL="https://git.coolaj86.com/coolaj86/node-installer.sh/raw/master"
 | 
				
			|||||||
# Download installers #
 | 
					# Download installers #
 | 
				
			||||||
#######################
 | 
					#######################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
INSTALL_FILE_REMOTE="setup.bash"
 | 
					INSTALL_FILE_REMOTE="install.sh"
 | 
				
			||||||
INSTALL_FILE="node.setup.bash"
 | 
					INSTALL_FILE="node-installer.sh"
 | 
				
			||||||
if [ ! -e "/tmp/${INSTALL_FILE}" ]
 | 
					if [ ! -e "/tmp/${INSTALL_FILE}" ]
 | 
				
			||||||
then
 | 
					then
 | 
				
			||||||
  if [ -n "$(which curl)" ]; then
 | 
					  if [ -n "$(which curl)" ]; then
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										331
									
								
								setup.bash
									
									
									
									
									
								
							
							
						
						
									
										331
									
								
								setup.bash
									
									
									
									
									
								
							@ -1,345 +1,44 @@
 | 
				
			|||||||
#!/bin/bash
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Installs node.js only (no development dependencies) for both Ubuntu and OS X
 | 
					# Installs node.js + dependencies for both Ubuntu and OS X
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# See https://git.coolaj86.com/coolaj86/node-installer.sh
 | 
					# See https://git.colaj86.com/coolaj86/node-installer.sh
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# curl -fsSL bit.ly/nodejs-min | bash
 | 
					# curl -fsSL https://example.com/setup.bash | bash
 | 
				
			||||||
# wget -nv bit.ly/nodejs-min -O - | bash
 | 
					# wget -nv https://example.com/setup.bash -O - | bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# curl -fsSL https://example.com/setup-min.bash | bash
 | 
					 | 
				
			||||||
# wget -nv https://example.com/setup-min.bash -O - | bash
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
dont_install_deps="$1"
 | 
					 | 
				
			||||||
set -e
 | 
					set -e
 | 
				
			||||||
set -u
 | 
					set -u
 | 
				
			||||||
#set -o pipefail
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ -z "${PREFIX-}" ]; then
 | 
					 | 
				
			||||||
  PREFIX=""
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
NODEJS_NAME="node"
 | 
					 | 
				
			||||||
NODEJS_BASE_URL="https://nodejs.org"
 | 
					 | 
				
			||||||
BASE_URL="https://git.coolaj86.com/coolaj86/node-installer.sh/raw/master"
 | 
					BASE_URL="https://git.coolaj86.com/coolaj86/node-installer.sh/raw/master"
 | 
				
			||||||
#NO_FAIL2BAN=""
 | 
					 | 
				
			||||||
NO_FAIL2BAN="nope"
 | 
					 | 
				
			||||||
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 'Linux Mint')" ]; then
 | 
					 | 
				
			||||||
    OS='ubuntu'
 | 
					 | 
				
			||||||
  elif [ "$(cat /etc/issue | grep -i 'elementary OS')" ]; then
 | 
					 | 
				
			||||||
    OS='ubuntu'
 | 
					 | 
				
			||||||
  elif [ "$(cat /etc/issue | grep -i 'Debian')" ]; then
 | 
					 | 
				
			||||||
    OS='ubuntu'
 | 
					 | 
				
			||||||
  elif [ "$(cat /etc/issue | grep -i 'Trisquel')" ]; then
 | 
					 | 
				
			||||||
    OS='ubuntu'
 | 
					 | 
				
			||||||
  elif [ "$(cat /etc/issue | grep -i 'Zorin')" ]; 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 #
 | 
					# Download installers #
 | 
				
			||||||
#######################
 | 
					#######################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ -z "$dont_install_deps" ]; then
 | 
					INSTALL_FILE_REMOTE="install.sh"
 | 
				
			||||||
  echo "Preparing to install node.js (and common development dependencies) for ${OS}" "${ARCH}"
 | 
					INSTALL_FILE="node-installer.sh"
 | 
				
			||||||
else
 | 
					if [ ! -e "/tmp/${INSTALL_FILE}" ]
 | 
				
			||||||
  echo "Preparing to install node.js (minimal) for ${OS}" "${ARCH}"
 | 
					then
 | 
				
			||||||
fi
 | 
					  if [ -n "$(which curl)" ]; then
 | 
				
			||||||
 | 
					    curl --silent -L "${BASE_URL}/${INSTALL_FILE_REMOTE}" \
 | 
				
			||||||
INSTALL_DEPS_FILE="setup-deps-${SETUP_FILE}.bash"
 | 
					      -o "/tmp/${INSTALL_FILE}" || echo 'error setup script: '"${BASE_URL}/${INSTALL_FILE_REMOTE}"
 | 
				
			||||||
INSTALL_FILE="setup-node-${SETUP_FILE}.bash"
 | 
					  elif [ -n "$(which wget)" ]; then
 | 
				
			||||||
if [ ! -e "/tmp/${INSTALL_FILE}" ]; then
 | 
					    wget --quiet "${BASE_URL}/${INSTALL_FILE_REMOTE}" \
 | 
				
			||||||
  if [ -n "$(type -p curl)" ]; then
 | 
					      -O "/tmp/${INSTALL_FILE}" || echo 'error setup script: '"${BASE_URL}/${INSTALL_FILE_REMOTE}"
 | 
				
			||||||
    curl --silent -L "${BASE_URL}/${INSTALL_FILE}" \
 | 
					 | 
				
			||||||
      -o "/tmp/${INSTALL_FILE}" || echo 'error downloading os setup script'
 | 
					 | 
				
			||||||
  elif [ -n "$(type -p wget)" ]; then
 | 
					 | 
				
			||||||
    wget --quiet "${BASE_URL}/${INSTALL_FILE}" \
 | 
					 | 
				
			||||||
      -O "/tmp/${INSTALL_FILE}" || echo 'error downloading os setup script'
 | 
					 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    echo "Found neither 'curl' nor 'wget'. Can't Continue."
 | 
					    echo "Found neither 'curl' nor 'wget'. Can't Continue."
 | 
				
			||||||
    exit 1
 | 
					    exit 1
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ -z "$dont_install_deps" ]; then
 | 
					 | 
				
			||||||
  if [ ! -e "/tmp/${INSTALL_DEPS_FILE}" ]; then
 | 
					 | 
				
			||||||
    if [ -n "$(type -p curl)" ]; then
 | 
					 | 
				
			||||||
      curl --silent -L "${BASE_URL}/${INSTALL_DEPS_FILE}" \
 | 
					 | 
				
			||||||
        -o "/tmp/${INSTALL_DEPS_FILE}" || echo 'error downloading os deps script: '"${BASE_URL}/${INSTALL_DEPS_FILE}"
 | 
					 | 
				
			||||||
    elif [ -n "$(type -p 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}"
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
      echo "Found neither 'curl' nor 'wget'. Can't Continue."
 | 
					 | 
				
			||||||
      exit 1
 | 
					 | 
				
			||||||
    fi
 | 
					 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if [ ! -e "/tmp/${INSTALL_FILE}" ]
 | 
					if [ ! -e "/tmp/${INSTALL_FILE}" ]
 | 
				
			||||||
then
 | 
					then
 | 
				
			||||||
  echo "Error Downloading Install File"
 | 
					  echo "Error Downloading Install File"
 | 
				
			||||||
  exit 1
 | 
					  exit 1
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ -z "$dont_install_deps" ]; then
 | 
					 | 
				
			||||||
  if [ ! -e "/tmp/${INSTALL_DEPS_FILE}" ]
 | 
					 | 
				
			||||||
  then
 | 
					 | 
				
			||||||
    echo "Error Downloading Deps File"
 | 
					 | 
				
			||||||
    exit 1
 | 
					 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#########################
 | 
					bash "/tmp/${INSTALL_FILE}"
 | 
				
			||||||
# 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 "$(type -p curl)" ]; then
 | 
					 | 
				
			||||||
    NODEJS_VER=$(curl -fsL "$NODEJS_BASE_URL/dist/index.tab" | head -2 | tail -1 | cut -f 1) \
 | 
					 | 
				
			||||||
      || echo 'error automatically determining current node.js version'
 | 
					 | 
				
			||||||
  elif [ -n "$(type -p 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 node.js version'
 | 
					 | 
				
			||||||
  else
 | 
					 | 
				
			||||||
    echo "Found neither 'curl' nor 'wget'. Can't Continue."
 | 
					 | 
				
			||||||
    exit 1
 | 
					 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# node
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
if [ -z "${NODE_PATH-}" ]; then
 | 
					 | 
				
			||||||
  if [ -n "$(type -p node | grep node 2>/dev/null)" ]; then
 | 
					 | 
				
			||||||
    # /usr/local/bin/node => /usr/local
 | 
					 | 
				
			||||||
    node_install_path="$(dirname $(dirname $(type -p node)))"
 | 
					 | 
				
			||||||
  else
 | 
					 | 
				
			||||||
    node_install_path=$PREFIX/usr/local
 | 
					 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
else
 | 
					 | 
				
			||||||
  node_install_path=$(dirname $(dirname $NODE_PATH))
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
echo "Install path is $node_install_path"
 | 
					 | 
				
			||||||
if [ -e "$node_install_path/bin/node" ]; then
 | 
					 | 
				
			||||||
# node of some version is already installed
 | 
					 | 
				
			||||||
  if [ "${NODEJS_VER}" == "$($node_install_path/bin/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_install_path/bin/node -v | grep v)"
 | 
					 | 
				
			||||||
    echo ""
 | 
					 | 
				
			||||||
    echo "to reinstall please first run: rm $node_install_path/bin/node"
 | 
					 | 
				
			||||||
    echo ""
 | 
					 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  NODEJS_VER=""
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if [ -n "${NODEJS_VER}" ]; then
 | 
					 | 
				
			||||||
  bash "/tmp/${INSTALL_FILE}" "${NODEJS_VER}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
sudo chown -R $(whoami) $node_install_path/lib/node_modules
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
echo ""
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if [ -z "$dont_install_deps" ]; then
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ################
 | 
					 | 
				
			||||||
  # 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 obviously 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}"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  # yarn
 | 
					 | 
				
			||||||
  #if [ -z "$(type -p yarn)" ]; then
 | 
					 | 
				
			||||||
  #  echo "installing yarn..."
 | 
					 | 
				
			||||||
  #  npm install --silent yarn -g > /dev/null
 | 
					 | 
				
			||||||
  #fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  # jshint
 | 
					 | 
				
			||||||
  if [ -z "$(type -p jshint)" ]; then
 | 
					 | 
				
			||||||
    echo "installing jshint..."
 | 
					 | 
				
			||||||
    #yarn global add jshint > /dev/null
 | 
					 | 
				
			||||||
    $node_install_path/bin/npm install -g jshint > /dev/null
 | 
					 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  echo ""
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user