only sudo as fallback, use mktemp -d
This commit is contained in:
parent
a443dd04d3
commit
bad41027ad
30
install.sh
30
install.sh
|
@ -33,6 +33,8 @@ NO_FAIL2BAN="nope"
|
||||||
OS="unsupported"
|
OS="unsupported"
|
||||||
ARCH=""
|
ARCH=""
|
||||||
SETUP_FILE=""
|
SETUP_FILE=""
|
||||||
|
my_tmp=$(mktemp -d)
|
||||||
|
export my_tmp
|
||||||
|
|
||||||
clear
|
clear
|
||||||
|
|
||||||
|
@ -179,13 +181,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 +195,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 +209,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 +229,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
|
||||||
|
|
||||||
|
@ -292,10 +294,10 @@ if [ -e "$node_install_path/bin/node" ]; then
|
||||||
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
|
chown -R $(whoami) $node_install_path/lib/node_modules || $sudo_cmd chown -R $(whoami) $node_install_path/lib/node_modules
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
@ -339,7 +341,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
|
||||||
|
|
|
@ -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,23 +36,25 @@ 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}..."
|
||||||
curl -fsSL "${NODEJS_REMOTE}" -o "${NODEJS_PKG}"
|
curl -fsSL "${NODEJS_REMOTE}" -o "${NODEJS_PKG}"
|
||||||
|
|
||||||
# When using .pkg
|
# When using .pkg
|
||||||
#sudo /usr/sbin/installer -pkg "${NODEJS_PKG}" -target /
|
#sudo /usr/sbin/installer -pkg "${NODEJS_PKG}" -target /
|
||||||
|
|
||||||
# When using .tar.gz
|
# When using .tar.gz
|
||||||
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/"
|
||||||
sudo chown -R $(whoami) "$node_install_path/lib/node_modules/"
|
rsync -a "${NODEJS_UNTAR}/" "$node_install_path/" || sudo rsync -a "${NODEJS_UNTAR}/" "$node_install_path/"
|
||||||
sudo chown $(whoami) "$node_install_path/bin/"
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
|
@ -8,6 +8,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
|
||||||
|
@ -46,8 +49,8 @@ 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}..."
|
||||||
|
@ -58,7 +61,7 @@ if [ -n "${NODEJS_VER}" ]; 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
|
||||||
|
|
||||||
|
@ -69,9 +72,9 @@ if [ -n "${NODEJS_VER}" ]; then
|
||||||
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/"
|
echo $sudo_cmd rsync -a "${NODEJS_UNTAR}/" "$node_install_path/"
|
||||||
$sudo_cmd rsync -a "${NODEJS_UNTAR}/" "$node_install_path/"
|
rsync -a "${NODEJS_UNTAR}/" "$node_install_path/" || $sudo_cmd rsync -a "${NODEJS_UNTAR}/" "$node_install_path/"
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue