Skip to content

Instantly share code, notes, and snippets.

@boutell
Last active December 24, 2015 08:09
Show Gist options
  • Save boutell/6768845 to your computer and use it in GitHub Desktop.
Save boutell/6768845 to your computer and use it in GitHub Desktop.
nodeup: a tiny script that installs the desired version of node on any Ubuntu Linux server. Builds from source but does it quickly with 4 cores. Also installs forever
#!/bin/sh
# On the specified host, install the specified version of node
if [ -z "$1" ]
then
echo "First argument must be somehost.com, second argument must be desired node version"
exit 1
fi
if [ -z "$2" ]
then
echo "Specify node version in this format: 0.10.18"
exit 1
fi
SERVER="$1"
VERSION="$2"
ssh "root@$SERVER" <<EOM
wget http://nodejs.org/dist/v0.10.18/node-v0.10.18.tar.gz &&
tar -zxf node-v0.10.18.tar.gz && cd node-v0.10.18 &&
./configure --prefix=/usr &&
make -j 4 &&
./node --version &&
apt-get -y remove nodejs &&
make install &&
npm install -g forever &&
cd /tmp &&
node --version &&
echo Done
EOM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment