forked from coolaj86/node-installer.sh
Compare commits
140 Commits
pull/4/mas
...
master
Author | SHA1 | Date |
---|---|---|
AJ ONeal | a431978582 | |
AJ ONeal | 6c3fa218ba | |
AJ ONeal | 79d4d239ad | |
AJ ONeal | 60f206373c | |
AJ ONeal | 22c741817c | |
AJ ONeal | 1f3a195fe9 | |
AJ ONeal | c3890ca8a9 | |
AJ ONeal | 689fa58531 | |
AJ ONeal | 895dcd31f2 | |
AJ ONeal | b8acbae85f | |
AJ ONeal | 509ee32688 | |
AJ ONeal | 3109f4bb94 | |
AJ ONeal | 05199bcf82 | |
AJ ONeal | 1387929dfc | |
AJ ONeal | c15264b763 | |
AJ ONeal | 8be0a29b7d | |
AJ ONeal | 972d510f59 | |
AJ ONeal | 92ec7ad5b6 | |
AJ ONeal | 95c0caf4be | |
AJ ONeal | ed24276356 | |
AJ ONeal | dddf31db8d | |
AJ ONeal | a1af3328cb | |
AJ ONeal | 515bdce8c2 | |
AJ ONeal | 4ea01c4c42 | |
AJ ONeal | 45adb12ae1 | |
AJ ONeal | 0d6e15ee62 | |
AJ ONeal | 8a14fc8ede | |
AJ ONeal | 2309008c5f | |
AJ ONeal | f2a8c2fc49 | |
AJ ONeal | b562d6dd3b | |
AJ ONeal | bad41027ad | |
AJ ONeal | 5f231f9d22 | |
AJ ONeal | 0171162f20 | |
AJ ONeal | 3ced314799 | |
AJ ONeal | 00c986e483 | |
AJ ONeal | 97c7ef9793 | |
AJ ONeal | c747edb99a | |
AJ ONeal | 62bc523d03 | |
AJ ONeal | 82e6ace060 | |
AJ ONeal | 748c51a687 | |
AJ ONeal | 0c7d0a7da6 | |
AJ ONeal | be9344dbea | |
AJ ONeal | 2d628014d0 | |
AJ ONeal | 17c0b01ee0 | |
AJ ONeal | e436cdb64d | |
AJ ONeal | a443dd04d3 | |
AJ ONeal | 5af26c6c86 | |
AJ ONeal | a9e1370b58 | |
AJ ONeal | 1edc07515f | |
AJ ONeal | 1a7d21b850 | |
AJ ONeal | 7809937d74 | |
AJ ONeal | 3adefcc4a8 | |
AJ ONeal | ae2511f592 | |
AJ ONeal | 08002c572a | |
AJ ONeal | 3e7745177f | |
AJ ONeal | 5d39eef143 | |
AJ ONeal | 90cdb8f93e | |
AJ ONeal | ccb1487b36 | |
AJ ONeal | e57069fe50 | |
AJ ONeal | e9c21e3063 | |
AJ ONeal | 216aa9b420 | |
AJ ONeal | d3069471e7 | |
AJ ONeal | 65ad946056 | |
AJ ONeal | b0b829fd91 | |
AJ ONeal | bacd1a4537 | |
AJ ONeal | 963f551a98 | |
AJ ONeal | 32839e69ba | |
AJ ONeal | 4090196e84 | |
AJ ONeal | 2adfec1fd6 | |
richdex14 | aed892007f | |
richdex14 | 6252737cc1 | |
richdex14 | 2f9f3c0c82 | |
richdex14 | a24f92df98 | |
richdex14 | 351056f9bc | |
richdex14 | 28c1ad8484 | |
richdex14 | ae331149f7 | |
richdex14 | 16a6d7e18c | |
richdex14 | 6c0afe6488 | |
richdex14 | 31b92cdadb | |
richdex14 | 561a2e2fa1 | |
richdex14 | 8a5593363d | |
richdex14 | 69bc78680d | |
richdex14 | 8a3f4ba77f | |
richdex14 | a99583fb1d | |
richdex14 | 0948a728c3 | |
richdex14 | fb0a8f6372 | |
richdex14 | de522df09b | |
AJ ONeal | b96b79f3ed | |
AJ ONeal | efe4bde88e | |
AJ ONeal | 1b271ba7e5 | |
AJ ONeal | 01bc3bf064 | |
AJ ONeal | 586863fb75 | |
AJ ONeal | 77c6be5840 | |
AJ ONeal | a05cf035b3 | |
AJ ONeal | f2f1cb94d2 | |
AJ ONeal | 6a73356dd9 | |
AJ ONeal | b33f1136f2 | |
AJ ONeal | 0e84c903e9 | |
AJ ONeal | 6fb08fe2af | |
AJ ONeal | ae72817e43 | |
AJ ONeal | 228bdc5e1c | |
AJ ONeal | 59e420471b | |
AJ ONeal | 3e36adfbcb | |
AJ ONeal | d41b5b1adf | |
AJ ONeal | 49d19e6cdb | |
AJ ONeal | 1a41b29bfb | |
AJ ONeal | 6d1df2e7e4 | |
AJ ONeal | 1c05eb8a68 | |
AJ ONeal | 6dde1965fc | |
AJ ONeal | e9837d9445 | |
AJ ONeal | 0a5ec4deba | |
AJ ONeal | 933ceba356 | |
AJ ONeal | 5a1edbd2e4 | |
AJ ONeal | 216bcb8796 | |
AJ ONeal | 30627ef933 | |
AJ ONeal | b6c4f023f5 | |
AJ ONeal | e93042403c | |
AJ ONeal | 1bc7b66208 | |
AJ ONeal | 24b68d4f90 | |
AJ ONeal | 85ad20281f | |
AJ ONeal | c3e6fa9660 | |
AJ ONeal | 94e18f04a9 | |
AJ ONeal | 2831949296 | |
AJ ONeal | 5b17c6e5fd | |
AJ ONeal | 4155a7c639 | |
AJ ONeal | 2cfa00cced | |
AJ ONeal | 4011161397 | |
AJ ONeal | 67245d84fc | |
AJ ONeal | a5d7a27747 | |
AJ ONeal | c65932db08 | |
AJ ONeal | 020fe6b3d6 | |
AJ ONeal | c243b8bb89 | |
AJ ONeal | d5fb60b2a9 | |
AJ ONeal | 891dd40394 | |
AJ ONeal | 2f42061544 | |
Joshua Mudge | dde86e4db2 | |
Joshua Mudge | fe16a47cb6 | |
Joshua Mudge | c8d1657124 | |
Joshua Mudge | 2c16603901 | |
Joshua Mudge | 4eccc5c807 |
141
README.md
141
README.md
|
@ -1,43 +1,105 @@
|
||||||
|
# STOP
|
||||||
|
|
||||||
|
The install method in this repo still has its place, but this is no longer maintained.
|
||||||
|
|
||||||
|
**Update**: Use [Webi](https://webinstall.dev) instead:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
curl https://webinstall.dev/node | bash
|
||||||
|
```
|
||||||
|
|
||||||
# Easy Install node.js
|
# Easy Install node.js
|
||||||
|
|
||||||
Automated node.js installers for OS X and Ubuntu
|
| A [Root](https://rootprojects.org) Project |
|
||||||
|
|
||||||
**node.js only** (no dev tools)
|
Simple node.js installer for macOS and Linux
|
||||||
|
|
||||||
|
## QuickStart
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# install node.js without development dependencies
|
curl -fsL bit.ly/node-installer | bash
|
||||||
curl -fsSL bit.ly/nodejs-min | bash
|
|
||||||
|
|
||||||
# using wget instead of curl (Ubuntu)
|
|
||||||
wget -nv bit.ly/nodejs-min -O - | bash
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**node.js + dev tools**
|
*Note*: [bit.ly/node-installer](https://bit.ly/node-installer) is a redirect to <https://git.coolaj86.com/coolaj86/node-installer.sh/raw/master/install.sh>
|
||||||
|
|
||||||
Install node.js and basic development tools - git, node, gcc, pkg-config, etc
|
|
||||||
|
|
||||||
```bash
|
|
||||||
curl -L bit.ly/nodejs-dev-install -o ./node-dev; bash ./node-dev
|
|
||||||
```
|
|
||||||
|
|
||||||
<!-- bit.ly/easy-install-node -->
|
|
||||||
|
|
||||||
## Screencast
|
## 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))
|
[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))
|
||||||
|
|
||||||
## Choosing a specific version
|
## Installer Options
|
||||||
|
|
||||||
|
* [x] version
|
||||||
|
* [x] install location
|
||||||
|
* [x] tools for building native modules
|
||||||
|
|
||||||
|
### Choose Version
|
||||||
|
|
||||||
|
The latest version of node is installed by default.
|
||||||
|
|
||||||
|
You can choose a specific version by defining `NODE_VERSION` in the format `vX`, `vX.Y`, or `v.X.Y.Z`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
echo "Current node.js version is $(curl -fsSL https://nodejs.org/dist/index.tab | head -2 | tail -1 | cut -f 1)"
|
NODE_VERSION=v10
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# To install a specific version rather than defaulting to latest
|
export NODE_VERSION=v10.10
|
||||||
# latest version at time of writing are v4.4.1 and v5.9.1
|
curl -fsSL https://bit.ly/node-installer | bash
|
||||||
echo "v5.9.1" > /tmp/NODE_VER
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Location
|
||||||
|
|
||||||
|
By default node will be installed to `/usr/local`, without root if possible.
|
||||||
|
|
||||||
|
You can choose a specific location by setting **both** `NPM_CONFIG_PREFIX` **and** `NODE_PATH`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export NPM_CONFIG_PREFIX=$HOME/.local
|
||||||
|
export NODE_PATH=$NPM_CONFIG_PREFIX/lib/node_modules
|
||||||
|
curl -fsSL https://bit.ly/node-installer | bash
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want to add the install location to your `PATH`, add `/bin` to the custom location used above and append it like so:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
PATH=$PATH:$HOME/.local/bin
|
||||||
|
```
|
||||||
|
|
||||||
|
### Development Tools
|
||||||
|
|
||||||
|
If you plan on building or creating native node modules, you'll want to install `gcc`, `pgk-config`, and a few other required tools and niceties.
|
||||||
|
|
||||||
|
In fact, it's fairly common for modules to have both native module and pure js dependencies, so you'll probably want (or need) to install these even if you don't plan to use them directly.
|
||||||
|
|
||||||
|
* [x] curl & wget
|
||||||
|
* [x] git
|
||||||
|
* [x] rsync
|
||||||
|
* [x] xcode, brew (on macOS), build-essential (Linux)
|
||||||
|
* [x] gcc, pkg-config
|
||||||
|
* [x] pkg-config
|
||||||
|
* [x] node.js, jshint
|
||||||
|
|
||||||
|
Pass `--dev-deps` to the installer script and it will use either `brew` (on macOS) or `apt` (on Linux) to install the development tools.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -fsSL https://bit.ly/node-installer | bash -s -- --dev-deps
|
||||||
|
```
|
||||||
|
|
||||||
|
Or, if you don't have `curl` installed yet you can use `wget`:
|
||||||
|
```bash
|
||||||
|
wget -nv https://bit.ly/node-installer -O - | bash -s -- --dev-deps
|
||||||
|
```
|
||||||
|
|
||||||
|
### Securing your server
|
||||||
|
|
||||||
|
If you're running a node.js server on anything with a public ip address
|
||||||
|
(an "edge" server), I'd highly recommend that you also install `fail2ban` to secure ssh -
|
||||||
|
especially if you haven't switched your server to use key-only authentication (which you should also do).
|
||||||
|
|
||||||
|
See [The 15-Minute Guide to Secure VPS Access (for the Semi-Paranoid)](https://www.youtube.com/watch?v=YZzhIIJmlE0)
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
* [OS X](#apple-os-x)
|
* [OS X](#apple-os-x)
|
||||||
|
@ -65,7 +127,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/nodejs-dev-install -o /tmp/node-dev.sh; bash /tmp/node-dev.sh
|
curl -fsSL https://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?)
|
||||||
|
@ -73,31 +135,20 @@ curl -fsSL bit.ly/nodejs-dev-install -o /tmp/node-dev.sh; bash /tmp/node-dev.sh
|
||||||
### Ubuntu Linux
|
### Ubuntu Linux
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
wget -nv bit.ly/nodejs-dev-install -O /tmp/node-dev.sh; bash /tmp/node-dev.sh
|
wget -nv https://bit.ly/node-installer -O /tmp/node-installer.sh; bash /tmp/node-installer.sh --dev-deps
|
||||||
```
|
```
|
||||||
|
|
||||||
### Other things you should know
|
### Automatic Version Detection
|
||||||
|
|
||||||
This is what gets installed:
|
Fun FYI, here's how the latest version is determined:
|
||||||
|
|
||||||
* rsync
|
```bash
|
||||||
* curl
|
NODE_VERSION=$(curl -fsSL https://nodejs.org/dist/index.tab | tail -n +2 | cut -f 1 | head -1 )
|
||||||
* wget
|
echo "The current node.js version is $NODE_VERSION"
|
||||||
* git
|
```
|
||||||
* xcode / brew / build-essential / pkg-config / gcc
|
|
||||||
* node (including npm)
|
|
||||||
* jshint
|
|
||||||
|
|
||||||
**NOTE**: If `fail2ban` is not already securing ssh, you will be asked to install it.
|
```bash
|
||||||
|
BASE_VER="v10\\."
|
||||||
|
NODE_VERSION=$(curl -fsSL https://nodejs.org/dist/index.tab | tail -n +2 | cut -f 1 | grep $BASE_VER | head -1 )
|
||||||
Front-End Extras
|
echo "Latest node.js $BASE_VER is $NODE_VERSION"
|
||||||
================
|
```
|
||||||
|
|
||||||
These are **not installed**, but you may wish to use them if you're doing front-end work as well
|
|
||||||
|
|
||||||
* bower
|
|
||||||
* uglifyjs
|
|
||||||
* yo
|
|
||||||
* jade
|
|
||||||
* less
|
|
|
@ -0,0 +1,387 @@
|
||||||
|
#!/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
|
||||||
|
|
||||||
|
# Not every platform has or needs sudo, gotta save them O(1)s...
|
||||||
|
sudo_cmd=""
|
||||||
|
((EUID)) && [[ -z "${ANDROID_ROOT:-}" ]] && sudo_cmd="sudo"
|
||||||
|
|
||||||
|
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=""
|
||||||
|
SETUP_FILE=""
|
||||||
|
my_tmp="$(mktemp -d -t node-installer.XXXXXXXX)"
|
||||||
|
export my_tmp
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
# Mavericks+ works for all current macOS versions
|
||||||
|
OS='mavericks'
|
||||||
|
|
||||||
|
if [[ "$OSX_MAJOR" -eq 10 ]]; then
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
fi
|
||||||
|
|
||||||
|
# OS X (10) and macOS (11) should be supported
|
||||||
|
|
||||||
|
if [ "$OSX_MAJOR" -gt 11 ]; then
|
||||||
|
echo "WARNING: macOS 12+ may or may not be supported"
|
||||||
|
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 "$(uname -a | 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 'Arch ')" ]; 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='ubuntu'
|
||||||
|
elif [ "$(cat /etc/issue | grep -i 'Marvell')" ]; then
|
||||||
|
OS='marvell'
|
||||||
|
else
|
||||||
|
OS='ubuntu'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "unsupported unknown os (non-mac, non-linux)"
|
||||||
|
exit 500
|
||||||
|
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"
|
||||||
|
;;
|
||||||
|
marvell)
|
||||||
|
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 "$my_tmp/${INSTALL_FILE}" ]; then
|
||||||
|
if [ -n "$(type -p curl)" ]; then
|
||||||
|
curl --silent -L "${BASE_URL}/${INSTALL_FILE}" \
|
||||||
|
-o "$my_tmp/${INSTALL_FILE}" || echo 'error downloading os setup script'
|
||||||
|
elif [ -n "$(type -p wget)" ]; then
|
||||||
|
wget --quiet "${BASE_URL}/${INSTALL_FILE}" \
|
||||||
|
-O "$my_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 "$my_tmp/${INSTALL_DEPS_FILE}" ]; then
|
||||||
|
if [ -n "$(type -p curl)" ]; then
|
||||||
|
curl --silent -L "${BASE_URL}/${INSTALL_DEPS_FILE}" \
|
||||||
|
-o "$my_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 "$my_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 "$my_tmp/${INSTALL_FILE}" ]
|
||||||
|
then
|
||||||
|
echo "Error Downloading Install File"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "--dev-deps" == "$deps_flag" ]; then
|
||||||
|
if [ ! -e "$my_tmp/${INSTALL_DEPS_FILE}" ]
|
||||||
|
then
|
||||||
|
echo "Error Downloading Deps File"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# Which node.js VERSION ? #
|
||||||
|
#########################
|
||||||
|
|
||||||
|
NODE_VERSION=${NODE_VERSION:-}
|
||||||
|
NODEJS_VER=${NODEJS_VER:-}
|
||||||
|
if [ -n "$NODE_VERSION" ]; then
|
||||||
|
NODEJS_VER=$NODE_VERSION
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${NODEJS_VER:-}" ]; then
|
||||||
|
# For backwards compat
|
||||||
|
if [ -f "$my_tmp/NODEJS_VER" ]; then
|
||||||
|
NODEJS_VER=$(cat $my_tmp/NODEJS_VER | grep v)
|
||||||
|
elif [ -f "/tmp/IOJS_VER" ]; then
|
||||||
|
NODEJS_VER=$(cat $my_tmp/IOJS_VER | grep v)
|
||||||
|
fi
|
||||||
|
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
|
||||||
|
|
||||||
|
NODEJS_VER="${NODEJS_VER:-v}" # Search for 'v' at the least
|
||||||
|
# sort -rV # will sort by version number, but it appears these are already sorted
|
||||||
|
# tail -n +2 # starts at line two (1-indexed) and all after (omits the csv header with 'version' and such)
|
||||||
|
# cut -f 1 # gets only the first column
|
||||||
|
# head -n 1 # gets only the most recent version
|
||||||
|
my_char="."
|
||||||
|
my_count=$(awk -F"${my_char}" '{print NF-1}' <<< "${NODEJS_VER}")
|
||||||
|
# get the latest version if partial
|
||||||
|
if [ $my_count -ne 2 ]; then
|
||||||
|
if [ "$NODEJS_VER" != "v" ]; then
|
||||||
|
NODEJS_VER="$NODEJS_VER\\."
|
||||||
|
fi
|
||||||
|
if [ -n "$(type -p curl)" ]; then
|
||||||
|
NODEJS_VER=$(curl -fsL "$NODEJS_BASE_URL/dist/index.tab" | tail -n +2 | cut -f 1 | grep "^$NODEJS_VER" | head -n 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 - | tail -n +2 | cut -f 1 | grep "^$NODEJS_VER" | head -n 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)))"
|
||||||
|
echo "NODE_PATH is not set. Using existing node install path: '$node_install_path'"
|
||||||
|
else
|
||||||
|
node_install_path=$PREFIX/usr/local
|
||||||
|
echo "NODE_PATH is not set. Using default install path '$node_install_path'"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
node_install_path=$(dirname $(dirname $NODE_PATH))
|
||||||
|
echo "NODE_PATH is '$NODE_PATH', so install path is '$node_install_path'"
|
||||||
|
fi
|
||||||
|
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
|
||||||
|
exit 0
|
||||||
|
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 as ${NODEJS_VER} please first run: rm $node_install_path/bin/node"
|
||||||
|
echo ""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
NODEJS_VER=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${NODEJS_VER}" ]; then
|
||||||
|
bash "$my_tmp/${INSTALL_FILE}" "${NODEJS_VER}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p $node_install_path/lib/node_modules 2> /dev/null || $sudo_cmd mkdir -p $node_install_path/lib/node_modules
|
||||||
|
chown -R $(whoami) $node_install_path/lib/node_modules 2> /dev/null || $sudo_cmd 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 "$my_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
|
||||||
|
|
||||||
|
rm -rf "$my_tmp"
|
|
@ -11,7 +11,6 @@ echo " * XCode Command Line Tools"
|
||||||
echo " * wget"
|
echo " * wget"
|
||||||
echo " * pkg-config"
|
echo " * pkg-config"
|
||||||
echo " * node"
|
echo " * node"
|
||||||
echo " * iojs"
|
|
||||||
echo " * jshint"
|
echo " * jshint"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
@ -32,6 +31,13 @@ if [ -z "$(xcode-select --print-path 2>/dev/null)" ] || [ -z "$(git --version 2>
|
||||||
while true; do
|
while true; do
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
|
if [ -n "$(xcode-select --print-path 2>/dev/null)" ]; then
|
||||||
|
# Agreeing to the Xcode/iOS license requires admin privileges, please run “sudo xcodebuild -license” and then retry this command.
|
||||||
|
echo "Now running 'sudo xcodebuild -license' so that you can accept the license agreement"
|
||||||
|
sudo xcodebuild -license
|
||||||
|
fi
|
||||||
|
# http://stackoverflow.com/questions/15371925/how-to-check-if-command-line-tools-is-installed
|
||||||
|
|
||||||
if [ -n "$(git --version 2>/dev/null)" ] && [ -n "$(xcode-select --print-path 2>/dev/null)" ]; then
|
if [ -n "$(git --version 2>/dev/null)" ] && [ -n "$(xcode-select --print-path 2>/dev/null)" ]; then
|
||||||
break;
|
break;
|
||||||
fi
|
fi
|
||||||
|
@ -58,13 +64,13 @@ if [ -z "$(which wget | grep wget)" ]; then
|
||||||
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
|
||||||
if [ -z "${NO_FAIL2BAN}" ]; then
|
# 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
|
||||||
fi
|
# fi
|
||||||
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..."
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
# curl -fsSL https://ldsconnect.org/setup-linux.bash | bash -c
|
# curl -fsSL https://ldsconnect.org/setup-linux.bash | bash -c
|
||||||
|
|
||||||
|
# Not every platform has or needs sudo, gotta save them O(1)s...
|
||||||
|
sudo_cmd=""
|
||||||
|
((EUID)) && [[ -z "$ANDROID_ROOT" ]] && sudo_cmd="sudo"
|
||||||
|
|
||||||
NO_FAIL2BAN=${1}
|
NO_FAIL2BAN=${1}
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -14,24 +18,23 @@ echo " * wget"
|
||||||
echo " * curl"
|
echo " * curl"
|
||||||
echo " * pkg-config"
|
echo " * pkg-config"
|
||||||
echo " * node"
|
echo " * node"
|
||||||
echo " * iojs"
|
|
||||||
echo " * jshint"
|
echo " * jshint"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
echo "updating apt-get..."
|
echo "updating apt-get..."
|
||||||
sudo bash -c "apt-get update -qq -y < /dev/null" > /dev/null
|
$sudo_cmd bash -c "apt-get update -qq -y < /dev/null" > /dev/null
|
||||||
|
|
||||||
# fail2ban
|
# fail2ban
|
||||||
if [ -z "$(which fail2ban-server | grep fail2ban)" ]; then
|
#if [ -z "$(which fail2ban-server | grep fail2ban)" ]; then
|
||||||
if [ -z "${NO_FAIL2BAN}" ]; then
|
# if [ -z "${NO_FAIL2BAN}" ]; then
|
||||||
echo "installing fail2ban..."
|
# echo "installing fail2ban..."
|
||||||
sudo bash -c "apt-get install -qq -y fail2ban < /dev/null" > /dev/null
|
# sudo bash -c "apt-get install -qq -y fail2ban < /dev/null" > /dev/null
|
||||||
fi
|
# fi
|
||||||
fi
|
#fi
|
||||||
|
|
||||||
# git, wget, curl, build-essential
|
# 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)" ]
|
if [ -z "$(type -p pkg-config)" ] || [ -z "$(type -p git)" ] || [ -z "$(type -p wget)" ] || [ -z "$(type -p curl)" ] || [ -z "$(type -p gcc)" ] || [ -z "$(type -p rsync)" ] || [ -z "$(type -p python)" ]
|
||||||
then
|
then
|
||||||
echo "installing git, wget, curl, build-essential, rsync, pkg-config..."
|
echo "installing git, wget, curl, build-essential, rsync, pkg-config, python..."
|
||||||
sudo bash -c "apt-get install -qq -y git wget curl build-essential rsync pkg-config < /dev/null" > /dev/null 2>/dev/null
|
$sudo_cmd bash -c "apt-get install -qq -y git wget curl build-essential rsync pkg-config python < /dev/null" > /dev/null 2>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
210
setup-min.sh
210
setup-min.sh
|
@ -1,158 +1,33 @@
|
||||||
#!/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://github.com/coolaj86/node-install-script
|
# 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
|
set -e
|
||||||
# wget -nv https://example.com/setup-min.bash -O - | bash
|
set -u
|
||||||
|
|
||||||
NODEJS_NAME="node"
|
BASE_URL="https://git.coolaj86.com/coolaj86/node-installer.sh/raw/master"
|
||||||
NODEJS_BASE_URL="https://nodejs.org"
|
|
||||||
BASE_URL="https://raw.githubusercontent.com/coolaj86/node-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 #
|
# Download installers #
|
||||||
#######################
|
#######################
|
||||||
|
|
||||||
echo "Preparing to install io.js (and common development dependencies) for ${OS}" "${ARCH}"
|
INSTALL_FILE_REMOTE="install.sh"
|
||||||
|
INSTALL_FILE="node-installer.sh"
|
||||||
INSTALL_FILE="setup-node-${SETUP_FILE}.bash"
|
|
||||||
if [ ! -e "/tmp/${INSTALL_FILE}" ]
|
if [ ! -e "/tmp/${INSTALL_FILE}" ]
|
||||||
then
|
then
|
||||||
if [ -n "$(which curl)" ]; then
|
if [ -n "$(which curl)" ]; then
|
||||||
curl --silent "${BASE_URL}/${INSTALL_FILE}" \
|
curl --silent -L "${BASE_URL}/${INSTALL_FILE_REMOTE}" \
|
||||||
-o "/tmp/${INSTALL_FILE}" || echo 'error downloading os setup script'
|
-o "/tmp/${INSTALL_FILE}" || echo 'error setup script: '"${BASE_URL}/${INSTALL_FILE_REMOTE}"
|
||||||
elif [ -n "$(which wget)" ]; then
|
elif [ -n "$(which wget)" ]; then
|
||||||
wget --quiet "${BASE_URL}/${INSTALL_FILE}" \
|
wget --quiet "${BASE_URL}/${INSTALL_FILE_REMOTE}" \
|
||||||
-O "/tmp/${INSTALL_FILE}" || echo 'error downloading os setup script'
|
-O "/tmp/${INSTALL_FILE}" || echo 'error setup script: '"${BASE_URL}/${INSTALL_FILE_REMOTE}"
|
||||||
else
|
else
|
||||||
echo "Found neither 'curl' nor 'wget'. Can't Continue."
|
echo "Found neither 'curl' nor 'wget'. Can't Continue."
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -165,62 +40,5 @@ then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#########################
|
|
||||||
# Which io.js VERSION ? #
|
|
||||||
#########################
|
|
||||||
|
|
||||||
if [ -f "/tmp/NODEJS_VER" ]; then
|
bash "/tmp/${INSTALL_FILE}" --no-dev-deps
|
||||||
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 -fsL "$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 ""
|
|
||||||
|
|
|
@ -1,3 +1,22 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -u
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
if [ -z "${my_tmp-}" ]; then
|
||||||
|
my_tmp=$(mkdir -p)
|
||||||
|
fi
|
||||||
|
if [ -z "${PREFIX-}" ]; then
|
||||||
|
PREFIX=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${NODE_PATH-}" ]; then
|
||||||
|
node_install_path=$PREFIX/usr/local
|
||||||
|
else
|
||||||
|
node_install_path=$(dirname $(dirname $NODE_PATH))
|
||||||
|
fi
|
||||||
|
|
||||||
NODEJS_VER=${1}
|
NODEJS_VER=${1}
|
||||||
NODEJS_VERT=$(echo ${NODEJS_VER} | cut -c 2- | cut -d '.' -f1)
|
NODEJS_VERT=$(echo ${NODEJS_VER} | cut -c 2- | cut -d '.' -f1)
|
||||||
|
|
||||||
|
@ -12,14 +31,30 @@ then
|
||||||
NODEJS_NAME="iojs"
|
NODEJS_NAME="iojs"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NODEJS_REMOTE="$NODEJS_BASE_URL/dist/${NODEJS_VER}/${NODEJS_NAME}-${NODEJS_VER}.pkg"
|
# When using .pkg
|
||||||
NODEJS_PKG="/tmp/${NODEJS_NAME}-${NODEJS_VER}.pkg"
|
#NODEJS_REMOTE="$NODEJS_BASE_URL/dist/${NODEJS_VER}/${NODEJS_NAME}-${NODEJS_VER}.pkg"
|
||||||
|
#NODEJS_PKG="/tmp/${NODEJS_NAME}-${NODEJS_VER}.pkg"
|
||||||
|
|
||||||
|
NODEJS_REMOTE="$NODEJS_BASE_URL/dist/${NODEJS_VER}/${NODEJS_NAME}-${NODEJS_VER}-darwin-x64.tar.gz"
|
||||||
|
NODEJS_PKG="$my_tmp/${NODEJS_NAME}-${NODEJS_VER}-darwin-x64.tar.gz"
|
||||||
|
NODEJS_UNTAR="$my_tmp/${NODEJS_NAME}-${NODEJS_VER}-darwin-x64"
|
||||||
|
|
||||||
if [ -n "${NODEJS_VER}" ]; then
|
if [ -n "${NODEJS_VER}" ]; then
|
||||||
echo "installing ${NODEJS_NAME} as ${NODEJS_NAME} ${NODEJS_VER}..."
|
echo "installing ${NODEJS_NAME} as ${NODEJS_NAME} ${NODEJS_VER}..."
|
||||||
curl -fsSL "${NODEJS_REMOTE}" -o "${NODEJS_PKG}"
|
curl -fsSL "${NODEJS_REMOTE}" -o "${NODEJS_PKG}"
|
||||||
sudo /usr/sbin/installer -pkg "${NODEJS_PKG}" -target /
|
|
||||||
|
|
||||||
sudo chown -R $(whoami) /usr/local/lib/node_modules/
|
# When using .pkg
|
||||||
sudo chown $(whoami) /usr/local/bin/
|
#sudo /usr/sbin/installer -pkg "${NODEJS_PKG}" -target /
|
||||||
|
|
||||||
|
# When using .tar.gz
|
||||||
|
mkdir -p ${NODEJS_UNTAR}/
|
||||||
|
tar xf "${NODEJS_PKG}" -C "${NODEJS_UNTAR}/" --strip-components=1
|
||||||
|
rm -f ${NODEJS_UNTAR}/{LICENSE,CHANGELOG.md,README.md}
|
||||||
|
|
||||||
|
mkdir -p "$node_install_path/" || sudo mkdir -p "$node_install_path/"
|
||||||
|
rsync -a "${NODEJS_UNTAR}/" "$node_install_path/" || sudo rsync -a "${NODEJS_UNTAR}/" "$node_install_path/"
|
||||||
|
|
||||||
|
|
||||||
|
chown -R $(whoami) "$node_install_path/lib/node_modules/" || sudo chown -R $(whoami) "$node_install_path/lib/node_modules/"
|
||||||
|
chown $(whoami) "$node_install_path/bin/" || sudo chown $(whoami) "$node_install_path/bin/"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,3 +1,26 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Not every platform has or needs sudo, gotta save them O(1)s...
|
||||||
|
sudo_cmd=""
|
||||||
|
((EUID)) && [[ -z "${ANDROID_ROOT:-}" ]] && sudo_cmd="sudo"
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -u
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
if [ -z "${my_tmp-}" ]; then
|
||||||
|
my_tmp="$(mktemp -d -t node-installer.XXXXXXXX)"
|
||||||
|
fi
|
||||||
|
if [ -z "${PREFIX-}" ]; then
|
||||||
|
PREFIX=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${NODE_PATH-}" ]; then
|
||||||
|
node_install_path=$PREFIX/usr/local
|
||||||
|
else
|
||||||
|
node_install_path=$(dirname $(dirname $NODE_PATH))
|
||||||
|
fi
|
||||||
|
|
||||||
NODEJS_VER=${1}
|
NODEJS_VER=${1}
|
||||||
NODEJS_VERT=$(echo ${NODEJS_VER} | cut -c 2- | cut -d '.' -f1)
|
NODEJS_VERT=$(echo ${NODEJS_VER} | cut -c 2- | cut -d '.' -f1)
|
||||||
|
|
||||||
|
@ -11,39 +34,54 @@ then
|
||||||
NODEJS_NAME="iojs"
|
NODEJS_NAME="iojs"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$(arch | grep 64)" ]; then
|
if [ -n "$(uname -a | grep aarch64)" ]; then
|
||||||
|
ARCH="arm64"
|
||||||
|
elif [ -n "$(uname -a | grep 64)" ]; then
|
||||||
ARCH="x64"
|
ARCH="x64"
|
||||||
elif [ -n "$(arch | grep armv7l)" ]; then
|
elif [ -n "$(uname -a | grep armv8l)" ]; then
|
||||||
|
ARCH="arm64"
|
||||||
|
elif [ -n "$(uname -a | grep armv7l)" ]; then
|
||||||
ARCH="armv7l"
|
ARCH="armv7l"
|
||||||
elif [ -n "$(arch | grep armv6l)" ]; then
|
elif [ -n "$(uname -a | grep armv6l)" ]; then
|
||||||
ARCH="armv6l"
|
ARCH="armv6l"
|
||||||
else
|
else
|
||||||
ARCH="x86"
|
ARCH="x86"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NODEJS_REMOTE="${NODEJS_BASE_URL}/dist/${NODEJS_VER}/${NODEJS_NAME}-${NODEJS_VER}-linux-${ARCH}.tar.gz"
|
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_LOCAL="$my_tmp/${NODEJS_NAME}-${NODEJS_VER}-linux-${ARCH}.tar.gz"
|
||||||
NODEJS_UNTAR="/tmp/${NODEJS_NAME}-${NODEJS_VER}-linux-${ARCH}"
|
NODEJS_UNTAR="$my_tmp/${NODEJS_NAME}-${NODEJS_VER}-linux-${ARCH}"
|
||||||
|
|
||||||
if [ -n "${NODEJS_VER}" ]; then
|
if [ -n "${NODEJS_VER}" ]; then
|
||||||
echo "installing ${NODEJS_NAME} as ${NODEJS_NAME} ${NODEJS_VER}..."
|
echo "installing ${NODEJS_NAME} as ${NODEJS_NAME} ${NODEJS_VER}..."
|
||||||
|
|
||||||
if [ -n "$(which curl 2>/dev/null)" ]; then
|
if [ -n "$(command -v curl 2>/dev/null | grep curl)" ]; then
|
||||||
curl -fsSL ${NODEJS_REMOTE} -o ${NODEJS_LOCAL} || echo 'error downloading ${NODEJS_NAME}'
|
curl -fsSL ${NODEJS_REMOTE} -o ${NODEJS_LOCAL} || echo 'error downloading ${NODEJS_NAME}'
|
||||||
elif [ -n "$(which wget 2>/dev/null)" ]; then
|
elif [ -n "$(command -v wget 2>/dev/null | grep wget)" ]; then
|
||||||
wget --quiet ${NODEJS_REMOTE} -O ${NODEJS_LOCAL} || echo 'error downloading ${NODEJS_NAME}'
|
wget --quiet ${NODEJS_REMOTE} -O ${NODEJS_LOCAL} || echo 'error downloading ${NODEJS_NAME}'
|
||||||
else
|
else
|
||||||
echo "'wget' and 'curl' are missing. Please run the following command and try again"
|
echo "'wget' and 'curl' are missing. Please run the following command and try again"
|
||||||
echo "\tsudo apt-get install --yes curl wget"
|
echo " sudo apt-get install --yes curl wget"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p ${NODEJS_UNTAR}/
|
mkdir -p ${NODEJS_UNTAR}/
|
||||||
tar xf ${NODEJS_LOCAL} -C ${NODEJS_UNTAR}/ --strip-components=1
|
# --strip-components isn't portable, switch to portable version by performing move step after untar
|
||||||
|
tar xf ${NODEJS_LOCAL} -C ${NODEJS_UNTAR}/ #--strip-components=1
|
||||||
|
mv ${NODEJS_UNTAR}/${NODEJS_NAME}-${NODEJS_VER}-linux-${ARCH}/* ${NODEJS_UNTAR}/
|
||||||
|
rm -rf ${NODEJS_UNTAR}/${NODEJS_NAME}-${NODEJS_VER}-linux-${ARCH} # clean up the temporary unzip folder
|
||||||
rm ${NODEJS_UNTAR}/{LICENSE,CHANGELOG.md,README.md}
|
rm ${NODEJS_UNTAR}/{LICENSE,CHANGELOG.md,README.md}
|
||||||
sudo rsync -a "${NODEJS_UNTAR}/" /usr/local/
|
if [ -n "$(command -v rsync 2>/dev/null | grep rsync)" ]; then
|
||||||
|
echo $sudo_cmd rsync -Krl "${NODEJS_UNTAR}/" "$node_install_path/"
|
||||||
|
rsync -Krl "${NODEJS_UNTAR}/" "$node_install_path/" 2>/dev/null || $sudo_cmd rsync -Krl "${NODEJS_UNTAR}/" "$node_install_path/"
|
||||||
|
else
|
||||||
|
# due to symlink issues on Arch Linux, don't copy the share directory
|
||||||
|
rm -rf ${NODEJS_UNTAR}/share
|
||||||
|
echo $sudo_cmd cp -Hr "${NODEJS_UNTAR}/*" "$node_install_path/"
|
||||||
|
cp -Hr "${NODEJS_UNTAR}"/* "$node_install_path/" 2>/dev/null || $sudo_cmd cp -Hr "${NODEJS_UNTAR}"/* "$node_install_path/"
|
||||||
|
fi
|
||||||
|
rm -rf "${NODEJS_UNTAR}"
|
||||||
|
|
||||||
|
chown -R $(whoami) "$node_install_path/lib/node_modules/" 2>/dev/null || $sudo_cmd chown -R $(whoami) "$node_install_path/lib/node_modules/"
|
||||||
sudo chown -R $(whoami) /usr/local/lib/node_modules/
|
chown $(whoami) ""$node_install_path"/bin/" 2>/dev/null || $sudo_cmd chown $(whoami) ""$node_install_path"/bin/"
|
||||||
sudo chown $(whoami) /usr/local/bin/
|
|
||||||
fi
|
fi
|
||||||
|
|
263
setup.bash
263
setup.bash
|
@ -3,279 +3,42 @@
|
||||||
# Installs node.js + dependencies for both Ubuntu and OS X
|
# Installs node.js + dependencies for both Ubuntu and OS X
|
||||||
|
|
||||||
#
|
#
|
||||||
# See https://github.com/coolaj86/node-install-script
|
# See https://git.colaj86.com/coolaj86/node-installer.sh
|
||||||
#
|
#
|
||||||
|
|
||||||
# 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
|
||||||
|
|
||||||
NODEJS_NAME="node"
|
set -e
|
||||||
NODEJS_BASE_URL="https://nodejs.org"
|
set -u
|
||||||
BASE_URL="https://raw.githubusercontent.com/coolaj86/node-install-script/master"
|
|
||||||
NO_FAIL2BAN=""
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BASE_URL="https://git.coolaj86.com/coolaj86/node-installer.sh/raw/master"
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# Download installers #
|
# Download installers #
|
||||||
#######################
|
#######################
|
||||||
|
|
||||||
echo "Preparing to install ${NODEJS_NAME} (and common development dependencies) for ${OS}" "${ARCH}"
|
INSTALL_FILE_REMOTE="install.sh"
|
||||||
|
INSTALL_FILE="node-installer.sh"
|
||||||
INSTALL_DEPS_FILE="setup-deps-${SETUP_FILE}.bash"
|
if [ ! -e "/tmp/${INSTALL_FILE}" ]
|
||||||
INSTALL_FILE="setup-node-${SETUP_FILE}.bash"
|
|
||||||
if [ ! -e "/tmp/${INSTALL_DEPS_FILE}" ]
|
|
||||||
then
|
then
|
||||||
if [ -n "$(which curl)" ]; then
|
if [ -n "$(which curl)" ]; then
|
||||||
curl --silent "${BASE_URL}/${INSTALL_DEPS_FILE}" \
|
curl --silent -L "${BASE_URL}/${INSTALL_FILE_REMOTE}" \
|
||||||
-o "/tmp/${INSTALL_DEPS_FILE}" || echo 'error downloading os deps script: '"${BASE_URL}/${INSTALL_DEPS_FILE}"
|
-o "/tmp/${INSTALL_FILE}" || echo 'error setup script: '"${BASE_URL}/${INSTALL_FILE_REMOTE}"
|
||||||
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
|
elif [ -n "$(which wget)" ]; then
|
||||||
wget --quiet "${BASE_URL}/${INSTALL_DEPS_FILE}" \
|
wget --quiet "${BASE_URL}/${INSTALL_FILE_REMOTE}" \
|
||||||
-O "/tmp/${INSTALL_DEPS_FILE}" || echo 'error downloading os deps script: '"${BASE_URL}/${INSTALL_DEPS_FILE}"
|
-O "/tmp/${INSTALL_FILE}" || echo 'error setup script: '"${BASE_URL}/${INSTALL_FILE_REMOTE}"
|
||||||
wget --quiet "${BASE_URL}/${INSTALL_FILE}" \
|
|
||||||
-O "/tmp/${INSTALL_FILE}" || echo 'error downloading os setup script: '"${BASE_URL}/${INSTALL_FILE}"
|
|
||||||
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 [ ! -e "/tmp/${INSTALL_DEPS_FILE}" ]
|
if [ ! -e "/tmp/${INSTALL_FILE}" ]
|
||||||
then
|
then
|
||||||
echo "Error Downloading Install File"
|
echo "Error Downloading Install File"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
################
|
bash "/tmp/${INSTALL_FILE}"
|
||||||
# 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}"
|
|
||||||
|
|
||||||
#########################
|
|
||||||
# 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 -fsL "$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
|
|
||||||
if [ -z "$(which jshint | grep jshint)" ]; then
|
|
||||||
echo "installing jshint..."
|
|
||||||
npm install --silent jshint -g > /dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
|
|
Loading…
Reference in New Issue