forked from coolaj86/node-installer.sh
install io.js if 1 <= x < 4, otherwise install node.js
This commit is contained in:
parent
701513faa9
commit
d8c75b08f4
|
@ -1,11 +1,25 @@
|
|||
IOJS_VER=${1}
|
||||
IOJS_REMOTE="http://iojs.org/dist/${IOJS_VER}/iojs-${IOJS_VER}.pkg"
|
||||
IOJS_PKG="/tmp/iojs-${IOJS_VER}.pkg"
|
||||
NODEJS_VER=${1}
|
||||
NODEJS_VERT=$(echo ${NODEJS_VER} | cut -c 2- | cut -d '.' -f1)
|
||||
|
||||
if [ -n "${IOJS_VER}" ]; then
|
||||
echo "installing io.js as iojs ${IOJS_VER}..."
|
||||
curl -fsSL "${IOJS_REMOTE}" -o "${IOJS_PKG}"
|
||||
sudo /usr/sbin/installer -pkg "${IOJS_PKG}" -target /
|
||||
NODEJS_NAME="node"
|
||||
NODEJS_BASE_URL="https://nodejs.org"
|
||||
|
||||
GE1=$(echo "$NODEJS_VERT>=1" | bc)
|
||||
LT4=$(echo "$NODEJS_VERT<4" | bc)
|
||||
|
||||
if [ "1" -eq $GE1 ] && [ "1" -eq $LT4 ]
|
||||
then
|
||||
NODEJS_BASE_URL="https://iojs.org"
|
||||
NODEJS_NAME="iojs"
|
||||
fi
|
||||
|
||||
NODEJS_REMOTE="$NODEJS_BASE_URL/dist/${NODEJS_VER}/${NODEJS_NAME}-${NODEJS_VER}.pkg"
|
||||
NODEJS_PKG="/tmp/${NODEJS_NAME}-${NODEJS_VER}.pkg"
|
||||
|
||||
if [ -n "${NODEJS_VER}" ]; then
|
||||
echo "installing ${NODEJS_NAME} as ${NODEJS_NAME} ${NODEJS_VER}..."
|
||||
curl -fsSL "${NODEJS_REMOTE}" -o "${NODEJS_PKG}"
|
||||
sudo /usr/sbin/installer -pkg "${NODEJS_PKG}" -target /
|
||||
|
||||
sudo chown -R $(whoami) /usr/local 2>/dev/null
|
||||
fi
|
||||
|
|
|
@ -1,4 +1,17 @@
|
|||
IOJS_VER=${1}
|
||||
NODEJS_VER=${1}
|
||||
NODEJS_VERT=$(echo ${NODEJS_VER} | cut -c 2- | cut -d '.' -f1)
|
||||
|
||||
NODEJS_NAME="node"
|
||||
NODEJS_BASE_URL="https://nodejs.org"
|
||||
|
||||
GE1=$(echo "$NODEJS_VERT>=1" | bc)
|
||||
LT4=$(echo "$NODEJS_VERT<4" | bc)
|
||||
|
||||
if [ "1" -eq $GE1 ] && [ "1" -eq $LT4 ]
|
||||
then
|
||||
NODEJS_BASE_URL="https://iojs.org"
|
||||
NODEJS_NAME="iojs"
|
||||
fi
|
||||
|
||||
if [ -n "$(arch | grep 64)" ]; then
|
||||
ARCH="x64"
|
||||
|
@ -10,26 +23,26 @@ else
|
|||
ARCH="x86"
|
||||
fi
|
||||
|
||||
IOJS_REMOTE="http://iojs.org/dist/${IOJS_VER}/iojs-${IOJS_VER}-linux-${ARCH}.tar.gz"
|
||||
IOJS_LOCAL="/tmp/iojs-${IOJS_VER}-linux-${ARCH}.tar.gz"
|
||||
IOJS_UNTAR="/tmp/iojs-${IOJS_VER}-linux-${ARCH}"
|
||||
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_UNTAR="/tmp/${NODEJS_NAME}-${NODEJS_VER}-linux-${ARCH}"
|
||||
|
||||
if [ -n "${IOJS_VER}" ]; then
|
||||
echo "installing io.js as iojs ${IOJS_VER}..."
|
||||
if [ -n "${NODEJS_VER}" ]; then
|
||||
echo "installing ${NODEJS_NAME} as ${NODEJS_NAME} ${NODEJS_VER}..."
|
||||
|
||||
if [ -n "$(which curl 2>/dev/null)" ]; then
|
||||
curl -fsSL ${IOJS_REMOTE} -o ${IOJS_LOCAL} || echo 'error downloading io.js'
|
||||
curl -fsSL ${NODEJS_REMOTE} -o ${NODEJS_LOCAL} || echo 'error downloading ${NODEJS_NAME}'
|
||||
elif [ -n "$(which wget 2>/dev/null)" ]; then
|
||||
wget --quiet ${IOJS_REMOTE} -O ${IOJS_LOCAL} || echo 'error downloading io.js'
|
||||
wget --quiet ${NODEJS_REMOTE} -O ${NODEJS_LOCAL} || echo 'error downloading ${NODEJS_NAME}'
|
||||
else
|
||||
echo "'wget' and 'curl' are missing. Please run the following command and try again"
|
||||
echo "\tsudo apt-get install --yes curl wget"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tar xf ${IOJS_LOCAL} -C /tmp/
|
||||
rm ${IOJS_UNTAR}/{LICENSE,CHANGELOG.md,README.md}
|
||||
sudo rsync -a "${IOJS_UNTAR}/" /usr/local/
|
||||
tar xf ${NODEJS_LOCAL} -C /tmp/
|
||||
rm ${NODEJS_UNTAR}/{LICENSE,CHANGELOG.md,README.md}
|
||||
sudo rsync -a "${NODEJS_UNTAR}/" /usr/local/
|
||||
|
||||
|
||||
sudo chown -R $(whoami) /usr/local
|
||||
|
|
41
setup-min.sh
41
setup-min.sh
|
@ -12,10 +12,12 @@
|
|||
# curl -fsSL https://example.com/setup-min.bash | bash
|
||||
# wget -nv https://example.com/setup-min.bash -O - | bash
|
||||
|
||||
NODEJS_NAME="node"
|
||||
NODEJS_BASE_URL="https://nodejs.org"
|
||||
BASE_URL="https://raw.githubusercontent.com/coolaj86/iojs-install-script/master"
|
||||
OS="unsupported"
|
||||
ARCH=""
|
||||
IOJS_VER=""
|
||||
NODEJS_VER=""
|
||||
SETUP_FILE=""
|
||||
|
||||
clear
|
||||
|
@ -157,16 +159,31 @@ fi
|
|||
# Which io.js VERSION ? #
|
||||
#########################
|
||||
|
||||
if [ -f "/tmp/IOJS_VER" ]; then
|
||||
IOJS_VER=$(cat /tmp/IOJS_VER | grep v)
|
||||
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 [ -z "$IOJS_VER" ]; then
|
||||
if [ -n "$NODEJS_VER" ]; then
|
||||
NODEJS_VERT=$(echo ${NODEJS_VER} | cut -c 2- | cut -d '.' -f1)
|
||||
|
||||
GE1=$(echo "$NODEJS_VERT>=1" | bc)
|
||||
LT4=$(echo "$NODEJS_VERT<4" | bc)
|
||||
|
||||
if [ "1" -eq $GE1 ] && [ "1" -eq $LT4 ]
|
||||
then
|
||||
NODEJS_BASE_URL="https://iojs.org"
|
||||
NODEJS_NAME="iojs"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$NODEJS_VER" ]; then
|
||||
if [ -n "$(which curl)" ]; then
|
||||
IOJS_VER="$(curl -fsSL https://iojs.org/dist/index.tab | head -2 | tail -1 | cut -f 1)" \
|
||||
NODEJS_VER="$(curl -fsSL "$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
|
||||
IOJS_VER="wget --quiet https://iojs.org/dist/index.tab -O - | head -2 | tail -1 | cut -f 1)" \
|
||||
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."
|
||||
|
@ -175,12 +192,12 @@ if [ -z "$IOJS_VER" ]; then
|
|||
fi
|
||||
|
||||
#
|
||||
# iojs
|
||||
# iojs
|
||||
#
|
||||
if [ -n "$(which iojs | grep iojs 2>/dev/null)" ]; then
|
||||
# iojs of some version is already installed
|
||||
if [ "${IOJS_VER}" == "$(iojs -v 2>/dev/null)" ]; then
|
||||
echo iojs ${IOJS_VER} is already installed
|
||||
if [ "${NODEJS_VER}" == "$(iojs -v 2>/dev/null)" ]; then
|
||||
echo iojs ${NODEJS_VER} is already installed
|
||||
else
|
||||
echo ""
|
||||
echo "HEY, LISTEN:"
|
||||
|
@ -190,7 +207,7 @@ if [ -n "$(which iojs | grep iojs 2>/dev/null)" ]; then
|
|||
echo "to reinstall please first run: rm $(which iojs)"
|
||||
echo ""
|
||||
fi
|
||||
IOJS_VER=""
|
||||
NODEJS_VER=""
|
||||
elif [ "$(node -v 2>/dev/null)" != "$(iojs -v 2>/dev/null)" ]; then
|
||||
# node of some version is already installed
|
||||
echo ""
|
||||
|
@ -211,8 +228,8 @@ elif [ "$(node -v 2>/dev/null)" != "$(iojs -v 2>/dev/null)" ]; then
|
|||
echo ""
|
||||
fi
|
||||
|
||||
if [ -n "${IOJS_VER}" ]; then
|
||||
bash /tmp/install-iojs.bash "${IOJS_VER}"
|
||||
if [ -n "${NODEJS_VER}" ]; then
|
||||
bash /tmp/install-iojs.bash "${NODEJS_VER}"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
|
65
setup.bash
65
setup.bash
|
@ -9,13 +9,13 @@
|
|||
# curl -fsSL https://example.com/setup.bash | bash
|
||||
# wget -nv https://example.com/setup.bash -O - | bash
|
||||
|
||||
NODEJS_BASE_URL="https://iojs.org"
|
||||
#NODEJS_BASE_URL="https://nodejs.org"
|
||||
NODEJS_NAME="node"
|
||||
NODEJS_BASE_URL="https://nodejs.org"
|
||||
BASE_URL="https://raw.githubusercontent.com/coolaj86/iojs-install-script/master"
|
||||
NO_FAIL2BAN=""
|
||||
OS="unsupported"
|
||||
ARCH=""
|
||||
IOJS_VER=""
|
||||
NODEJS_VER=""
|
||||
SETUP_FILE=""
|
||||
|
||||
clear
|
||||
|
@ -145,18 +145,18 @@ esac
|
|||
# Download installers #
|
||||
#######################
|
||||
|
||||
echo "Preparing to install io.js (and common development dependencies) for ${OS}" "${ARCH}"
|
||||
echo "Preparing to install ${NODEJS_NAME} (and common development dependencies) for ${OS}" "${ARCH}"
|
||||
|
||||
if [ -n "$(which curl)" ]; then
|
||||
curl --silent "${BASE_URL}/setup-deps-${SETUP_FILE}.bash" \
|
||||
-o /tmp/install-iojs-deps.bash || echo 'error downloading os setup script'
|
||||
-o /tmp/install-${NODEJS_NAME}-deps.bash || echo 'error downloading os setup script'
|
||||
curl --silent "${BASE_URL}/setup-iojs-${SETUP_FILE}.bash" \
|
||||
-o /tmp/install-iojs.bash || echo 'error downloading os setup script'
|
||||
-o /tmp/install-${NODEJS_NAME}.bash || echo 'error downloading os setup script'
|
||||
elif [ -n "$(which wget)" ]; then
|
||||
wget --quiet "${BASE_URL}/setup-deps-${SETUP_FILE}.bash" \
|
||||
-O /tmp/install-iojs-deps.bash || echo 'error downloading os setup script'
|
||||
-O /tmp/install-${NODEJS_NAME}-deps.bash || echo 'error downloading os setup script'
|
||||
wget --quiet "${BASE_URL}/setup-iojs-${SETUP_FILE}.bash" \
|
||||
-O /tmp/install-iojs.bash || echo 'error downloading os setup script'
|
||||
-O /tmp/install-${NODEJS_NAME}.bash || echo 'error downloading os setup script'
|
||||
else
|
||||
echo "Found neither 'curl' nor 'wget'. Can't Continue."
|
||||
exit 1
|
||||
|
@ -203,23 +203,39 @@ if [ -z "$(which fail2ban-server | grep fail2ban)" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
bash /tmp/install-iojs-deps.bash "${NO_FAIL2BAN}"
|
||||
bash /tmp/install-${NODEJS_NAME}-deps.bash "${NO_FAIL2BAN}"
|
||||
|
||||
#########################
|
||||
# Which io.js VERSION ? #
|
||||
# Which node.js VERSION ? #
|
||||
#########################
|
||||
|
||||
if [ -f "/tmp/IOJS_VER" ]; then
|
||||
IOJS_VER=$(cat /tmp/IOJS_VER | grep v)
|
||||
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 [ -z "$IOJS_VER" ]; then
|
||||
if [ -n "$NODEJS_VER" ]; then
|
||||
NODEJS_VERT=$(echo ${NODEJS_VER} | cut -c 2- | cut -d '.' -f1)
|
||||
|
||||
GE1=$(echo "$NODEJS_VERT>=1" | bc)
|
||||
LT4=$(echo "$NODEJS_VERT<4" | bc)
|
||||
|
||||
if [ "1" -eq $GE1 ] && [ "1" -eq $LT4 ]
|
||||
then
|
||||
echo "Selecting io.js instead of node.js for this version"
|
||||
NODEJS_BASE_URL="https://iojs.org"
|
||||
NODEJS_NAME="iojs"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$NODEJS_VER" ]; then
|
||||
if [ -n "$(which curl)" ]; then
|
||||
IOJS_VER="$(curl -fsSL "$NODEJS_BASE_URL/dist/index.tab" | head -2 | tail -1 | cut -f 1)" \
|
||||
|| echo 'error automatically determining current io.js version'
|
||||
NODEJS_VER="$(curl -fsSL "$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
|
||||
IOJS_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'
|
||||
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
|
||||
|
@ -227,22 +243,22 @@ if [ -z "$IOJS_VER" ]; then
|
|||
fi
|
||||
|
||||
#
|
||||
# iojs
|
||||
# iojs
|
||||
#
|
||||
if [ -n "$(which iojs | grep iojs 2>/dev/null)" ]; then
|
||||
# iojs of some version is already installed
|
||||
if [ "${IOJS_VER}" == "$(iojs -v 2>/dev/null)" ]; then
|
||||
echo iojs ${IOJS_VER} is already installed
|
||||
if [ "${NODEJS_VER}" == "$(iojs -v 2>/dev/null)" ]; then
|
||||
echo iojs ${NODEJS_VER} is already installed
|
||||
else
|
||||
echo ""
|
||||
echo "HEY, LISTEN:"
|
||||
echo ""
|
||||
echo "io.js is already installed as iojs $(iojs -v | grep v)"
|
||||
echo "${NODEJS_NAME} is already installed as iojs $(iojs -v | grep v)"
|
||||
echo ""
|
||||
echo "to reinstall please first run: rm $(which iojs)"
|
||||
echo ""
|
||||
fi
|
||||
IOJS_VER=""
|
||||
NODEJS_VER=""
|
||||
elif [ "$(node -v 2>/dev/null)" != "$(iojs -v 2>/dev/null)" ]; then
|
||||
# node of some version is already installed
|
||||
echo ""
|
||||
|
@ -250,7 +266,6 @@ elif [ "$(node -v 2>/dev/null)" != "$(iojs -v 2>/dev/null)" ]; then
|
|||
echo ""
|
||||
echo "You have node.js installed."
|
||||
echo "Backing up $(which node) as $(which node).$(node -v)"
|
||||
echo "(copy it back after the install to maintain node.js and io.js separately)"
|
||||
echo ""
|
||||
sleep 3
|
||||
NODE_PATH=$(which node)
|
||||
|
@ -263,8 +278,8 @@ elif [ "$(node -v 2>/dev/null)" != "$(iojs -v 2>/dev/null)" ]; then
|
|||
echo ""
|
||||
fi
|
||||
|
||||
if [ -n "${IOJS_VER}" ]; then
|
||||
bash /tmp/install-iojs.bash "${IOJS_VER}"
|
||||
if [ -n "${NODEJS_VER}" ]; then
|
||||
bash /tmp/install-${NODEJS_NAME}.bash "${NODEJS_VER}"
|
||||
fi
|
||||
|
||||
# jshint
|
||||
|
|
Loading…
Reference in New Issue