Compare commits

...

30 Commits

Author SHA1 Message Date
AJ ONeal 8be0a29b7d remove tmpdir on success 2018-07-26 22:10:46 +00:00
AJ ONeal 972d510f59 better tmpdir 2018-07-26 22:08:15 +00:00
AJ ONeal 92ec7ad5b6 use better tmp dir 2018-07-26 22:07:02 +00:00
AJ ONeal 95c0caf4be cleanup 2018-07-26 22:02:16 +00:00
AJ ONeal ed24276356 bugfix for Arch Linux sans rsync 2018-07-26 22:00:40 +00:00
AJ ONeal dddf31db8d do copy links with rsync 2018-07-26 21:48:34 +00:00
AJ ONeal a1af3328cb copy -Hr as best approximation for rsync -Kr 2018-07-26 21:47:05 +00:00
AJ ONeal 515bdce8c2 rsync with -Kr instead of -a to not break symlinks in /usr/local 2018-07-26 21:41:42 +00:00
AJ ONeal 4ea01c4c42 don't include * in quotes 2018-07-26 20:51:20 +00:00
AJ ONeal 45adb12ae1 cp has slightly different symmantecs 2018-07-26 20:49:40 +00:00
AJ ONeal 0d6e15ee62 don't rely on rsync 2018-07-26 20:48:00 +00:00
AJ ONeal 8a14fc8ede assume no dev tools by default 2018-07-26 20:38:51 +00:00
AJ ONeal 2309008c5f failsafe exit if node is installed 2018-06-27 10:20:10 +00:00
AJ ONeal f2a8c2fc49 allow ANDROID_ROOT to be undefined 2018-06-26 05:54:06 +00:00
AJ ONeal b562d6dd3b merge 2018-06-23 16:31:37 -06:00
AJ ONeal bad41027ad only sudo as fallback, use mktemp -d 2018-06-23 16:29:13 -06:00
AJ ONeal 5f231f9d22 set ANDROID_ROOT empty 2018-06-23 05:16:13 +00:00
AJ ONeal 0171162f20 typo fix 2018-06-20 02:11:24 +00:00
AJ ONeal 3ced314799 fix comparison 2018-06-20 02:07:43 +00:00
AJ ONeal 00c986e483 regression fix: allow empty NODEJS_VER 2018-06-20 02:06:38 +00:00
AJ ONeal 97c7ef9793 make sure directory exists before chowning it 2018-06-18 21:40:42 +00:00
AJ ONeal c747edb99a update installer examples 2018-06-14 21:10:05 +00:00
AJ ONeal 62bc523d03 fix #1 typo / misspelling of PREFIX
PREFIX not PREFIIX as per #1
2018-06-05 07:36:21 +00:00
AJ ONeal 82e6ace060 make docs more readable 2018-05-24 21:34:44 +00:00
AJ ONeal 748c51a687 show selecting version in docs 2018-05-24 21:31:04 +00:00
AJ ONeal 0c7d0a7da6 note desired version number when already installed 2018-05-24 21:13:55 +00:00
AJ ONeal be9344dbea match literal '.' for version, not wildcard 2018-05-24 21:12:37 +00:00
AJ ONeal 2d628014d0 tail typo fix 2018-05-24 21:09:02 +00:00
AJ ONeal 17c0b01ee0 unset far typo fix 2018-05-24 21:08:12 +00:00
AJ ONeal e436cdb64d allow use of partial version number i.e. v10 or v10.2 2018-05-24 21:07:04 +00:00
4 changed files with 131 additions and 48 deletions

View File

@ -35,29 +35,75 @@ wget -nv https://bit.ly/node-installer -O - ./node-installer.sh; bash ./node-ins
### Choosing a specific version ### Choosing a specific version
**Latest**
```bash ```bash
echo "Current node.js version is $(curl -fsSL https://nodejs.org/dist/index.tab | head -2 | tail -1 | cut -f 1)" export NODEJS_VER=""
```
**Exact**
```bash
export NODEJS_VER="v10.2.1"
```
**Latest of vX.Y.Z**
```bash
export NODEJS_VER="v8.1"
```
**Latest of vX.YY.Z**
```bash
# latest of v8.11.x
export NODEJS_VER="v8.11"
```
**Latest of vX.Y**
```bash
export NODEJS_VER="v10"
```
Fun FYI, here's how the latest version is determined:
```bash
NODEJS_VER=$(curl -fsSL https://nodejs.org/dist/index.tab | tail -n +2 | cut -f 1 | head -1 )
echo "The current node.js version is $NODEJS_VER"
``` ```
```bash ```bash
# To install a specific version rather than defaulting to latest BASE_VER="v10\\."
# latest version at time of writing are v8.11.1 and v10.1.0 NODEJS_VER=$(curl -fsSL https://nodejs.org/dist/index.tab | tail -n +2 | cut -f 1 | grep $BASE_VER | head -1 )
export NODEJS_VER="v10.1.0" echo "Latest node.js $BASE_VER is $NODEJS_VER"
``` ```
### Choosing an install location ### Choosing an install location
Just set BOTH `NODE_PATH` and `NPM_CONFIG_PREFIX`. Just set BOTH `NODE_PATH` and `NPM_CONFIG_PREFIX`.
The install path will be the preceding `lib/node_modules` The install path will be the preceding `lib/node_modules`
(which you usually want to be the same as `NPM_CONFIG_PREFIIX` anyway). (which you usually want to be the same as `NPM_CONFIG_PREFIX` anyway).
```bash ```bash
export NPM_CONFIG_PREFIX=/tmp/user/local export NPM_CONFIG_PREFIX=/tmp/usr/local
export NODE_PATH=/tmp/user/local/lib/node_modules export NODE_PATH=/tmp/usr/local/lib/node_modules
```
A more realistic example for a self-contained node app:
```bash
export NPM_CONFIG_PREFIX=/opt/my-app
export NODE_PATH=/opt/my-app/lib/node_modules
```
```bash
curl -fsSL https://bit.ly/node-installer -o ./node-installer.sh; bash ./node-installer.sh --dev-deps curl -fsSL https://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 If you want to add the install location to your `PATH`:
```bash
PATH=$PATH:/tmp/user/local/bin PATH=$PATH:/tmp/user/local/bin
``` ```
@ -101,7 +147,7 @@ wget -nv https://bit.ly/node-installer -O /tmp/node-installer.sh; bash /tmp/node
### Other things you should know ### Other things you should know
This is what gets installed: This is what gets installed with the dev dependencies:
* rsync * rsync
* curl * curl

View File

@ -14,7 +14,7 @@
# Not every platform has or needs sudo, gotta save them O(1)s... # Not every platform has or needs sudo, gotta save them O(1)s...
sudo_cmd="" sudo_cmd=""
((EUID)) && [[ -z "$ANDROID_ROOT" ]] && sudo_cmd="sudo" ((EUID)) && [[ -z "${ANDROID_ROOT:-}" ]] && sudo_cmd="sudo"
deps_flag="$1" deps_flag="$1"
set -e set -e
@ -33,6 +33,8 @@ NO_FAIL2BAN="nope"
OS="unsupported" OS="unsupported"
ARCH="" ARCH=""
SETUP_FILE="" SETUP_FILE=""
my_tmp="$(mktemp -d -t node-installer.XXXXXXXX)"
export my_tmp
clear clear
@ -110,6 +112,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
@ -119,13 +123,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 elif [ "$(cat /etc/issue | grep -i 'Marvell')" ]; then
OS='marvell' 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
@ -179,13 +185,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
@ -193,13 +199,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
@ -207,14 +213,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
@ -227,10 +233,10 @@ fi
if [ -z "${NODEJS_VER:-}" ]; then if [ -z "${NODEJS_VER:-}" ]; then
# For backwards compat # For backwards compat
if [ -f "/tmp/NODEJS_VER" ]; then if [ -f "$my_tmp/NODEJS_VER" ]; then
NODEJS_VER=$(cat /tmp/NODEJS_VER | grep v) NODEJS_VER=$(cat $my_tmp/NODEJS_VER | grep v)
elif [ -f "/tmp/IOJS_VER" ]; then elif [ -f "/tmp/IOJS_VER" ]; then
NODEJS_VER=$(cat /tmp/IOJS_VER | grep v) NODEJS_VER=$(cat $my_tmp/IOJS_VER | grep v)
fi fi
fi fi
@ -245,12 +251,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 -n 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 -n 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."
@ -278,24 +295,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_cmd chown -R $(whoami) $node_install_path/lib/node_modules mkdir -p $node_install_path/lib/node_modules || $sudo_cmd mkdir -p $node_install_path/lib/node_modules
chown -R $(whoami) $node_install_path/lib/node_modules || $sudo_cmd chown -R $(whoami) $node_install_path/lib/node_modules
echo "" echo ""
@ -339,7 +359,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
@ -356,3 +376,5 @@ if [ "--dev-deps" == "$deps_flag" ]; then
echo "" echo ""
fi fi
rm -rf "$my_tmp"

View File

@ -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

View File

@ -2,12 +2,15 @@
# Not every platform has or needs sudo, gotta save them O(1)s... # Not every platform has or needs sudo, gotta save them O(1)s...
sudo_cmd="" sudo_cmd=""
((EUID)) && [[ -z "$ANDROID_ROOT" ]] && sudo_cmd="sudo" ((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
@ -46,19 +49,19 @@ else
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
@ -68,10 +71,17 @@ if [ -n "${NODEJS_VER}" ]; then
mv ${NODEJS_UNTAR}/${NODEJS_NAME}-${NODEJS_VER}-linux-${ARCH}/* ${NODEJS_UNTAR}/ 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 -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}
echo $sudo_cmd rsync -a "${NODEJS_UNTAR}/" "$node_install_path/" if [ -n "$(command -v rsync 2>/dev/null | grep rsync)" ]; then
$sudo_cmd rsync -a "${NODEJS_UNTAR}/" "$node_install_path/" echo $sudo_cmd rsync -Krl "${NODEJS_UNTAR}/" "$node_install_path/"
rsync -Krl "${NODEJS_UNTAR}/" "$node_install_path/" || $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/" || $sudo_cmd cp -Hr "${NODEJS_UNTAR}"/* "$node_install_path/"
fi
rm -rf "${NODEJS_UNTAR}" rm -rf "${NODEJS_UNTAR}"
$sudo_cmd chown -R $(whoami) "$node_install_path/lib/node_modules/" chown -R $(whoami) "$node_install_path/lib/node_modules/" || $sudo_cmd chown -R $(whoami) "$node_install_path/lib/node_modules/"
$sudo_cmd chown $(whoami) ""$node_install_path"/bin/" chown $(whoami) ""$node_install_path"/bin/" || $sudo_cmd chown $(whoami) ""$node_install_path"/bin/"
fi fi