From 6d2d7e7c20291e7cc352871419f3376ec0a0a123 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Tue, 20 Jan 2015 23:18:12 -0700 Subject: [PATCH] move paths to bash vars --- setup-iojs-ubuntu.bash | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/setup-iojs-ubuntu.bash b/setup-iojs-ubuntu.bash index f8b7911..48b6337 100644 --- a/setup-iojs-ubuntu.bash +++ b/setup-iojs-ubuntu.bash @@ -6,15 +6,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}" + if [ -n "${IOJS_VER}" ]; then echo "installing io.js as iojs ${IOJS_VER}..." - curl -fsSL "http://iojs.org/dist/${IOJS_VER}/iojs-${IOJS_VER}-linux-${ARCH}.tar.gz" \ - -o "/tmp/iojs-${IOJS_VER}-linux-${ARCH}.tar.gz" - pushd /tmp >/dev/null - tar xf /tmp/iojs-${IOJS_VER}-linux-${ARCH}.tar.gz - rm iojs-${IOJS_VER}-linux-x64/{LICENSE,CHANGELOG.md,README.md} - sudo rsync -a "/tmp/iojs-${IOJS_VER}-linux-${ARCH}/" /usr/local/ + if [ -n "$(which curl 2>/dev/null)" ]; then + curl -fsSL ${IOJS_REMOTE} -o ${IOJS_LOCAL} || echo 'error downloading io.js' + elif [ -n "$(which wget 2>/dev/null)" ]; then + wget --quiet ${IOJS_REMOTE} -O ${IOJS_LOCAL} || echo 'error downloading io.js' + 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} + rm ${IOJS_UNTAR}/{LICENSE,CHANGELOG.md,README.md} + sudo rsync -a "${IOJS_UNTAR}/" /usr/local/ sudo chown -R $(whoami) /usr/local