diff --git a/setup-mavericks.bash b/setup-mavericks.bash new file mode 100644 index 0000000..d93c79a --- /dev/null +++ b/setup-mavericks.bash @@ -0,0 +1,74 @@ +#!/bin/bash + +# curl -fsSL https://ldsconnect.org/setup-osx.bash | bash -c +NODE_VER=${1} + +echo "" +echo "" + +# XCode +# testing for which git, gcc, etc will not work because the tools are aliased to the install script +if [ -z "$(xcode-select --print-path 2>/dev/null)" ] || [ -z "$(git --version 2>/dev/null)" ]; then + echo "Hey You!!!" + echo "" + echo "A thingy is going to pop up and ask you to install 'command line developer tools' for 'xcode-select'" + echo "" + echo "You need to click Install. This installation should begin when that finishes." + echo "(if that box doesn't pop up in a second or two, something went wrong)" + echo "(note that it may pop up underneath this window, so check for it in the dock too)" + echo "" + + xcode-select --install 2>/dev/null + + while true; do + sleep 5 + + if [ -n "$(git --version 2>/dev/null)" ] && [ -n "$(xcode-select --print-path 2>/dev/null)" ]; then + break; + fi + done + + echo "It looks like the other install is finishing up." + echo "This installation will begin in one minute." + sleep 60 +else + echo "XCode Command Line Tools already installed" +fi + +# homebrew +if [ -z "$(which brew | grep brew)" ]; then + echo "installing brew (homebrew)..." + ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + brew doctor +else + echo "updating brew..." + brew update >/dev/null 2>/dev/null +fi + +if [ -z "$(which wget | grep wget)" ]; then + echo "installing wget..." + brew install wget +else + echo "wget already installed" +fi + +# http://www.fail2ban.org/wiki/index.php/HOWTO_Mac_OS_X_Server_(10.5) +if [ -z "$(which fail2ban-server | grep fail2ban)" ]; then + echo "installing fail2ban..." + brew install fail2ban + sudo cp -fv /usr/local/opt/fail2ban/*.plist /Library/LaunchDaemons + sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.fail2ban.plist +else + echo "fail2ban already installed" +fi + +# node +CUR_NODE_VER=$(node -v 2>/dev/null) +if [ -n "$(which node | grep node)" ] && [ "${NODE_VER}" == "$(node -v 2>/dev/null)" ]; then + echo node ${NODE_VER} already installed +else + echo "installing node ${NODE_VER}..." + curl -fsSL "http://nodejs.org/dist/${NODE_VER}/node-${NODE_VER}.pkg" -o "/tmp/node-${NODE_VER}.pkg" + sudo /usr/sbin/installer -pkg "/tmp/node-${NODE_VER}.pkg" -target / + sudo chown -R $(whoami) /usr/local +fi diff --git a/setup-ubuntu.bash b/setup-ubuntu.bash new file mode 100644 index 0000000..cc81f45 --- /dev/null +++ b/setup-ubuntu.bash @@ -0,0 +1,40 @@ +#!/bin/bash + +# curl -fsSL https://ldsconnect.org/setup-linux.bash | bash -c + +NODE_VER=${1} + +echo "" +echo "" + +echo "updating apt-get..." +sudo bash -c "apt-get update -qq -y < /dev/null" > /dev/null + +# fail2ban +if [ -z "$(which fail2ban-server | grep fail2ban)" ]; then + echo "installing fail2ban..." + sudo bash -c "apt-get install -qq -y fail2ban < /dev/null" > /dev/null +fi + +# git, wget, curl, build-essential +if [ -z "$(which git | grep git)" ] || [ -z "$(which wget | grep wget)" ] || [ -z "$(which curl | grep curl)" ] || [ -z "$(which gcc | grep gcc)" ] || [ -z "$(which rsync | grep rsync)" ] +then + echo "installing git, wget, curl, build-essential, rsync..." + sudo bash -c "apt-get install -qq -y git wget curl build-essential rsync < /dev/null" > /dev/null 2>/dev/null +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 + 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" + pushd /tmp + tar xf /tmp/node-${NODE_VER}-linux-x64.tar.gz + rm node-${NODE_VER}-linux-x64/{LICENSE,ChangeLog,README.md} + sudo rsync -a /tmp/node-${NODE_VER}-linux-x64/ /usr/local/ + sudo chown -R $(whoami) /usr/local +fi diff --git a/setup.bash b/setup.bash new file mode 100644 index 0000000..e4edbd6 --- /dev/null +++ b/setup.bash @@ -0,0 +1,158 @@ +#!/bin/bash + +# curl -s https://ldsconnect.org/setup.bash | bash +# wget -nv https://ldsconnect.org/setup.bash -O - | bash + +BASE_URL="https://ldsconnect.org" +NODE_VER="v0.11.14" +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" + echo "wget --quiet ${BASE_URL}/setup-fedora.bash -O /tmp/install-node.bash || echo 'error downloading os setup script'" + ;; + ubuntu) + wget --quiet "${BASE_URL}/setup-ubuntu.bash" -O /tmp/install-node.bash || echo 'error downloading os setup script' + ;; + yosemite) + # mavericks + curl --silent "${BASE_URL}/setup-mavericks.bash" -o /tmp/install-node.bash || echo 'error downloading os setup script' + ;; + mavericks) + curl --silent "${BASE_URL}/setup-mavericks.bash" -o /tmp/install-node.bash || echo 'error downloading os setup script' + ;; + mountain) + echo "wget cltools" + echo "curl --silent ${BASE_URL}/setup-mountain.bash -o /tmp/install-node.bash || echo 'error downloading os setup script'" + ;; + lion) + echo "wget cltools" + echo "curl --silent ${BASE_URL}/setup-lion.bash -o /tmp/install-node.bash || echo 'error downloading os setup script'" + ;; + snow) + echo "wget gcc-0.6.pkg" + echo "curl --silent ${BASE_URL}/setup-snow.bash -o /tmp/install-node.bash || echo 'error downloading os setup script'" + ;; + *) + echo "unsupported unknown os ${OS}" + exit 1 + ;; +esac + +echo "${OS}" "${ARCH}" +bash /tmp/install-node.bash "${NODE_VER}" + +# jshint +if [ -z "$(which jshint | grep jshint)" ]; then + echo "installing jshint..." + npm install --silent jshint -g > /dev/null +else + echo "jshint already installed" +fi + +# yo +if [ -z "$(which yo | grep yo)" ]; then + echo "installing yo (yeoman)..." + npm install --silent yo generator-angular -g > /dev/null +else + echo "yo (yeoman) already installed" +fi + +# bower +if [ -z "$(which bower | grep bower)" ]; then + echo "installing bower..." + npm install --silent bower -g > /dev/null +else + echo "bower already installed" +fi + +# jade +if [ -z "$(which jade | grep jade)" ]; then + echo "installing jade..." + npm install --silent jade -g > /dev/null +else + echo "jade already installed" +fi + +echo ""