node-installer.sh/setup.bash

150 lines
3.3 KiB
Bash
Raw Normal View History

2014-12-22 00:16:06 +00:00
#!/bin/bash
2014-12-28 08:25:26 +00:00
# curl -fsSL https://example.com/setup.bash | bash
# wget -nv https://example.com/setup.bash -O - | bash
2014-12-22 00:16:06 +00:00
2015-01-14 09:43:38 +00:00
BASE_URL="https://raw.githubusercontent.com/coolaj86/iojs-install-script/master"
2015-01-14 09:43:38 +00:00
if [ -n "$(which iojs 2>/dev/null || false)" ]; then
echo ""
echo "HEY, LISTEN:"
2015-01-14 09:43:38 +00:00
echo "io.js is already install as iojs $(iojs -v | grep v)"
echo ""
2015-01-14 09:43:38 +00:00
echo "to reinstall please first run: rm $(which iojs)"
echo ""
fi
2015-01-14 09:43:38 +00:00
if [ -f "/tmp/IOJS_VER" ]; then
IOJS_VER=$(cat /tmp/IOJS_VER | grep v)
2015-01-08 18:37:33 +00:00
fi
2015-01-14 09:43:38 +00:00
if [ -z "$IOJS_VER" ]; then
IOJS_VER="v1.0.1"
2015-01-08 18:37:33 +00:00
fi
2014-12-22 00:16:06 +00:00
OS="unsupported"
ARCH=""
if [ "$(uname | grep -i 'Darwin')" ]; then
OSX_VER="$(sw_vers | grep ProductVersion | cut -d':' -f2 | cut -f2)"
OSX_MAJOR="$(echo ${OSX_VER} | cut -d'.' -f1)"
OSX_MINOR="$(echo ${OSX_VER} | cut -d'.' -f2)"
OSX_PATCH="$(echo ${OSX_VER} | cut -d'.' -f3)"
#
# Major
#
if [ "$OSX_MAJOR" -lt 10 ]; then
echo "unsupported OS X version (os 9-)"
exit 1
fi
if [ "$OSX_MAJOR" -gt 10 ]; then
echo "unsupported OS X version (os 11+)"
exit 1
fi
#
# Minor
#
if [ "$OSX_MINOR" -le 5 ]; then
echo "unsupported OS X version (os 10.5-)"
exit 1
fi
# Snow
if [ "$OSX_MINOR" -eq 6 ]; then
OS='snow'
fi
# Lion
if [ $OSX_MINOR -eq 7 ]; then
OS='lion'
fi
# Mountain Lion
if [ "$OSX_MINOR" -eq 8 ]; then
OS='mountain'
fi
# Mavericks, Yosemite
if [ "$OSX_MINOR" -ge 9 ]; then
OS='mavericks'
fi
if [ -n "$(sysctl hw | grep 64bit | grep ': 1')" ]; then
ARCH="64"
else
ARCH="32"
fi
elif [ "$(uname | grep -i 'Linux')" ]; then
if [ ! -f "/etc/issue" ]; then
echo "unsupported linux os"
exit 1
fi
if [ -n "$(arch | grep 64)" ]; then
ARCH="64"
else
ARCH="32"
fi
if [ "$(cat /etc/issue | grep -i 'Ubuntu')" ]; then
OS='ubuntu'
elif [ "$(cat /etc/issue | grep -i 'Fedora')" ]; then
OS='fedora'
fi
else
echo "unsupported unknown os (non-mac, non-linux)"
exit 1
fi
case "${OS}" in
fedora)
echo "sudo yum"
2015-01-14 09:43:38 +00:00
echo "wget --quiet ${BASE_URL}/setup-fedora.bash -O /tmp/install-iojs.bash || echo 'error downloading os setup script'"
2014-12-22 00:16:06 +00:00
;;
ubuntu)
2015-01-14 09:43:38 +00:00
wget --quiet "${BASE_URL}/setup-ubuntu.bash" -O /tmp/install-iojs.bash || echo 'error downloading os setup script'
2014-12-22 00:16:06 +00:00
;;
yosemite)
# mavericks
2015-01-14 09:43:38 +00:00
curl --silent "${BASE_URL}/setup-mavericks.bash" -o /tmp/install-iojs.bash || echo 'error downloading os setup script'
2014-12-22 00:16:06 +00:00
;;
mavericks)
2015-01-14 09:43:38 +00:00
curl --silent "${BASE_URL}/setup-mavericks.bash" -o /tmp/install-iojs.bash || echo 'error downloading os setup script'
2014-12-22 00:16:06 +00:00
;;
mountain)
echo "wget cltools"
2015-01-14 09:43:38 +00:00
echo "curl --silent ${BASE_URL}/setup-mountain.bash -o /tmp/install-iojs.bash || echo 'error downloading os setup script'"
2014-12-22 00:16:06 +00:00
;;
lion)
echo "wget cltools"
2015-01-14 09:43:38 +00:00
echo "curl --silent ${BASE_URL}/setup-lion.bash -o /tmp/install-iojs.bash || echo 'error downloading os setup script'"
2014-12-22 00:16:06 +00:00
;;
snow)
echo "wget gcc-0.6.pkg"
2015-01-14 09:43:38 +00:00
echo "curl --silent ${BASE_URL}/setup-snow.bash -o /tmp/install-iojs.bash || echo 'error downloading os setup script'"
2014-12-22 00:16:06 +00:00
;;
*)
echo "unsupported unknown os ${OS}"
exit 1
;;
esac
echo "${OS}" "${ARCH}"
2015-01-14 09:43:38 +00:00
bash /tmp/install-iojs.bash "${IOJS_VER}"
2014-12-22 00:16:06 +00:00
# jshint
if [ -z "$(which jshint | grep jshint)" ]; then
echo "installing jshint..."
npm install --silent jshint -g > /dev/null
else
echo "jshint already installed"
fi
echo ""