Compare commits
78 Commits
v1.1.1-wip
...
master
Author | SHA1 | Date | |
---|---|---|---|
a431978582 | |||
6c3fa218ba | |||
79d4d239ad | |||
60f206373c | |||
22c741817c | |||
1f3a195fe9 | |||
c3890ca8a9 | |||
689fa58531 | |||
895dcd31f2 | |||
b8acbae85f | |||
509ee32688 | |||
3109f4bb94 | |||
05199bcf82 | |||
1387929dfc | |||
c15264b763 | |||
8be0a29b7d | |||
972d510f59 | |||
92ec7ad5b6 | |||
95c0caf4be | |||
ed24276356 | |||
dddf31db8d | |||
a1af3328cb | |||
515bdce8c2 | |||
4ea01c4c42 | |||
45adb12ae1 | |||
0d6e15ee62 | |||
8a14fc8ede | |||
2309008c5f | |||
f2a8c2fc49 | |||
b562d6dd3b | |||
bad41027ad | |||
5f231f9d22 | |||
0171162f20 | |||
3ced314799 | |||
00c986e483 | |||
97c7ef9793 | |||
c747edb99a | |||
62bc523d03 | |||
82e6ace060 | |||
748c51a687 | |||
0c7d0a7da6 | |||
be9344dbea | |||
2d628014d0 | |||
17c0b01ee0 | |||
e436cdb64d | |||
|
a443dd04d3 | ||
|
5af26c6c86 | ||
|
a9e1370b58 | ||
|
1edc07515f | ||
1a7d21b850 | |||
|
7809937d74 | ||
|
3adefcc4a8 | ||
|
ae2511f592 | ||
08002c572a | |||
|
3e7745177f | ||
|
5d39eef143 | ||
|
90cdb8f93e | ||
|
ccb1487b36 | ||
|
e9c21e3063 | ||
d3069471e7 | |||
|
aed892007f | ||
|
6252737cc1 | ||
|
2f9f3c0c82 | ||
|
a24f92df98 | ||
|
351056f9bc | ||
|
28c1ad8484 | ||
|
ae331149f7 | ||
|
16a6d7e18c | ||
|
6c0afe6488 | ||
|
31b92cdadb | ||
|
561a2e2fa1 | ||
|
8a5593363d | ||
|
69bc78680d | ||
|
8a3f4ba77f | ||
|
a99583fb1d | ||
|
0948a728c3 | ||
|
fb0a8f6372 | ||
|
de522df09b |
140
README.md
140
README.md
@ -1,64 +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
|
||||||
|
|
||||||
| Sponsored by [Daplie](https://daplie.com) |
|
| A [Root](https://rootprojects.org) Project |
|
||||||
|
|
||||||
Automated node.js installers for OS X and Ubuntu
|
Simple node.js installer for macOS and Linux
|
||||||
|
|
||||||
**node.js only** (no dev tools)
|
## QuickStart
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# install node.js without development dependencies
|
curl -fsL bit.ly/node-installer | bash
|
||||||
curl -fsSL bit.ly/node-installer | bash -s --no-dev-deps
|
|
||||||
|
|
||||||
# using wget instead of curl (Ubuntu)
|
|
||||||
wget -nv bit.ly/node-installer -O - | bash -s --no-dev-deps
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**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 -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
|
|
||||||
```
|
|
||||||
|
|
||||||
*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
|
||||||
|
|
||||||
[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 v8.9.0 and v9.0.0
|
curl -fsSL https://bit.ly/node-installer | bash
|
||||||
echo "v8.9.0" > /tmp/NODEJS_VER
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Choosing an install location
|
### Location
|
||||||
|
|
||||||
Just set BOTH `NODE_PATH` and `NPM_CONFIG_PREFIX`.
|
By default node will be installed to `/usr/local`, without root if possible.
|
||||||
The install path will be the preceding `lib/node_modules`
|
|
||||||
(which you usually want to be the same as `NPM_CONFIG_PREFIIX` anyway).
|
You can choose a specific location by setting **both** `NPM_CONFIG_PREFIX` **and** `NODE_PATH`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export NPM_CONFIG_PREFIX=/tmp/user/local
|
export NPM_CONFIG_PREFIX=$HOME/.local
|
||||||
export NODE_PATH=/tmp/user/local/lib/node_modules
|
export NODE_PATH=$NPM_CONFIG_PREFIX/lib/node_modules
|
||||||
|
curl -fsSL https://bit.ly/node-installer | bash
|
||||||
curl -fsSL bit.ly/node-installer -o ./node-installer.sh; bash ./node-installer.sh --dev-deps
|
|
||||||
|
|
||||||
# If you want to add the install location to your PATH
|
|
||||||
PATH=$PATH:/tmp/user/local/bin
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
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)
|
||||||
@ -86,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/node-installer -o /tmp/node-installer.sh; bash /tmp/node-installer.sh --dev-deps
|
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?)
|
||||||
@ -94,21 +135,20 @@ curl -fsSL bit.ly/node-installer -o /tmp/node-installer.sh; bash /tmp/node-insta
|
|||||||
### Ubuntu Linux
|
### Ubuntu Linux
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
wget -nv bit.ly/node-installer -O /tmp/node-installer.sh; bash /tmp/node-installer.sh --dev-deps
|
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 you're running a node.js server on an edge server,
|
```bash
|
||||||
I'd highly recommend that you also install `fail2ban` to secure ssh -
|
BASE_VER="v10\\."
|
||||||
especially if you haven't switched your server to use key-only authentication.
|
NODE_VERSION=$(curl -fsSL https://nodejs.org/dist/index.tab | tail -n +2 | cut -f 1 | grep $BASE_VER | head -1 )
|
||||||
|
echo "Latest node.js $BASE_VER is $NODE_VERSION"
|
||||||
|
```
|
144
install.sh
144
install.sh
@ -12,6 +12,10 @@
|
|||||||
# curl -fsSL https://example.com/setup-min.bash | bash
|
# curl -fsSL https://example.com/setup-min.bash | bash
|
||||||
# wget -nv https://example.com/setup-min.bash -O - | 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"
|
deps_flag="$1"
|
||||||
set -e
|
set -e
|
||||||
set -u
|
set -u
|
||||||
@ -28,8 +32,9 @@ BASE_URL="https://git.coolaj86.com/coolaj86/node-installer.sh/raw/master"
|
|||||||
NO_FAIL2BAN="nope"
|
NO_FAIL2BAN="nope"
|
||||||
OS="unsupported"
|
OS="unsupported"
|
||||||
ARCH=""
|
ARCH=""
|
||||||
NODEJS_VER=""
|
|
||||||
SETUP_FILE=""
|
SETUP_FILE=""
|
||||||
|
my_tmp="$(mktemp -d -t node-installer.XXXXXXXX)"
|
||||||
|
export my_tmp
|
||||||
|
|
||||||
clear
|
clear
|
||||||
|
|
||||||
@ -51,37 +56,38 @@ if [ "$(uname | grep -i 'Darwin')" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$OSX_MAJOR" -gt 10 ]; then
|
# Mavericks+ works for all current macOS versions
|
||||||
echo "unsupported OS X version (os 11+)"
|
OS='mavericks'
|
||||||
exit 1
|
|
||||||
|
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
|
fi
|
||||||
|
|
||||||
#
|
# OS X (10) and macOS (11) should be supported
|
||||||
# Minor
|
|
||||||
#
|
|
||||||
if [ "$OSX_MINOR" -le 5 ]; then
|
|
||||||
echo "unsupported OS X version (os 10.5-)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Snow
|
if [ "$OSX_MAJOR" -gt 11 ]; then
|
||||||
if [ "$OSX_MINOR" -eq 6 ]; then
|
echo "WARNING: macOS 12+ may or may not be supported"
|
||||||
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
|
fi
|
||||||
|
|
||||||
if [ -n "$(sysctl hw | grep 64bit | grep ': 1')" ]; then
|
if [ -n "$(sysctl hw | grep 64bit | grep ': 1')" ]; then
|
||||||
@ -95,7 +101,7 @@ elif [ "$(uname | grep -i 'Linux')" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$(arch | grep 64)" ]; then
|
if [ -n "$(uname -a | grep 64)" ]; then
|
||||||
ARCH="64"
|
ARCH="64"
|
||||||
else
|
else
|
||||||
ARCH="32"
|
ARCH="32"
|
||||||
@ -107,6 +113,8 @@ elif [ "$(uname | grep -i 'Linux')" ]; then
|
|||||||
OS='ubuntu'
|
OS='ubuntu'
|
||||||
elif [ "$(cat /etc/issue | grep -i 'elementary OS')" ]; then
|
elif [ "$(cat /etc/issue | grep -i 'elementary OS')" ]; then
|
||||||
OS='ubuntu'
|
OS='ubuntu'
|
||||||
|
elif [ "$(cat /etc/issue | grep -i 'Arch ')" ]; then
|
||||||
|
OS='ubuntu'
|
||||||
elif [ "$(cat /etc/issue | grep -i 'Debian')" ]; then
|
elif [ "$(cat /etc/issue | grep -i 'Debian')" ]; then
|
||||||
OS='ubuntu'
|
OS='ubuntu'
|
||||||
elif [ "$(cat /etc/issue | grep -i 'Trisquel')" ]; then
|
elif [ "$(cat /etc/issue | grep -i 'Trisquel')" ]; then
|
||||||
@ -116,11 +124,15 @@ elif [ "$(uname | grep -i 'Linux')" ]; then
|
|||||||
elif [ "$(cat /etc/issue | grep -i 'Raspbian')" ]; then
|
elif [ "$(cat /etc/issue | grep -i 'Raspbian')" ]; then
|
||||||
OS='raspbian'
|
OS='raspbian'
|
||||||
elif [ "$(cat /etc/issue | grep -i 'Fedora')" ]; then
|
elif [ "$(cat /etc/issue | grep -i 'Fedora')" ]; then
|
||||||
OS='fedora'
|
OS='ubuntu'
|
||||||
|
elif [ "$(cat /etc/issue | grep -i 'Marvell')" ]; then
|
||||||
|
OS='marvell'
|
||||||
|
else
|
||||||
|
OS='ubuntu'
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "unsupported unknown os (non-mac, non-linux)"
|
echo "unsupported unknown os (non-mac, non-linux)"
|
||||||
exit 1
|
exit 500
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "${OS}" in
|
case "${OS}" in
|
||||||
@ -134,6 +146,9 @@ case "${OS}" in
|
|||||||
raspbian)
|
raspbian)
|
||||||
SETUP_FILE="ubuntu"
|
SETUP_FILE="ubuntu"
|
||||||
;;
|
;;
|
||||||
|
marvell)
|
||||||
|
SETUP_FILE="ubuntu"
|
||||||
|
;;
|
||||||
yosemite)
|
yosemite)
|
||||||
# mavericks
|
# mavericks
|
||||||
SETUP_FILE="mavericks"
|
SETUP_FILE="mavericks"
|
||||||
@ -171,13 +186,13 @@ fi
|
|||||||
|
|
||||||
INSTALL_DEPS_FILE="setup-deps-${SETUP_FILE}.bash"
|
INSTALL_DEPS_FILE="setup-deps-${SETUP_FILE}.bash"
|
||||||
INSTALL_FILE="setup-node-${SETUP_FILE}.bash"
|
INSTALL_FILE="setup-node-${SETUP_FILE}.bash"
|
||||||
if [ ! -e "/tmp/${INSTALL_FILE}" ]; then
|
if [ ! -e "$my_tmp/${INSTALL_FILE}" ]; then
|
||||||
if [ -n "$(type -p curl)" ]; then
|
if [ -n "$(type -p curl)" ]; then
|
||||||
curl --silent -L "${BASE_URL}/${INSTALL_FILE}" \
|
curl --silent -L "${BASE_URL}/${INSTALL_FILE}" \
|
||||||
-o "/tmp/${INSTALL_FILE}" || echo 'error downloading os setup script'
|
-o "$my_tmp/${INSTALL_FILE}" || echo 'error downloading os setup script'
|
||||||
elif [ -n "$(type -p wget)" ]; then
|
elif [ -n "$(type -p wget)" ]; then
|
||||||
wget --quiet "${BASE_URL}/${INSTALL_FILE}" \
|
wget --quiet "${BASE_URL}/${INSTALL_FILE}" \
|
||||||
-O "/tmp/${INSTALL_FILE}" || echo 'error downloading os setup script'
|
-O "$my_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
|
||||||
@ -185,13 +200,13 @@ if [ ! -e "/tmp/${INSTALL_FILE}" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "--dev-deps" == "$deps_flag" ]; then
|
if [ "--dev-deps" == "$deps_flag" ]; then
|
||||||
if [ ! -e "/tmp/${INSTALL_DEPS_FILE}" ]; then
|
if [ ! -e "$my_tmp/${INSTALL_DEPS_FILE}" ]; then
|
||||||
if [ -n "$(type -p curl)" ]; then
|
if [ -n "$(type -p curl)" ]; then
|
||||||
curl --silent -L "${BASE_URL}/${INSTALL_DEPS_FILE}" \
|
curl --silent -L "${BASE_URL}/${INSTALL_DEPS_FILE}" \
|
||||||
-o "/tmp/${INSTALL_DEPS_FILE}" || echo 'error downloading os deps script: '"${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
|
elif [ -n "$(type -p wget)" ]; then
|
||||||
wget --quiet "${BASE_URL}/${INSTALL_DEPS_FILE}" \
|
wget --quiet "${BASE_URL}/${INSTALL_DEPS_FILE}" \
|
||||||
-O "/tmp/${INSTALL_DEPS_FILE}" || echo 'error downloading os deps script: '"${BASE_URL}/${INSTALL_DEPS_FILE}"
|
-O "$my_tmp/${INSTALL_DEPS_FILE}" || echo 'error downloading os deps script: '"${BASE_URL}/${INSTALL_DEPS_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
|
||||||
@ -199,14 +214,14 @@ if [ "--dev-deps" == "$deps_flag" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -e "/tmp/${INSTALL_FILE}" ]
|
if [ ! -e "$my_tmp/${INSTALL_FILE}" ]
|
||||||
then
|
then
|
||||||
echo "Error Downloading Install File"
|
echo "Error Downloading Install File"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "--dev-deps" == "$deps_flag" ]; then
|
if [ "--dev-deps" == "$deps_flag" ]; then
|
||||||
if [ ! -e "/tmp/${INSTALL_DEPS_FILE}" ]
|
if [ ! -e "$my_tmp/${INSTALL_DEPS_FILE}" ]
|
||||||
then
|
then
|
||||||
echo "Error Downloading Deps File"
|
echo "Error Downloading Deps File"
|
||||||
exit 1
|
exit 1
|
||||||
@ -217,13 +232,22 @@ fi
|
|||||||
# Which node.js VERSION ? #
|
# Which node.js VERSION ? #
|
||||||
#########################
|
#########################
|
||||||
|
|
||||||
if [ -f "/tmp/NODEJS_VER" ]; then
|
NODE_VERSION=${NODE_VERSION:-}
|
||||||
NODEJS_VER=$(cat /tmp/NODEJS_VER | grep v)
|
NODEJS_VER=${NODEJS_VER:-}
|
||||||
elif [ -f "/tmp/IOJS_VER" ]; then
|
if [ -n "$NODE_VERSION" ]; then
|
||||||
NODEJS_VER=$(cat /tmp/IOJS_VER | grep v)
|
NODEJS_VER=$NODE_VERSION
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$NODEJS_VER" ]; then
|
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)
|
NODEJS_VERT=$(echo ${NODEJS_VER} | cut -c 2- | cut -d '.' -f1)
|
||||||
|
|
||||||
if [ $NODEJS_VERT -ge 1 ] && [ $NODEJS_VERT -lt 4 ]
|
if [ $NODEJS_VERT -ge 1 ] && [ $NODEJS_VERT -lt 4 ]
|
||||||
@ -234,12 +258,23 @@ if [ -n "$NODEJS_VER" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$NODEJS_VER" ]; then
|
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
|
if [ -n "$(type -p curl)" ]; then
|
||||||
NODEJS_VER=$(curl -fsL "$NODEJS_BASE_URL/dist/index.tab" | head -2 | tail -1 | cut -f 1) \
|
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'
|
|| echo 'error automatically determining current node.js version'
|
||||||
elif [ -n "$(type -p wget)" ]; then
|
elif [ -n "$(type -p wget)" ]; then
|
||||||
NODEJS_VER=$(wget --quiet "$NODEJS_BASE_URL/dist/index.tab" -O - | head -2 | tail -1 | cut -f 1) \
|
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'
|
|| echo 'error automatically determining current node.js version'
|
||||||
else
|
else
|
||||||
echo "Found neither 'curl' nor 'wget'. Can't Continue."
|
echo "Found neither 'curl' nor 'wget'. Can't Continue."
|
||||||
@ -267,24 +302,27 @@ if [ -e "$node_install_path/bin/node" ]; then
|
|||||||
# node of some version is already installed
|
# node of some version is already installed
|
||||||
if [ "${NODEJS_VER}" == "$($node_install_path/bin/node -v 2>/dev/null)" ]; then
|
if [ "${NODEJS_VER}" == "$($node_install_path/bin/node -v 2>/dev/null)" ]; then
|
||||||
echo node ${NODEJS_VER} is already installed
|
echo node ${NODEJS_VER} is already installed
|
||||||
|
exit 0
|
||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
echo "HEY, LISTEN:"
|
echo "HEY, LISTEN:"
|
||||||
echo ""
|
echo ""
|
||||||
echo "node.js is already installed as node $($node_install_path/bin/node -v | grep v)"
|
echo "node.js is already installed as node $($node_install_path/bin/node -v | grep v)"
|
||||||
echo ""
|
echo ""
|
||||||
echo "to reinstall please first run: rm $node_install_path/bin/node"
|
echo "to reinstall as ${NODEJS_VER} please first run: rm $node_install_path/bin/node"
|
||||||
echo ""
|
echo ""
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NODEJS_VER=""
|
NODEJS_VER=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "${NODEJS_VER}" ]; then
|
if [ -n "${NODEJS_VER}" ]; then
|
||||||
bash "/tmp/${INSTALL_FILE}" "${NODEJS_VER}"
|
bash "$my_tmp/${INSTALL_FILE}" "${NODEJS_VER}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo chown -R $(whoami) $node_install_path/lib/node_modules
|
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 ""
|
echo ""
|
||||||
|
|
||||||
@ -328,7 +366,7 @@ if [ "--dev-deps" == "$deps_flag" ]; then
|
|||||||
# fi
|
# fi
|
||||||
#fi
|
#fi
|
||||||
|
|
||||||
bash "/tmp/${INSTALL_DEPS_FILE}" "${NO_FAIL2BAN}"
|
bash "$my_tmp/${INSTALL_DEPS_FILE}" "${NO_FAIL2BAN}"
|
||||||
|
|
||||||
# yarn
|
# yarn
|
||||||
#if [ -z "$(type -p yarn)" ]; then
|
#if [ -z "$(type -p yarn)" ]; then
|
||||||
@ -345,3 +383,5 @@ if [ "--dev-deps" == "$deps_flag" ]; then
|
|||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
rm -rf "$my_tmp"
|
@ -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 ""
|
||||||
@ -18,7 +22,7 @@ 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
|
||||||
@ -32,5 +36,5 @@ sudo bash -c "apt-get update -qq -y < /dev/null" > /dev/null
|
|||||||
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)" ]
|
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, python..."
|
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 python < /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
|
||||||
|
@ -4,6 +4,9 @@ set -e
|
|||||||
set -u
|
set -u
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
|
if [ -z "${my_tmp-}" ]; then
|
||||||
|
my_tmp=$(mkdir -p)
|
||||||
|
fi
|
||||||
if [ -z "${PREFIX-}" ]; then
|
if [ -z "${PREFIX-}" ]; then
|
||||||
PREFIX=""
|
PREFIX=""
|
||||||
fi
|
fi
|
||||||
@ -33,8 +36,8 @@ fi
|
|||||||
#NODEJS_PKG="/tmp/${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_REMOTE="$NODEJS_BASE_URL/dist/${NODEJS_VER}/${NODEJS_NAME}-${NODEJS_VER}-darwin-x64.tar.gz"
|
||||||
NODEJS_PKG="/tmp/${NODEJS_NAME}-${NODEJS_VER}-darwin-x64.tar.gz"
|
NODEJS_PKG="$my_tmp/${NODEJS_NAME}-${NODEJS_VER}-darwin-x64.tar.gz"
|
||||||
NODEJS_UNTAR="/tmp/${NODEJS_NAME}-${NODEJS_VER}-darwin-x64"
|
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}..."
|
||||||
@ -47,9 +50,11 @@ if [ -n "${NODEJS_VER}" ]; then
|
|||||||
mkdir -p ${NODEJS_UNTAR}/
|
mkdir -p ${NODEJS_UNTAR}/
|
||||||
tar xf "${NODEJS_PKG}" -C "${NODEJS_UNTAR}/" --strip-components=1
|
tar xf "${NODEJS_PKG}" -C "${NODEJS_UNTAR}/" --strip-components=1
|
||||||
rm -f ${NODEJS_UNTAR}/{LICENSE,CHANGELOG.md,README.md}
|
rm -f ${NODEJS_UNTAR}/{LICENSE,CHANGELOG.md,README.md}
|
||||||
sudo rsync -a "${NODEJS_UNTAR}/" "$node_install_path/"
|
|
||||||
|
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/"
|
||||||
|
|
||||||
|
|
||||||
sudo chown -R $(whoami) "$node_install_path/lib/node_modules/"
|
chown -R $(whoami) "$node_install_path/lib/node_modules/" || sudo chown -R $(whoami) "$node_install_path/lib/node_modules/"
|
||||||
sudo chown $(whoami) "$node_install_path/bin/"
|
chown $(whoami) "$node_install_path/bin/" || sudo chown $(whoami) "$node_install_path/bin/"
|
||||||
fi
|
fi
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
#!/bin/bash
|
#!/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 -e
|
||||||
set -u
|
set -u
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
|
if [ -z "${my_tmp-}" ]; then
|
||||||
|
my_tmp="$(mktemp -d -t node-installer.XXXXXXXX)"
|
||||||
|
fi
|
||||||
if [ -z "${PREFIX-}" ]; then
|
if [ -z "${PREFIX-}" ]; then
|
||||||
PREFIX=""
|
PREFIX=""
|
||||||
fi
|
fi
|
||||||
@ -27,43 +34,54 @@ then
|
|||||||
NODEJS_NAME="iojs"
|
NODEJS_NAME="iojs"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$(arch | grep aarch64)" ]; then
|
if [ -n "$(uname -a | grep aarch64)" ]; then
|
||||||
ARCH="arm64"
|
ARCH="arm64"
|
||||||
elif [ -n "$(arch | grep 64)" ]; then
|
elif [ -n "$(uname -a | grep 64)" ]; then
|
||||||
ARCH="x64"
|
ARCH="x64"
|
||||||
elif [ -n "$(arch | grep armv8l)" ]; then
|
elif [ -n "$(uname -a | grep armv8l)" ]; then
|
||||||
ARCH="arm64"
|
ARCH="arm64"
|
||||||
elif [ -n "$(arch | grep armv7l)" ]; then
|
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}/" "$node_install_path/"
|
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) "$node_install_path/lib/node_modules/"
|
chown $(whoami) ""$node_install_path"/bin/" 2>/dev/null || $sudo_cmd chown $(whoami) ""$node_install_path"/bin/"
|
||||||
sudo chown $(whoami) ""$node_install_path"/bin/"
|
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user