Created
March 26, 2013 09:20
-
-
Save tagomoris/5244103 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| TARGET_VERSION=$1 | |
| LOCATION=$2 | |
| ARCH=$3 | |
| if [ "x"$TARGET_VERSION = "x-h" -o "x"$TARGET_VERSION = "x--help" -o "x"$LOCATION = "x" ]; then | |
| echo "[usage] node-install VERSION LOCATION [arch]" | |
| echo " ex: node-install v0.10.1 ~/local/node-v0.10" | |
| echo " ex: node-install v0.10.1 ~/local/node-v0.10 darwin-x86" | |
| echo " default arch is 'linux-x64'" | |
| exit 0 | |
| fi | |
| if [ "x"$ARCH = "x" ]; then | |
| ARCH="linux-x64" | |
| fi | |
| cd $(dirname $0) | |
| ARCHIVE_FILENAME="node-"$TARGET_VERSION"-"$ARCH".tar.gz" | |
| ARCHIVE_DIRNAME="node-"$TARGET_VERSION"-"$ARCH | |
| set -e | |
| mkdir -p var/node-archive | |
| cd var/node-archive | |
| curl -s -O http://nodejs.org/dist/$TARGET_VERSION/$ARCHIVE_FILENAME | |
| cd .. | |
| tar xzf node-archive/$ARCHIVE_FILENAME | |
| if [ -d $LOCATION ]; then | |
| [[ -d $LOCATION.replaced ]] && rm -rf $LOCATION.replaced | |
| mv $LOCATION $LOCATION.replaced | |
| else | |
| mkdir -p $LOCATION && rmdir $LOCATION | |
| fi | |
| mv $ARCHIVE_DIRNAME $LOCATION | |
| echo "node $TARGET_VERSION successfully installed on $LOCATION" | |
| echo "To use this node, do 'export PATH=$LOCATION/bin:\$PATH'." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment