From c17d4a2459a95af2823aaae88f77ed03b06aeafd Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 8 Jan 2015 11:57:50 -0700 Subject: [PATCH] check existing node version --- setup-ubuntu.bash | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/setup-ubuntu.bash b/setup-ubuntu.bash index ab434e9..6bab698 100644 --- a/setup-ubuntu.bash +++ b/setup-ubuntu.bash @@ -24,17 +24,32 @@ then fi # node -CUR_NODE_VER=$(node -v 2>/dev/null) -if [ -n "$(which node | grep node)" ] && [ "${NODE_VER}" == "$(node -v 2>/dev/null)" ]; then -#if [ "${NODE_VER}" == "${CUR_NODE_VER}" ]; then - echo node ${NODE_VER} already installed -else +if [ -n "$(which node | grep node 2>/dev/null)" ]; then + if [ "${NODE_VER}" == "$(node -v 2>/dev/null)" ]; then + echo node ${NODE_VER} already installed + else + echo "" + echo "HEY, LISTEN:" + echo "node is already installed as $(node -v | grep v)" + echo "" + echo "to reinstall please first run: rm $(which node)" + echo "" + NODE_VER="" + fi +fi + +if [ -n "${NODE_VER}" ]; then + if [ -n "$(arch | grep 64)" ]; then + ARCH="x64" + else + ARCH="x86" + fi echo "installing node ${NODE_VER}..." - curl -fsSL "http://nodejs.org/dist/${NODE_VER}/node-${NODE_VER}-linux-x64.tar.gz" \ - -o "/tmp/node-${NODE_VER}-linux-x64.tar.gz" + curl -fsSL "http://nodejs.org/dist/${NODE_VER}/node-${NODE_VER}-linux-${ARCH}.tar.gz" \ + -o "/tmp/node-${NODE_VER}-linux-${ARCH}.tar.gz" pushd /tmp - tar xf /tmp/node-${NODE_VER}-linux-x64.tar.gz + tar xf /tmp/node-${NODE_VER}-linux-${ARCH}.tar.gz rm node-${NODE_VER}-linux-x64/{LICENSE,ChangeLog,README.md} - sudo rsync -a /tmp/node-${NODE_VER}-linux-x64/ /usr/local/ + sudo rsync -a "/tmp/node-${NODE_VER}-linux-${ARCH}/" /usr/local/ sudo chown -R $(whoami) /usr/local fi