diff --git a/package.json b/package.json index 56627575..8ec46e56 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,6 @@ "description": "Full node with extended capabilities using Bitcore and Bitcoin Core", "author": "BitPay ", "version": "2.1.1-dev", - "lastBuild": "2.1.1", "main": "./index.js", "repository": "git://github.com/bitpay/bitcore-node.git", "homepage": "https://github.com/bitpay/bitcore-node", @@ -31,6 +30,7 @@ "bitcore-node": "./bin/bitcore-node" }, "scripts": { + "install": "./scripts/install", "test": "NODE_ENV=test mocha -R spec --recursive", "coverage": "NODE_ENV=test istanbul cover _mocha -- --recursive" }, diff --git a/scripts/install b/scripts/install new file mode 100755 index 00000000..496ca5d2 --- /dev/null +++ b/scripts/install @@ -0,0 +1,51 @@ +#!/bin/bash + +root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.." +platform=`uname -a | awk '{print tolower($1)}'` +arch=`uname -m` +version="0.12.0-bitcore" +url="https://github.com/" + +cd "${root_dir}/bin" + +if [ "${platform}" == "linux" ]; then + if [ "${arch}" == "x86_64" ]; then + tarball_name="bitcoin-${version}-linux64.tar.gz" + elif [ "${arch}" == "x86_32" ]; then + tarball_name="bitcoin-${version}-linux32.tar.gz" + fi +elif [ "${platform}" == "darwin" ]; then + tarball_name="bitcoin-${version}-osx64.tar.gz" +else + echo "Bitcoin binary distribution not available for platform and architecture" + exit -1 +fi + +binary_url="${url}/${tarball_name}" + +echo "Downloading bitcoin: ${binary_url}" + +is_curl=true +if hash curl 2>/dev/null; then + curl --fail -I $binary_url >/dev/null 2>&1 +else + is_curl=false + wget --server-response --spider $binary_url >/dev/null 2>&1 +fi + +if test $? -eq 0; then + if [ "${is_curl}" = true ]; then + curl $binary_url > $tarball_name + else + wget $binary_url + fi + if test -e "${tarball_name}"; then + echo "Unpacking bitcoin distribution" + tar -xvzf $tarball_name + if test $? -eq 0; then + exit 0 + fi + fi +fi +echo "Bitcoin binary distribution could not be downloaded" +exit -1