From 3273ac3e5b590fc43ba35eea6533a1a79162d463 Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Thu, 4 Feb 2016 21:34:21 +0000 Subject: [PATCH 01/26] fixed a conditional --- install-deps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-deps.sh b/install-deps.sh index 1e1ce9128..a831bb64f 100755 --- a/install-deps.sh +++ b/install-deps.sh @@ -548,7 +548,7 @@ function run_installer() function linux_rocksdb_installer() { - if [[ $isUbuntu1404 ]]; then + if [[ $isUbuntu1404 == true ]]; then ubuntu1404_rocksdb_installer else oldpwd=`pwd` From 6af69d705766fe3ce08b2ad0b1643d15046c5c18 Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Thu, 4 Feb 2016 22:40:19 +0000 Subject: [PATCH 02/26] moved parity-related build stuff from install-deps into install-parity --- install-deps.sh | 97 ------------- install-parity.sh | 337 ++++++++++------------------------------------ 2 files changed, 70 insertions(+), 364 deletions(-) diff --git a/install-deps.sh b/install-deps.sh index 5c42bcf2a..a641f3659 100755 --- a/install-deps.sh +++ b/install-deps.sh @@ -636,89 +636,6 @@ function run_installer() fi } - function build_parity() - { - info "Downloading Parity..." - git clone git@github.com:ethcore/parity - cd parity - git submodule init - git submodule update - - info "Building & testing Parity..." - cargo test --release -p ethcore-util - - info "Running consensus tests..." - cargo test --release --features ethcore/json-tests -p ethcore - - echo - info "Parity source code is in $(pwd)/parity" - info "Run a client with: ${b}cargo run --release${reset}" - } - - function install_netstats() - { - echo "Installing netstats" - - secret=$(prompt_for_input "Please enter the netstats secret:") - instance_name=$(prompt_for_input "Please enter your instance name:") - contact_details=$(prompt_for_input "Please enter your contact details (optional):") - - # install ethereum & install dependencies - sudo apt-get install -y -qq build-essential git unzip wget nodejs npm ntp cloud-utils - - # add node symlink if it doesn't exist - [[ ! -f /usr/bin/node ]] && sudo ln -s /usr/bin/nodejs /usr/bin/node - - # set up time update cronjob - sudo bash -c "cat > /etc/cron.hourly/ntpdate << EOF - #!/bin/sh - pm2 flush - sudo service ntp stop - sudo ntpdate -s ntp.ubuntu.com - sudo service ntp start - EOF" - - sudo chmod 755 /etc/cron.hourly/ntpdate - - [ ! -d "www" ] && git clone https://github.com/cubedro/eth-net-intelligence-api netstats - cd netstats - git pull - git checkout 95d595258239a0fdf56b97dedcfb2be62f6170e6 - - sudo npm install - sudo npm install pm2 -g - - cat > app.json << EOL -[ - { - "name" : "node-app", - "script" : "app.js", - "log_date_format" : "YYYY-MM-DD HH:mm Z", - "merge_logs" : false, - "watch" : false, - "max_restarts" : 10, - "exec_interpreter" : "node", - "exec_mode" : "fork_mode", - "env": - { - "NODE_ENV" : "production", - "RPC_HOST" : "localhost", - "RPC_PORT" : "8545", - "LISTENING_PORT" : "30303", - "INSTANCE_NAME" : "${instance_name}", - "CONTACT_DETAILS" : "${contact_details}", - "WS_SERVER" : "wss://rpc.ethstats.net", - "WS_SECRET" : "${secret}", - "VERBOSITY" : 2 - - } - } -] -EOL - - pm2 start app.json - cd .. - } function abortInstall() { @@ -766,20 +683,6 @@ EOL # Check installation verify_installation - if [[ ! -e parity ]]; then - # Maybe install parity - if wait_for_user "${b}Build dependencies installed B-)!${reset} Would you like to download and build parity?"; then - # Do get parity. - build_parity - fi - fi - - if [[ $OS_TYPE == "linux" && $DISTRIB_ID == "Ubuntu" ]]; then - if wait_for_user "${b}Netstats:${reset} Would you like to install and configure a netstats client?"; then - install_netstats - fi - fi - # Display goodby message finish } diff --git a/install-parity.sh b/install-parity.sh index 3217cc284..9c0a40181 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -1,8 +1,7 @@ #!/usr/bin/env bash - -PARITY_DEB_URL=https://github.com/ethcore/parity/releases/download/beta-0.9/parity_0.9.0-0_amd64.deb +GET_DEPS_URL=https://raw.githubusercontent.com/ethcore/parity/install-parity/install-deps.sh?token=ABG4GdRAtO16t1U9l7JJgMDhf92CzHBWks5WvP6qwA%3D%3D function run_installer() { @@ -119,82 +118,38 @@ function run_installer() done } + function linux_version() + { + source /etc/lsb-release + + if [[ $DISTRIB_ID == "Ubuntu" ]]; then + if [[ $DISTRIB_RELEASE == "14.04" ]]; then + check "Ubuntu-14.04" + isUbuntu1404=true + else + check "Ubuntu, but not 14.04" + isUbuntu1404=false + fi + else + check "Ubuntu not found" + isUbuntu1404=false + fi + } function detectOS() { if [[ "$OSTYPE" == "linux-gnu" ]] then OS_TYPE="linux" - get_linux_dependencies + linux_version elif [[ "$OSTYPE" == "darwin"* ]] then OS_TYPE="osx" - get_osx_dependencies else OS_TYPE="win" abortInstall "${red}==>${reset} ${b}OS not supported:${reset} parity one-liner currently support OS X and Linux.\nFor instructions on installing parity on other platforms please visit ${u}${blue}http://ethcore.io/${reset}" fi echo - - if [[ $depCount == $depFound ]] - then - green "Found all dependencies ($depFound/$depCount)" - else - if [[ $canContinue == true ]] - then - red "Some dependencies are missing ($depFound/$depCount)" - elif [[ $canContinue == false && $depFound == 0 ]] - then - red "All dependencies are missing and cannot be auto-installed ($depFound/$depCount)" - abortInstall "$errorMessages"; - elif [[ $canContinue == false ]] - then - red "Some dependencies which cannot be auto-installed are missing ($depFound/$depCount)" - abortInstall "$errorMessages"; - fi - fi - } - - function get_osx_dependencies() - { - macos_version - find_git - find_ruby - find_brew - } - - function macos_version() - { - declare -a reqVersion - declare -a localVersion - - depCount=$((depCount+1)) - OSX_VERSION=`/usr/bin/sw_vers -productVersion 2>/dev/null` - - if [ -z "$OSX_VERSION" ] - then - uncheck "OS X version not supported 🔥" - isOsVersion=false - canContinue=false - else - IFS='.' read -a localVersion <<< "$OSX_VERSION" - IFS='.' read -a reqVersion <<< "$OSX_REQUIERED_VERSION" - - if (( ${reqVersion[0]} <= ${localVersion[0]} )) && (( ${reqVersion[1]} <= ${localVersion[1]} )) - then - check "OS X Version ${OSX_VERSION}" - isOsVersion=true - depFound=$((depFound+1)) - return - else - uncheck "OS X version not supported" - isOsVersion=false - canContinue=false - fi - fi - - errorMessages+="${red}==>${reset} ${b}Mac OS version too old:${reset} eth requires OS X version ${red}$OSX_REQUIERED_VERSION${reset} at least in order to run.\n" - errorMessages+=" Please update the OS and reload the install process.\n" } function find_eth() @@ -211,119 +166,8 @@ function run_installer() fi } - function find_git() - { - depCount=$((depCount+1)) - - GIT_PATH=`which git 2>/dev/null` - - if [[ -f $GIT_PATH ]] - then - check "$($GIT_PATH --version)" - isGit=true - depFound=$((depFound+1)) - else - uncheck "Git is missing" - isGit=false - fi - } - - function find_ruby() - { - depCount=$((depCount+1)) - - RUBY_PATH=`which ruby 2>/dev/null` - - if [[ -f $RUBY_PATH ]] - then - RUBY_VERSION=`ruby -e "print RUBY_VERSION"` - check "Ruby ${RUBY_VERSION}" - isRuby=true - depFound=$((depFound+1)) - else - uncheck "Ruby is missing 🔥" - isRuby=false - canContinue=false - errorMessages+="${red}==>${reset} ${b}Couldn't find Ruby:${reset} Brew requires Ruby which could not be found.\n" - errorMessages+=" Please install Ruby using these instructions ${u}${blue}https://www.ruby-lang.org/en/documentation/installation/${reset}.\n" - fi - } - - function find_brew() - { - BREW_PATH=`which brew 2>/dev/null` - - if [[ -f $BREW_PATH ]] - then - check "$($BREW_PATH -v)" - isBrew=true - depFound=$((depFound+1)) - else - uncheck "Homebrew is missing" - isBrew=false - - INSTALL_FILES+="${blue}${dim}==> Homebrew:${reset}\n" - INSTALL_FILES+=" ${blue}${dim}➜${reset} $HOMEBREW_PREFIX/bin/brew\n" - INSTALL_FILES+=" ${blue}${dim}➜${reset} $HOMEBREW_PREFIX/Library\n" - INSTALL_FILES+=" ${blue}${dim}➜${reset} $HOMEBREW_PREFIX/share/man/man1/brew.1\n" - fi - - depCount=$((depCount+1)) - } - - function install_brew() - { - if [[ $isBrew == false ]] - then - head "Installing Homebrew" - - if [[ $isRuby == true ]] - then - ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - else - cd /usr - - if [[ ! -d $HOMEBREW_PREFIX ]] - then - sudo mkdir $HOMEBREW_PREFIX - sudo chmod g+rwx $HOMEBREW_PREFIX - fi - - if [[ ! -d $HOMEBREW_CACHE ]] - then - sudo mkdir $HOMEBREW_CACHE - sudo chmod g+rwx $HOMEBREW_CACHE - fi - - DEVELOPER_DIR=`/usr/bin/xcode-select -print-path 2>/dev/null` - - if [[ ! $(ls -A $DEVELOPER_DIR) || ! -f $DEVELOPER_DIR/usr/bin/git ]] - then - info "Installing the Command Line Tools (expect a GUI popup):" - sudo /usr/bin/xcode-select --install - - echo "Press any key when the installation has completed" - fi - - cd $HOMEBREW_PREFIX - - bash -o pipefail -c "curl -fsSL ${HOMEBREW_REPO}/tarball/master | tar xz -m --strip 1" - fi - - find_brew - echo - - if [[ $isBrew == false ]] - then - abortInstall "Couldn't install brew" - fi - fi - } - function osx_installer() { - osx_dependency_installer - info "Adding ethcore repository" brew tap ethcore/ethcore https://github.com/ethcore/homebrew-ethcore.git echo @@ -343,64 +187,24 @@ function run_installer() echo } - function osx_dependency_installer() + function build_parity() { - if [[ $isGit == false ]]; - then - echo "Installing Git" - fi + info "Downloading Parity..." + git clone git@github.com:ethcore/parity + cd parity + git submodule init + git submodule update + + info "Building & testing Parity..." + cargo test --release -p ethcore-util - if [[ $isRuby == false ]]; - then - echo "Installing Ruby" - fi + info "Running consensus tests..." + git submodule update -i + cargo test --release --features ethcore/json-tests -p ethcore - if [[ $isBrew == false ]]; - then - install_brew - fi - } - - function get_linux_dependencies() - { - find_apt - find_docker - } - - function find_apt() - { - APT_PATH=`which apt-get 2>/dev/null` - - if [[ -f $APT_PATH ]] - then - check "apt-get" - echo "$($APT_PATH -v)" - isApt=true - else - uncheck "apt-get is missing" - isApt=false - fi - } - - function find_docker() - { - DOCKER_PATH=`which docker 2>/dev/null` - - if [[ -f $DOCKER_PATH ]] - then - check "docker" - echo "$($DOCKER_PATH -v)" - isDocker=true - else - isDocker=false - fi - } - function linux_rocksdb_installer() - { - sudo add-apt-repository -y ppa:giskou/librocksdb - sudo apt-get -f -y install - sudo apt-get update - sudo apt-get install -y librocksdb + echo + info "Parity source code is in $(pwd)/parity" + info "Run a client with: ${b}cargo run --release${reset}" } function linux_installer() @@ -413,34 +217,43 @@ function run_installer() linux_rocksdb_installer echo - info "Installing parity" - file=/tmp/parity.deb - - - wget $PARITY_DEB_URL -qO $file - sudo dpkg -i $file - rm $file + build_parity } function install_netstats() { - echo "install netstats" - - if [[ $isDocker == false ]] - then - info "installing docker" - curl -sSL https://get.docker.com/ | sh - fi - - dir=$HOME/.netstats + echo "Installing netstats" secret=$(prompt_for_input "Please enter the netstats secret:") instance_name=$(prompt_for_input "Please enter your instance name:") contact_details=$(prompt_for_input "Please enter your contact details (optional):") + # install ethereum & install dependencies + sudo apt-get install -y -qq build-essential git unzip wget nodejs npm ntp cloud-utils - mkdir -p $dir - cat > $dir/app.json << EOL + # add node symlink if it doesn't exist + [[ ! -f /usr/bin/node ]] && sudo ln -s /usr/bin/nodejs /usr/bin/node + + # set up time update cronjob + sudo bash -c "cat > /etc/cron.hourly/ntpdate << EOF + #!/bin/sh + pm2 flush + sudo service ntp stop + sudo ntpdate -s ntp.ubuntu.com + sudo service ntp start + EOF" + + sudo chmod 755 /etc/cron.hourly/ntpdate + + [ ! -d "www" ] && git clone https://github.com/cubedro/eth-net-intelligence-api netstats + cd netstats + git pull + git checkout 95d595258239a0fdf56b97dedcfb2be62f6170e6 + + sudo npm install + sudo npm install pm2 -g + + cat > app.json << EOL [ { "name" : "node-app", @@ -468,16 +281,13 @@ function run_installer() ] EOL - sudo docker rm --force netstats-client 2> /dev/null - sudo docker pull ethcore/netstats-client - sudo docker run -d --net=host --name netstats-client -v $dir/app.json:/home/ethnetintel/eth-net-intelligence-api/app.json ethcore/netstats-client + pm2 start app.json + cd .. } + function install() { - echo - head "Installing Parity build dependencies" - if [[ $OS_TYPE == "osx" ]] then osx_installer @@ -517,26 +327,21 @@ EOL exit 0 } - # Check dependencies - head "Checking OS dependencies" + bash <(curl $GET_DEPS_URL -L) + detectOS - echo - head "In addition to the parity build dependencies, this script will install:" - echo "$INSTALL_FILES" - echo - # Prompt user to continue or abort - if wait_for_user "${b}OK,${reset} let's go!" + if wait_for_user "${b}OK,${reset} let's install Parity now!" then echo "Installing..." else abortInstall "${red}==>${reset} Process stopped by user. To resume the install run the one-liner command again." fi - # Install dependencies and eth install - + verify_installation + if [[ $OS_TYPE == "linux" ]] then echo "Netstats:" @@ -547,10 +352,8 @@ EOL fi fi - # Check installation - verify_installation - # Display goodby message + # Display goodbye message finish } From 4653355241121855c04508e85cc09aeaac518b43 Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Thu, 4 Feb 2016 22:45:30 +0000 Subject: [PATCH 03/26] get deps url --- install-parity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-parity.sh b/install-parity.sh index 9c0a40181..aa8524e99 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -GET_DEPS_URL=https://raw.githubusercontent.com/ethcore/parity/install-parity/install-deps.sh?token=ABG4GdRAtO16t1U9l7JJgMDhf92CzHBWks5WvP6qwA%3D%3D +GET_DEPS_URL=https://raw.githubusercontent.com/ethcore/parity/install-parity/install-deps.sh?token=ABG4GbR8ozeZ4u9VPNK-_fUaWS4l-l6Xks5WvQ7ywA%3D%3D function run_installer() { From 9a71f684d4de1fb94829f1c55865f6107da1421f Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Thu, 4 Feb 2016 23:03:56 +0000 Subject: [PATCH 04/26] slimming down the installer --- install-deps.sh | 17 ----------------- install-parity.sh | 19 ++----------------- 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/install-deps.sh b/install-deps.sh index a641f3659..cb8cc2186 100755 --- a/install-deps.sh +++ b/install-deps.sh @@ -385,7 +385,6 @@ function run_installer() find_gcc find_apt - find_docker } function find_rocksdb() @@ -519,22 +518,6 @@ function run_installer() fi } - function find_docker() - { - depCount=$((depCount+1)) - DOCKER_PATH=`which docker 2>/dev/null` - - if [[ -f $DOCKER_PATH ]] - then - depFound=$((depFound+1)) - check "docker" - echo "$($DOCKER_PATH -v)" - isDocker=true - else - isDocker=false - uncheck "docker is missing" - fi - } function ubuntu1404_rocksdb_installer() { diff --git a/install-parity.sh b/install-parity.sh index aa8524e99..7d219b1cf 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -195,12 +195,8 @@ function run_installer() git submodule init git submodule update - info "Building & testing Parity..." - cargo test --release -p ethcore-util - - info "Running consensus tests..." - git submodule update -i - cargo test --release --features ethcore/json-tests -p ethcore + info "Building Parity..." + cargo build --release echo info "Parity source code is in $(pwd)/parity" @@ -297,16 +293,6 @@ EOL fi } - function verify_installation() - { - info "Verifying installation" - find_eth - - if [[ $isEth == false ]] - then - abortInstall - fi - } function abortInstall() { @@ -340,7 +326,6 @@ EOL fi install - verify_installation if [[ $OS_TYPE == "linux" ]] then From 1ff5645108a49509ceb4b3d29380c5981aef1a70 Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Thu, 4 Feb 2016 23:05:17 +0000 Subject: [PATCH 05/26] updated the deps url --- install-parity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-parity.sh b/install-parity.sh index 7d219b1cf..3cd0c2ea8 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -GET_DEPS_URL=https://raw.githubusercontent.com/ethcore/parity/install-parity/install-deps.sh?token=ABG4GbR8ozeZ4u9VPNK-_fUaWS4l-l6Xks5WvQ7ywA%3D%3D +GET_DEPS_URL=https://raw.githubusercontent.com/ethcore/parity/install-parity/install-deps.sh?token=ABG4GSrcbr5ls3LMAJ0Zpu6RrtUy50MZks5WvROhwA%3D%3D function run_installer() { From 51cd06b69f517e9e67c936ef2ef302b34519075c Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Thu, 4 Feb 2016 23:13:03 +0000 Subject: [PATCH 06/26] create parity in home --- install-parity.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install-parity.sh b/install-parity.sh index 3cd0c2ea8..4b6ba62f2 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -190,8 +190,8 @@ function run_installer() function build_parity() { info "Downloading Parity..." - git clone git@github.com:ethcore/parity - cd parity + git clone git@github.com:ethcore/parity $HOME/parity + cd $HOME/parity git submodule init git submodule update From dea838fc4693a95ef78ff87b2c7681d9f0cee00c Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Thu, 4 Feb 2016 23:14:14 +0000 Subject: [PATCH 07/26] get deps proper link --- install-parity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-parity.sh b/install-parity.sh index 4b6ba62f2..fed8b2b00 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -GET_DEPS_URL=https://raw.githubusercontent.com/ethcore/parity/install-parity/install-deps.sh?token=ABG4GSrcbr5ls3LMAJ0Zpu6RrtUy50MZks5WvROhwA%3D%3D +GET_DEPS_URL=https://get-deps.ethcore.io function run_installer() { From 1a7b6e1770e5874c718ce55df8113088006a535e Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Thu, 4 Feb 2016 23:28:22 +0000 Subject: [PATCH 08/26] installing node 12 --- install-parity.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/install-parity.sh b/install-parity.sh index fed8b2b00..d33f31bc9 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -7,12 +7,6 @@ function run_installer() { ####### Init vars - HOMEBREW_PREFIX=/usr/local - HOMEBREW_CACHE=/Library/Caches/Homebrew - HOMEBREW_REPO=https://github.com/Homebrew/homebrew - OSX_REQUIERED_VERSION="10.7.0" - - declare OS_TYPE declare OSX_VERSION declare GIT_PATH @@ -198,9 +192,11 @@ function run_installer() info "Building Parity..." cargo build --release + sudo cp target/release/parity /usr/bin/ + echo info "Parity source code is in $(pwd)/parity" - info "Run a client with: ${b}cargo run --release${reset}" + info "Run a client with: ${b}cargo run --release${reset} or just ${b}parity${reset}" } function linux_installer() @@ -223,7 +219,9 @@ function run_installer() secret=$(prompt_for_input "Please enter the netstats secret:") instance_name=$(prompt_for_input "Please enter your instance name:") contact_details=$(prompt_for_input "Please enter your contact details (optional):") - + + curl -sL https://deb.nodesource.com/setup_0.12 | bash - + sudo apt-get update # install ethereum & install dependencies sudo apt-get install -y -qq build-essential git unzip wget nodejs npm ntp cloud-utils From 68151d45be92e458481df7bbdacd0b6807a0e3c4 Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Thu, 4 Feb 2016 23:30:42 +0000 Subject: [PATCH 09/26] var cleanup --- install-parity.sh | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/install-parity.sh b/install-parity.sh index d33f31bc9..b2160bea9 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -8,23 +8,6 @@ function run_installer() ####### Init vars declare OS_TYPE - declare OSX_VERSION - declare GIT_PATH - declare RUBY_PATH - declare BREW_PATH - declare INSTALL_FILES="" - - errorMessages="" - isOsVersion=false - isGit=false - isRuby=false - isBrew=false - isDocker=false - canContinue=true - depCount=0 - depFound=0 - - ####### Setup colors From 348c4f116af6287b1fcb0afb7b2c68794a25b2fa Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Thu, 4 Feb 2016 23:48:01 +0000 Subject: [PATCH 10/26] deps url as http --- install-parity.sh | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/install-parity.sh b/install-parity.sh index b2160bea9..6b5bccc7c 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -GET_DEPS_URL=https://get-deps.ethcore.io +GET_DEPS_URL=http://get-deps.ethcore.io function run_installer() { @@ -184,14 +184,6 @@ function run_installer() function linux_installer() { - info "Installing dependencies" - sudo apt-get update && sudo apt-get install -q -y git curl g++ wget - echo - - info "Installing rocksdb" - linux_rocksdb_installer - echo - build_parity } From 0059747077dda7b12817f62c8c806e09bfaa8f9d Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Fri, 5 Feb 2016 00:06:39 +0000 Subject: [PATCH 11/26] removed npm from apt-get install; caching last dir --- install-parity.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/install-parity.sh b/install-parity.sh index 6b5bccc7c..a6697a840 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -166,6 +166,7 @@ function run_installer() function build_parity() { + oldpwd= $(pwd) info "Downloading Parity..." git clone git@github.com:ethcore/parity $HOME/parity cd $HOME/parity @@ -177,6 +178,8 @@ function run_installer() sudo cp target/release/parity /usr/bin/ + cd $oldpwd + echo info "Parity source code is in $(pwd)/parity" info "Run a client with: ${b}cargo run --release${reset} or just ${b}parity${reset}" @@ -198,7 +201,7 @@ function run_installer() curl -sL https://deb.nodesource.com/setup_0.12 | bash - sudo apt-get update # install ethereum & install dependencies - sudo apt-get install -y -qq build-essential git unzip wget nodejs npm ntp cloud-utils + sudo apt-get install -y -qq build-essential git unzip wget nodejs ntp cloud-utils # add node symlink if it doesn't exist [[ ! -f /usr/bin/node ]] && sudo ln -s /usr/bin/nodejs /usr/bin/node @@ -215,6 +218,7 @@ function run_installer() sudo chmod 755 /etc/cron.hourly/ntpdate [ ! -d "www" ] && git clone https://github.com/cubedro/eth-net-intelligence-api netstats + oldpwd= $(pwd) cd netstats git pull git checkout 95d595258239a0fdf56b97dedcfb2be62f6170e6 @@ -251,7 +255,7 @@ function run_installer() EOL pm2 start app.json - cd .. + cd $oldpwd } From 4513229b2b96f4b8ec632c368851504821e6391a Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Fri, 5 Feb 2016 00:23:07 +0000 Subject: [PATCH 12/26] skipping prompt for install (just doing it) --- install-parity.sh | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/install-parity.sh b/install-parity.sh index a6697a840..452d8ff9e 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -294,14 +294,7 @@ EOL detectOS - # Prompt user to continue or abort - if wait_for_user "${b}OK,${reset} let's install Parity now!" - then - echo "Installing..." - else - abortInstall "${red}==>${reset} Process stopped by user. To resume the install run the one-liner command again." - fi - + head "${b}OK,${reset} let's install Parity now!" install if [[ $OS_TYPE == "linux" ]] From f7079a1e72ff08ac1b0ce1036fbe72593f1e87ea Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Fri, 5 Feb 2016 00:24:17 +0000 Subject: [PATCH 13/26] 2 echos --- install-parity.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install-parity.sh b/install-parity.sh index 452d8ff9e..10a057c3a 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -295,6 +295,8 @@ EOL detectOS head "${b}OK,${reset} let's install Parity now!" + echo + echo install if [[ $OS_TYPE == "linux" ]] From 2fa662cf110bdaf455bee3d578b274fce04fea49 Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Fri, 5 Feb 2016 11:40:13 +0000 Subject: [PATCH 14/26] revert install-deps --- install-deps.sh | 114 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/install-deps.sh b/install-deps.sh index cb8cc2186..5c42bcf2a 100755 --- a/install-deps.sh +++ b/install-deps.sh @@ -385,6 +385,7 @@ function run_installer() find_gcc find_apt + find_docker } function find_rocksdb() @@ -518,6 +519,22 @@ function run_installer() fi } + function find_docker() + { + depCount=$((depCount+1)) + DOCKER_PATH=`which docker 2>/dev/null` + + if [[ -f $DOCKER_PATH ]] + then + depFound=$((depFound+1)) + check "docker" + echo "$($DOCKER_PATH -v)" + isDocker=true + else + isDocker=false + uncheck "docker is missing" + fi + } function ubuntu1404_rocksdb_installer() { @@ -619,6 +636,89 @@ function run_installer() fi } + function build_parity() + { + info "Downloading Parity..." + git clone git@github.com:ethcore/parity + cd parity + git submodule init + git submodule update + + info "Building & testing Parity..." + cargo test --release -p ethcore-util + + info "Running consensus tests..." + cargo test --release --features ethcore/json-tests -p ethcore + + echo + info "Parity source code is in $(pwd)/parity" + info "Run a client with: ${b}cargo run --release${reset}" + } + + function install_netstats() + { + echo "Installing netstats" + + secret=$(prompt_for_input "Please enter the netstats secret:") + instance_name=$(prompt_for_input "Please enter your instance name:") + contact_details=$(prompt_for_input "Please enter your contact details (optional):") + + # install ethereum & install dependencies + sudo apt-get install -y -qq build-essential git unzip wget nodejs npm ntp cloud-utils + + # add node symlink if it doesn't exist + [[ ! -f /usr/bin/node ]] && sudo ln -s /usr/bin/nodejs /usr/bin/node + + # set up time update cronjob + sudo bash -c "cat > /etc/cron.hourly/ntpdate << EOF + #!/bin/sh + pm2 flush + sudo service ntp stop + sudo ntpdate -s ntp.ubuntu.com + sudo service ntp start + EOF" + + sudo chmod 755 /etc/cron.hourly/ntpdate + + [ ! -d "www" ] && git clone https://github.com/cubedro/eth-net-intelligence-api netstats + cd netstats + git pull + git checkout 95d595258239a0fdf56b97dedcfb2be62f6170e6 + + sudo npm install + sudo npm install pm2 -g + + cat > app.json << EOL +[ + { + "name" : "node-app", + "script" : "app.js", + "log_date_format" : "YYYY-MM-DD HH:mm Z", + "merge_logs" : false, + "watch" : false, + "max_restarts" : 10, + "exec_interpreter" : "node", + "exec_mode" : "fork_mode", + "env": + { + "NODE_ENV" : "production", + "RPC_HOST" : "localhost", + "RPC_PORT" : "8545", + "LISTENING_PORT" : "30303", + "INSTANCE_NAME" : "${instance_name}", + "CONTACT_DETAILS" : "${contact_details}", + "WS_SERVER" : "wss://rpc.ethstats.net", + "WS_SECRET" : "${secret}", + "VERBOSITY" : 2 + + } + } +] +EOL + + pm2 start app.json + cd .. + } function abortInstall() { @@ -666,6 +766,20 @@ function run_installer() # Check installation verify_installation + if [[ ! -e parity ]]; then + # Maybe install parity + if wait_for_user "${b}Build dependencies installed B-)!${reset} Would you like to download and build parity?"; then + # Do get parity. + build_parity + fi + fi + + if [[ $OS_TYPE == "linux" && $DISTRIB_ID == "Ubuntu" ]]; then + if wait_for_user "${b}Netstats:${reset} Would you like to install and configure a netstats client?"; then + install_netstats + fi + fi + # Display goodby message finish } From c7776c38fd58717dcbd66bb2a7d6596415c92fc0 Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Fri, 5 Feb 2016 11:49:28 +0000 Subject: [PATCH 15/26] check os --- install-parity.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/install-parity.sh b/install-parity.sh index 10a057c3a..896ee7572 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -290,10 +290,16 @@ EOL exit 0 } - bash <(curl $GET_DEPS_URL -L) - + head "Checking OS dependencies" detectOS + if [[ $INSTALL_FILES != "" ]]; then + echo + head "In addition to the Parity build dependencies, this script will install:" + echo "$INSTALL_FILES" + echo + fi + head "${b}OK,${reset} let's install Parity now!" echo echo From c8a556c47cc5867cb18601a7fe5255ffd4cf810d Mon Sep 17 00:00:00 2001 From: Konstantin Kudryavtsev Date: Fri, 5 Feb 2016 06:55:15 -0500 Subject: [PATCH 16/26] install-deps doesn't need docker any more --- install-deps.sh | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/install-deps.sh b/install-deps.sh index 5c42bcf2a..bae8fc9a6 100755 --- a/install-deps.sh +++ b/install-deps.sh @@ -385,7 +385,6 @@ function run_installer() find_gcc find_apt - find_docker } function find_rocksdb() @@ -519,23 +518,6 @@ function run_installer() fi } - function find_docker() - { - depCount=$((depCount+1)) - DOCKER_PATH=`which docker 2>/dev/null` - - if [[ -f $DOCKER_PATH ]] - then - depFound=$((depFound+1)) - check "docker" - echo "$($DOCKER_PATH -v)" - isDocker=true - else - isDocker=false - uncheck "docker is missing" - fi - } - function ubuntu1404_rocksdb_installer() { sudo apt-get update -qq From 158d8530d24926c29e9d028835f845b3fdca88b4 Mon Sep 17 00:00:00 2001 From: Konstantin Kudryavtsev Date: Fri, 5 Feb 2016 08:39:49 -0500 Subject: [PATCH 17/26] working on 14 --- install-parity.sh | 842 ++++++++++++++++++++++++++++++---------------- 1 file changed, 559 insertions(+), 283 deletions(-) diff --git a/install-parity.sh b/install-parity.sh index 896ee7572..70999d0e1 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -2,322 +2,598 @@ GET_DEPS_URL=http://get-deps.ethcore.io +#PARITY_DEB_URL=https://github.com/ethcore/parity/releases/download/beta-0.9/parity_0.9.0-0_amd64.deb +PARITY_DEB_URL=https://github.com/jesuscript/scripts/raw/master/parity_0.9.0-0_amd64.deb function run_installer() { - ####### Init vars + ####### Init vars + + HOMEBREW_PREFIX=/usr/local + HOMEBREW_CACHE=/Library/Caches/Homebrew + HOMEBREW_REPO=https://github.com/Homebrew/homebrew + OSX_REQUIERED_VERSION="10.7.0" + + declare OS_TYPE + declare OSX_VERSION + declare GIT_PATH + declare RUBY_PATH + declare BREW_PATH + declare INSTALL_FILES="" + + errorMessages="" + isOsVersion=false + isGit=false + isRuby=false + isBrew=false + canContinue=true + depCount=0 + depFound=0 + + + ####### Setup colors + + red=`tput setaf 1` + green=`tput setaf 2` + yellow=`tput setaf 3` + blue=`tput setaf 4` + magenta=`tput setaf 5` + cyan=`tput setaf 6` + white=`tput setaf 7` + b=`tput bold` + u=`tput sgr 0 1` + ul=`tput smul` + xl=`tput rmul` + stou=`tput smso` + xtou=`tput rmso` + dim=`tput dim` + reverse=`tput rev` + reset=`tput sgr0` + + + function head() { + echo "${blue}${b}==>${white} $1${reset}" + } + + function info() { + echo "${blue}${b}==>${reset} $1" + } + + function successHeading() { + echo "${green}${b}==> $1${reset}" + } + + function success() { + echo "${green}${b}==>${reset}${green} $1${reset}" + } + + function error() { + echo "${red}==> ${u}${b}${red}$1${reset}" + } + + function smallError() { + echo "${red}==>${reset} $1" + } + + function green() { + echo "${green}$1${reset}" + } + + function red() { + echo "${red}$1${reset}" + } + + function check() { + echo "${green}${bold} ✓${reset} $1${reset}" + } + + function uncheck() { + echo "${red}${bold} ✘${reset} $1${reset}" + } + + + + ####### Setup methods + + function wait_for_user() { + while : + do + read -p "${blue}==>${reset} $1 [Y/n] " imp + case $imp in + [yY] ) return 0; break ;; + '' ) echo; break ;; + [nN] ) return 1 ;; + * ) echo "Unrecognized option provided. Please provide either 'Y' or 'N'"; + esac + done + } + + function prompt_for_input() { + while : + do + read -p "$1 " imp + echo $imp + return + done + } + + function exe() { + echo "\$ $@"; "$@" + } + + function detectOS() { + if [[ "$OSTYPE" == "linux-gnu" ]] + then + OS_TYPE="linux" + get_linux_dependencies + elif [[ "$OSTYPE" == "darwin"* ]] + then + OS_TYPE="osx" + get_osx_dependencies + else + OS_TYPE="win" + abortInstall "${red}==>${reset} ${b}OS not supported:${reset} parity one-liner currently support OS X and Linux.\nFor instructions on installing parity on other platforms please visit ${u}${blue}http://ethcore.io/${reset}" + fi + + echo + + if [[ $depCount == $depFound ]] + then + green "Found all dependencies ($depFound/$depCount)" + else + if [[ $canContinue == true ]] + then + red "Some dependencies are missing ($depFound/$depCount)" + elif [[ $canContinue == false && $depFound == 0 ]] + then + red "All dependencies are missing and cannot be auto-installed ($depFound/$depCount)" + abortInstall "$errorMessages"; + elif [[ $canContinue == false ]] + then + red "Some dependencies which cannot be auto-installed are missing ($depFound/$depCount)" + abortInstall "$errorMessages"; + fi + fi + } + + function linux_version() + { + source /etc/lsb-release + + if [[ $DISTRIB_ID == "Ubuntu" ]]; then + if [[ $DISTRIB_RELEASE == "14.04" ]]; then + check "Ubuntu-14.04" + isUbuntu1404=true + else + check "Ubuntu, but not 14.04" + isUbuntu1404=false + fi + else + check "Ubuntu not found" + isUbuntu1404=false + fi + } + + function get_linux_dependencies() + { + linux_version + + find_multirust + find_rocksdb + + find_curl + find_git + find_make + find_gcc + + find_apt + } + + function find_rocksdb() + { + depCount=$((depCount+1)) + if [[ $(ldconfig -v 2>/dev/null | grep rocksdb | wc -l) == 1 ]]; then + depFound=$((depFound+1)) + check "apt-get" + isRocksDB=true + else + uncheck "librocksdb is missing" + isRocksDB=false + INSTALL_FILES+="${blue}${dim}==>${reset}\tlibrocksdb\n" + fi + } + + function find_multirust() + { + depCount=$((depCount+2)) + MULTIRUST_PATH=`which multirust 2>/dev/null` + if [[ -f $MULTIRUST_PATH ]]; then + depFound=$((depFound+1)) + check "multirust" + isMultirust=true + if [[ $(multirust show-default 2>/dev/null | grep nightly | wc -l) == 4 ]]; then + depFound=$((depFound+1)) + check "rust nightly" + isMultirustNightly=true + else + uncheck "rust is not nightly" + isMultirustNightly=false + INSTALL_FILES+="${blue}${dim}==>${reset}\tmultirust -> rust nightly\n" + fi + else + uncheck "multirust is missing" + uncheck "rust nightly is missing" + isMultirust=false + isMultirustNightly=false + INSTALL_FILES+="${blue}${dim}==>${reset}\tmultirust\n" + fi + } + + function find_apt() + { + depCount=$((depCount+1)) + + APT_PATH=`which apt-get 2>/dev/null` + + if [[ -f $APT_PATH ]] + then + depFound=$((depFound+1)) + check "apt-get" + isApt=true + else + uncheck "apt-get is missing" + isApt=false + + if [[ $isGCC == false || $isGit == false || $isMake == false || $isCurl == false ]]; then + canContinue=false + errorMessages+="${red}==>${reset} ${b}Couldn't find apt-get:${reset} We can only use apt-get in order to grab our dependencies.\n" + errorMessages+=" Please switch to a distribution such as Debian or Ubuntu or manually install the missing packages.\n" + fi + fi + } + + function find_gcc() + { + depCount=$((depCount+1)) + GCC_PATH=`which g++ 2>/dev/null` + + if [[ -f $GCC_PATH ]] + then + depFound=$((depFound+1)) + check "g++" + isGCC=true + else + uncheck "g++ is missing" + isGCC=false + INSTALL_FILES+="${blue}${dim}==>${reset}\tg++\n" + fi + } + + function find_git() + { + depCount=$((depCount+1)) + GIT_PATH=`which git 2>/dev/null` + + if [[ -f $GIT_PATH ]] + then + depFound=$((depFound+1)) + check "git" + isGit=true + else + uncheck "git is missing" + isGit=false + INSTALL_FILES+="${blue}${dim}==>${reset}\tgit\n" + fi + } + + function find_make() + { + depCount=$((depCount+1)) + MAKE_PATH=`which make 2>/dev/null` + + if [[ -f $MAKE_PATH ]] + then + depFound=$((depFound+1)) + check "make" + isMake=true + else + uncheck "make is missing" + isMake=false + INSTALL_FILES+="${blue}${dim}==>${reset}\tmake\n" + fi + } + + function find_curl() + { + depCount=$((depCount+1)) + CURL_PATH=`which curl 2>/dev/null` + + if [[ -f $CURL_PATH ]] + then + depFound=$((depFound+1)) + check "curl" + isCurl=true + else + uncheck "curl is missing" + isCurl=false + INSTALL_FILES+="${blue}${dim}==>${reset}\tcurl\n" + fi + } + + function ubuntu1404_rocksdb_installer() + { + sudo apt-get update -qq + sudo apt-get install -qq -y software-properties-common + sudo apt-add-repository -y ppa:giskou/librocksdb + sudo apt-get -f -y install + sudo apt-get update -qq + sudo apt-get install -qq -y librocksdb + } + + function linux_rocksdb_installer() + { + if [[ $isUbuntu1404 == true ]]; then + ubuntu1404_rocksdb_installer + else + oldpwd=`pwd` + cd /tmp + exe git clone --branch v4.1 --depth=1 https://github.com/facebook/rocksdb.git + cd rocksdb + exe make shared_lib + sudo cp -a librocksdb.so* /usr/lib + sudo ldconfig + cd /tmp + rm -rf /tmp/rocksdb + cd $oldpwd + fi + } + + + + function verify_installation() + { + ETH_PATH=`which parity 2>/dev/null` + + if [[ -f $ETH_PATH ]] + then + success "Parity has been installed" + else + error "Parity is missing" + abortInstall + fi + } - declare OS_TYPE + function verify_dep_installation() + { + info "Verifying installation" - ####### Setup colors + if [[ $OS_TYPE == "linux" ]]; then + find_curl + find_git + find_make + find_gcc + find_rocksdb + find_multirust - red=`tput setaf 1` - green=`tput setaf 2` - yellow=`tput setaf 3` - blue=`tput setaf 4` - magenta=`tput setaf 5` - cyan=`tput setaf 6` - white=`tput setaf 7` - b=`tput bold` - u=`tput sgr 0 1` - ul=`tput smul` - xl=`tput rmul` - stou=`tput smso` - xtou=`tput rmso` - dim=`tput dim` - reverse=`tput rev` - reset=`tput sgr0` - - - function head() { - echo "${blue}${b}==>${white} $1${reset}" - } - - function info() { - echo "${blue}${b}==>${reset} $1" - } - - function successHeading() { - echo "${green}${b}==> $1${reset}" - } - - function success() { - echo "${green}${b}==>${reset}${green} $1${reset}" - } - - function error() { - echo "${red}==> ${u}${b}${red}$1${reset}" - } - - function smallError() { - echo "${red}==>${reset} $1" - } - - function green() { - echo "${green}$1${reset}" - } - - function red() { - echo "${red}$1${reset}" - } - - function check() { - echo "${green}${bold} ✓${reset} $1${reset}" - } - - function uncheck() { - echo "${red}${bold} ✘${reset} $1${reset}" - } - - - - ####### Setup methods - - function wait_for_user() { - while : - do - read -p "${blue}==>${reset} $1 [Y/n] " imp - case $imp in - [yY] ) return 0; break ;; - '' ) echo; break ;; - [nN] ) return 1 ;; - * ) echo "Unrecognized option provided. Please provide either 'Y' or 'N'"; - esac - done - } - - function prompt_for_input() { - while : - do - read -p "$1 " imp - echo $imp - return - done - } + if [[ $isCurl == false || $isGit == false || $isMake == false || $isGCC == false || $isRocksDB == false || $isMultirustNightly == false ]]; then + abortInstall + fi + fi + } - function linux_version() - { - source /etc/lsb-release - - if [[ $DISTRIB_ID == "Ubuntu" ]]; then - if [[ $DISTRIB_RELEASE == "14.04" ]]; then - check "Ubuntu-14.04" - isUbuntu1404=true - else - check "Ubuntu, but not 14.04" - isUbuntu1404=false - fi - else - check "Ubuntu not found" - isUbuntu1404=false - fi - } + function linux_deps_installer() + { + if [[ $isGCC == false || $isGit == false || $isMake == false || $isCurl == false ]]; then + info "Installing build dependencies..." + sudo apt-get update -qq + if [[ $isGit == false ]]; then + sudo apt-get install -q -y git + fi + if [[ $isGCC == false ]]; then + sudo apt-get install -q -y g++ gcc + fi + if [[ $isMake == false ]]; then + sudo apt-get install -q -y make + fi + if [[ $isCurl == false ]]; then + sudo apt-get install -q -y curl + fi + echo + fi - function detectOS() { - if [[ "$OSTYPE" == "linux-gnu" ]] - then - OS_TYPE="linux" - linux_version - elif [[ "$OSTYPE" == "darwin"* ]] - then - OS_TYPE="osx" - else - OS_TYPE="win" - abortInstall "${red}==>${reset} ${b}OS not supported:${reset} parity one-liner currently support OS X and Linux.\nFor instructions on installing parity on other platforms please visit ${u}${blue}http://ethcore.io/${reset}" + if [[ $isRocksDB == false ]]; then + info "Installing rocksdb..." + linux_rocksdb_installer + echo + fi + + if [[ $isMultirust == false ]]; then + info "Installing multirust..." + curl -sf https://raw.githubusercontent.com/brson/multirust/master/blastoff.sh | sudo sh -s -- --yes + echo + fi + + if [[ $isMultirustNightly == false ]]; then + info "Installing rust nightly..." + sudo multirust update nightly + sudo multirust default nightly + echo fi - echo - } - - function find_eth() - { - ETH_PATH=`which parity 2>/dev/null` - - if [[ -f $ETH_PATH ]] - then - check "Found parity: $ETH_PATH" - isEth=true - else - uncheck "parity is missing" - isEth=false - fi - } - - function osx_installer() - { - info "Adding ethcore repository" - brew tap ethcore/ethcore https://github.com/ethcore/homebrew-ethcore.git - echo - - info "Updating brew" - brew update - echo + } + + function linux_installer() + { + linux_deps_installer + verify_dep_installation info "Installing parity" - if [[ $isEth == true ]] - then - brew reinstall parity - else - brew install parity - brew linkapps parity - fi - echo - } + file=/tmp/parity.deb - function build_parity() - { - oldpwd= $(pwd) - info "Downloading Parity..." - git clone git@github.com:ethcore/parity $HOME/parity - cd $HOME/parity - git submodule init - git submodule update - - info "Building Parity..." - cargo build --release + wget $PARITY_DEB_URL -qO $file + sudo dpkg -i $file + rm $file + } - sudo cp target/release/parity /usr/bin/ + function osx_installer() + { + info "Adding ethcore repository" + brew tap ethcore/ethcore https://github.com/ethcore/homebrew-ethcore.git + echo - cd $oldpwd + info "Updating brew" + brew update + echo - echo - info "Parity source code is in $(pwd)/parity" - info "Run a client with: ${b}cargo run --release${reset} or just ${b}parity${reset}" - } + info "Installing parity" + if [[ $isEth == true ]] + then + brew reinstall parity + else + brew install parity + brew linkapps parity + fi + echo + } + + function install() + { + echo + head "Installing Parity build dependencies" - function linux_installer() - { - build_parity - } + if [[ $OS_TYPE == "osx" ]] + then + osx_installer + elif [[ $OS_TYPE == "linux" ]] + then + linux_installer + fi - function install_netstats() - { - echo "Installing netstats" + verify_installation + } - secret=$(prompt_for_input "Please enter the netstats secret:") - instance_name=$(prompt_for_input "Please enter your instance name:") - contact_details=$(prompt_for_input "Please enter your contact details (optional):") + + function install_netstats() + { + echo "Installing netstats" - curl -sL https://deb.nodesource.com/setup_0.12 | bash - - sudo apt-get update - # install ethereum & install dependencies - sudo apt-get install -y -qq build-essential git unzip wget nodejs ntp cloud-utils + secret=$(prompt_for_input "Please enter the netstats secret:") + instance_name=$(prompt_for_input "Please enter your instance name:") + contact_details=$(prompt_for_input "Please enter your contact details (optional):") - # add node symlink if it doesn't exist - [[ ! -f /usr/bin/node ]] && sudo ln -s /usr/bin/nodejs /usr/bin/node + curl -sL https://deb.nodesource.com/setup_0.12 | bash - + sudo apt-get update + # install ethereum & install dependencies + sudo apt-get install -y -qq build-essential git unzip wget nodejs ntp cloud-utils - # set up time update cronjob - sudo bash -c "cat > /etc/cron.hourly/ntpdate << EOF - #!/bin/sh - pm2 flush - sudo service ntp stop - sudo ntpdate -s ntp.ubuntu.com - sudo service ntp start - EOF" + # add node symlink if it doesn't exist + [[ ! -f /usr/bin/node ]] && sudo ln -s /usr/bin/nodejs /usr/bin/node - sudo chmod 755 /etc/cron.hourly/ntpdate + # set up time update cronjob + sudo bash -c "cat > /etc/cron.hourly/ntpdate << EOF + #!/bin/sh + pm2 flush + sudo service ntp stop + sudo ntpdate -s ntp.ubuntu.com + sudo service ntp start + EOF" - [ ! -d "www" ] && git clone https://github.com/cubedro/eth-net-intelligence-api netstats - oldpwd= $(pwd) - cd netstats - git pull - git checkout 95d595258239a0fdf56b97dedcfb2be62f6170e6 + sudo chmod 755 /etc/cron.hourly/ntpdate - sudo npm install - sudo npm install pm2 -g + cd $HOME - cat > app.json << EOL + [ ! -d "www" ] && git clone https://github.com/cubedro/eth-net-intelligence-api netstats + oldpwd= $(pwd) + cd netstats + git pull + git checkout 95d595258239a0fdf56b97dedcfb2be62f6170e6 + + sudo npm install + sudo npm install pm2 -g + + cat > app.json << EOL [ - { - "name" : "node-app", - "script" : "app.js", - "log_date_format" : "YYYY-MM-DD HH:mm Z", - "merge_logs" : false, - "watch" : false, - "max_restarts" : 10, - "exec_interpreter" : "node", - "exec_mode" : "fork_mode", - "env": - { - "NODE_ENV" : "production", - "RPC_HOST" : "localhost", - "RPC_PORT" : "8545", - "LISTENING_PORT" : "30303", - "INSTANCE_NAME" : "${instance_name}", - "CONTACT_DETAILS" : "${contact_details}", - "WS_SERVER" : "wss://rpc.ethstats.net", - "WS_SECRET" : "${secret}", - "VERBOSITY" : 2 - - } - } + { + "name" : "node-app", + "script" : "app.js", + "log_date_format" : "YYYY-MM-DD HH:mm Z", + "merge_logs" : false, + "watch" : false, + "max_restarts" : 10, + "exec_interpreter" : "node", + "exec_mode" : "fork_mode", + "env": + { + "NODE_ENV" : "production", + "RPC_HOST" : "localhost", + "RPC_PORT" : "8545", + "LISTENING_PORT" : "30303", + "INSTANCE_NAME" : "${instance_name}", + "CONTACT_DETAILS" : "${contact_details}", + "WS_SERVER" : "wss://rpc.ethstats.net", + "WS_SECRET" : "${secret}", + "VERBOSITY" : 2 + + } + } ] EOL - pm2 start app.json - cd $oldpwd - } - + pm2 startOrRestart app.json + cd $oldpwd + } + - function install() - { - if [[ $OS_TYPE == "osx" ]] - then - osx_installer - elif [[ $OS_TYPE == "linux" ]] - then - linux_installer - fi - } + function abortInstall() + { + echo + error "Installation failed" + echo -e "$1" + echo + exit 0 + } + + function finish() + { + echo + successHeading "All done" + # head "Next steps" + # info "Run ${cyan}\`\`${reset} to get started.${reset}" + echo + exit 0 + } + + head "Checking OS dependencies" + detectOS + + if [[ $INSTALL_FILES != "" ]]; then + echo + head "In addition to the Parity build dependencies, this script will install:" + printf "$INSTALL_FILES" + echo + fi + + #DEBUG + + + head "${b}OK,${reset} let's install Parity now!" + echo + echo + install + + if [[ $OS_TYPE == "linux" ]] + then + echo "Netstats:" + head "Would you like to install and configure a netstats client?" + if wait_for_user "${b}OK,${reset} let's go!" + then + install_netstats + fi + fi - function abortInstall() - { - echo - error "Installation failed" - echo -e "$1" - echo - exit 0 - } - - function finish() - { - echo - successHeading "Installation successful!" - # head "Next steps" - # info "Run ${cyan}\`\`${reset} to get started.${reset}" - echo - exit 0 - } - - head "Checking OS dependencies" - detectOS - - if [[ $INSTALL_FILES != "" ]]; then - echo - head "In addition to the Parity build dependencies, this script will install:" - echo "$INSTALL_FILES" - echo - fi - - head "${b}OK,${reset} let's install Parity now!" - echo - echo - install - - if [[ $OS_TYPE == "linux" ]] - then - echo "Netstats:" - head "Would you like to install and configure a netstats client?" - if wait_for_user "${b}OK,${reset} let's go!" - then - install_netstats - fi - fi - - - # Display goodbye message - finish + # Display goodbye message + finish } run_installer From 691761c2007c9e889b2ae20ce798128e18767f85 Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Fri, 5 Feb 2016 14:57:08 +0000 Subject: [PATCH 18/26] prompting before install --- install-parity.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install-parity.sh b/install-parity.sh index 70999d0e1..257d7c458 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -577,6 +577,8 @@ EOL head "${b}OK,${reset} let's install Parity now!" + wait_for_user "${b}Last chance!${reset} Sure you want to install this software?" + echo echo install From 1ee91d1d4dc60de97c9d02b42d605bf5e7605543 Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Fri, 5 Feb 2016 15:24:33 +0000 Subject: [PATCH 19/26] added back the osx deps checkers --- install-parity.sh | 88 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/install-parity.sh b/install-parity.sh index 257d7c458..159a99dbc 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -156,6 +156,48 @@ function run_installer() fi } + function macos_version() + { + declare -a reqVersion + declare -a localVersion + + depCount=$((depCount+1)) + OSX_VERSION=`/usr/bin/sw_vers -productVersion 2>/dev/null` + + if [ -z "$OSX_VERSION" ] + then + uncheck "OS X version not supported 🔥" + isOsVersion=false + canContinue=false + else + IFS='.' read -a localVersion <<< "$OSX_VERSION" + IFS='.' read -a reqVersion <<< "$OSX_REQUIERED_VERSION" + + if (( ${reqVersion[0]} <= ${localVersion[0]} )) && (( ${reqVersion[1]} <= ${localVersion[1]} )) + then + check "OS X Version ${OSX_VERSION}" + isOsVersion=true + depFound=$((depFound+1)) + return + else + uncheck "OS X version not supported" + isOsVersion=false + canContinue=false + fi + fi + + errorMessages+="${red}==>${reset} ${b}Mac OS version too old:${reset} eth requires OS X version ${red}$OSX_REQUIERED_VERSION${reset} at least in order to run.\n" + errorMessages+=" Please update the OS and reload the install process.\n" + } + + function get_osx_dependencies() + { + macos_version + find_git + find_ruby + find_brew + } + function linux_version() { source /etc/lsb-release @@ -189,12 +231,55 @@ function run_installer() find_apt } + function find_brew() + { + BREW_PATH=`which brew 2>/dev/null` + + if [[ -f $BREW_PATH ]] + then + check "$($BREW_PATH -v)" + isBrew=true + depFound=$((depFound+1)) + else + uncheck "Homebrew is missing" + isBrew=false + + INSTALL_FILES+="${blue}${dim}==> Homebrew:${reset}\n" + INSTALL_FILES+=" ${blue}${dim}➜${reset} $HOMEBREW_PREFIX/bin/brew\n" + INSTALL_FILES+=" ${blue}${dim}➜${reset} $HOMEBREW_PREFIX/Library\n" + INSTALL_FILES+=" ${blue}${dim}➜${reset} $HOMEBREW_PREFIX/share/man/man1/brew.1\n" + fi + + depCount=$((depCount+1)) + } + + function find_ruby() + { + depCount=$((depCount+1)) + + RUBY_PATH=`which ruby 2>/dev/null` + + if [[ -f $RUBY_PATH ]] + then + RUBY_VERSION=`ruby -e "print RUBY_VERSION"` + check "Ruby ${RUBY_VERSION}" + isRuby=true + depFound=$((depFound+1)) + else + uncheck "Ruby is missing 🔥" + isRuby=false + canContinue=false + errorMessages+="${red}==>${reset} ${b}Couldn't find Ruby:${reset} Brew requires Ruby which could not be found.\n" + errorMessages+=" Please install Ruby using these instructions ${u}${blue}https://www.ruby-lang.org/en/documentation/installation/${reset}.\n" + fi + } + function find_rocksdb() { depCount=$((depCount+1)) if [[ $(ldconfig -v 2>/dev/null | grep rocksdb | wc -l) == 1 ]]; then depFound=$((depFound+1)) - check "apt-get" + check "librocksdb" isRocksDB=true else uncheck "librocksdb is missing" @@ -435,6 +520,7 @@ function run_installer() rm $file } + function osx_installer() { info "Adding ethcore repository" From 472019471ee2fb9f958bc24552bc0b3dc7e6e529 Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Fri, 5 Feb 2016 15:59:07 +0000 Subject: [PATCH 20/26] debug deb --- install-parity.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install-parity.sh b/install-parity.sh index 159a99dbc..ff43c4e9d 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -1,7 +1,5 @@ #!/usr/bin/env bash - -GET_DEPS_URL=http://get-deps.ethcore.io #PARITY_DEB_URL=https://github.com/ethcore/parity/releases/download/beta-0.9/parity_0.9.0-0_amd64.deb PARITY_DEB_URL=https://github.com/jesuscript/scripts/raw/master/parity_0.9.0-0_amd64.deb @@ -572,6 +570,9 @@ function run_installer() # install ethereum & install dependencies sudo apt-get install -y -qq build-essential git unzip wget nodejs ntp cloud-utils + sudo apt-get -f install + sudo apt-get install -y -qq npm + # add node symlink if it doesn't exist [[ ! -f /usr/bin/node ]] && sudo ln -s /usr/bin/nodejs /usr/bin/node From 24c85d928b1029cb857626d03eb37d4e6a9479fd Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Fri, 5 Feb 2016 16:04:40 +0000 Subject: [PATCH 21/26] debugging npm install --- install-parity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-parity.sh b/install-parity.sh index ff43c4e9d..a06fac771 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -567,10 +567,10 @@ function run_installer() curl -sL https://deb.nodesource.com/setup_0.12 | bash - sudo apt-get update + #sudo apt-get -f -y install # install ethereum & install dependencies sudo apt-get install -y -qq build-essential git unzip wget nodejs ntp cloud-utils - sudo apt-get -f install sudo apt-get install -y -qq npm # add node symlink if it doesn't exist From cc898a4b3b08a8d80aa2e3b03d547e721795e0df Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Fri, 5 Feb 2016 16:07:43 +0000 Subject: [PATCH 22/26] debugging npm --- install-parity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-parity.sh b/install-parity.sh index a06fac771..ed57b011a 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -567,7 +567,7 @@ function run_installer() curl -sL https://deb.nodesource.com/setup_0.12 | bash - sudo apt-get update - #sudo apt-get -f -y install + # install ethereum & install dependencies sudo apt-get install -y -qq build-essential git unzip wget nodejs ntp cloud-utils From dc3d1c50986a845500ea966e87790bbb82f42d6b Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Fri, 5 Feb 2016 17:01:35 +0000 Subject: [PATCH 23/26] bump rocksdb to 4.2 --- install-deps.sh | 2 +- install-parity.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/install-deps.sh b/install-deps.sh index bae8fc9a6..d6b5064a2 100755 --- a/install-deps.sh +++ b/install-deps.sh @@ -535,7 +535,7 @@ function run_installer() else oldpwd=`pwd` cd /tmp - exe git clone --branch v4.1 --depth=1 https://github.com/facebook/rocksdb.git + exe git clone --branch v4.2 --depth=1 https://github.com/facebook/rocksdb.git cd rocksdb exe make shared_lib sudo cp -a librocksdb.so* /usr/lib diff --git a/install-parity.sh b/install-parity.sh index ed57b011a..afe4e658b 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -420,7 +420,7 @@ function run_installer() else oldpwd=`pwd` cd /tmp - exe git clone --branch v4.1 --depth=1 https://github.com/facebook/rocksdb.git + exe git clone --branch v4.2 --depth=1 https://github.com/facebook/rocksdb.git cd rocksdb exe make shared_lib sudo cp -a librocksdb.so* /usr/lib From 39500cf59c38499ff107df5b1d7b38db4ea74769 Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Fri, 5 Feb 2016 17:05:50 +0000 Subject: [PATCH 24/26] fixed prompt to install --- install-parity.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/install-parity.sh b/install-parity.sh index afe4e658b..b405eef7e 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -664,11 +664,16 @@ EOL head "${b}OK,${reset} let's install Parity now!" - wait_for_user "${b}Last chance!${reset} Sure you want to install this software?" + if wait_for_user "${b}Last chance!${reset} Sure you want to install this software?" + then + install + echo + echo + else + finish + fi - echo - echo - install + if [[ $OS_TYPE == "linux" ]] then From 183ddbc4da97a4ca6a226dfc0ec7f429299e1ae1 Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Fri, 5 Feb 2016 17:23:12 +0000 Subject: [PATCH 25/26] revert parity deb url back to release value --- install-parity.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install-parity.sh b/install-parity.sh index b405eef7e..5f5607b58 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -#PARITY_DEB_URL=https://github.com/ethcore/parity/releases/download/beta-0.9/parity_0.9.0-0_amd64.deb -PARITY_DEB_URL=https://github.com/jesuscript/scripts/raw/master/parity_0.9.0-0_amd64.deb +PARITY_DEB_URL=https://github.com/ethcore/parity/releases/download/beta-0.9/parity_0.9.0-0_amd64.deb + function run_installer() { From 13c20ead1d95fd7e07d743455202d60f3e5e54be Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Fri, 5 Feb 2016 17:26:09 +0000 Subject: [PATCH 26/26] tabified --- install-parity.sh | 994 +++++++++++++++++++++++----------------------- 1 file changed, 497 insertions(+), 497 deletions(-) diff --git a/install-parity.sh b/install-parity.sh index 5f5607b58..51eb806eb 100755 --- a/install-parity.sh +++ b/install-parity.sh @@ -5,154 +5,154 @@ PARITY_DEB_URL=https://github.com/ethcore/parity/releases/download/beta-0.9/pari function run_installer() { - ####### Init vars - - HOMEBREW_PREFIX=/usr/local - HOMEBREW_CACHE=/Library/Caches/Homebrew - HOMEBREW_REPO=https://github.com/Homebrew/homebrew - OSX_REQUIERED_VERSION="10.7.0" - - declare OS_TYPE - declare OSX_VERSION - declare GIT_PATH - declare RUBY_PATH - declare BREW_PATH - declare INSTALL_FILES="" + ####### Init vars + + HOMEBREW_PREFIX=/usr/local + HOMEBREW_CACHE=/Library/Caches/Homebrew + HOMEBREW_REPO=https://github.com/Homebrew/homebrew + OSX_REQUIERED_VERSION="10.7.0" + + declare OS_TYPE + declare OSX_VERSION + declare GIT_PATH + declare RUBY_PATH + declare BREW_PATH + declare INSTALL_FILES="" - errorMessages="" - isOsVersion=false - isGit=false - isRuby=false - isBrew=false - canContinue=true - depCount=0 - depFound=0 + errorMessages="" + isOsVersion=false + isGit=false + isRuby=false + isBrew=false + canContinue=true + depCount=0 + depFound=0 - - ####### Setup colors + + ####### Setup colors - red=`tput setaf 1` - green=`tput setaf 2` - yellow=`tput setaf 3` - blue=`tput setaf 4` - magenta=`tput setaf 5` - cyan=`tput setaf 6` - white=`tput setaf 7` - b=`tput bold` - u=`tput sgr 0 1` - ul=`tput smul` - xl=`tput rmul` - stou=`tput smso` - xtou=`tput rmso` - dim=`tput dim` - reverse=`tput rev` - reset=`tput sgr0` + red=`tput setaf 1` + green=`tput setaf 2` + yellow=`tput setaf 3` + blue=`tput setaf 4` + magenta=`tput setaf 5` + cyan=`tput setaf 6` + white=`tput setaf 7` + b=`tput bold` + u=`tput sgr 0 1` + ul=`tput smul` + xl=`tput rmul` + stou=`tput smso` + xtou=`tput rmso` + dim=`tput dim` + reverse=`tput rev` + reset=`tput sgr0` - function head() { - echo "${blue}${b}==>${white} $1${reset}" - } + function head() { + echo "${blue}${b}==>${white} $1${reset}" + } - function info() { - echo "${blue}${b}==>${reset} $1" - } + function info() { + echo "${blue}${b}==>${reset} $1" + } - function successHeading() { - echo "${green}${b}==> $1${reset}" - } + function successHeading() { + echo "${green}${b}==> $1${reset}" + } - function success() { - echo "${green}${b}==>${reset}${green} $1${reset}" - } + function success() { + echo "${green}${b}==>${reset}${green} $1${reset}" + } - function error() { - echo "${red}==> ${u}${b}${red}$1${reset}" - } + function error() { + echo "${red}==> ${u}${b}${red}$1${reset}" + } - function smallError() { - echo "${red}==>${reset} $1" - } + function smallError() { + echo "${red}==>${reset} $1" + } - function green() { - echo "${green}$1${reset}" - } + function green() { + echo "${green}$1${reset}" + } - function red() { - echo "${red}$1${reset}" - } + function red() { + echo "${red}$1${reset}" + } - function check() { - echo "${green}${bold} ✓${reset} $1${reset}" - } + function check() { + echo "${green}${bold} ✓${reset} $1${reset}" + } - function uncheck() { - echo "${red}${bold} ✘${reset} $1${reset}" - } + function uncheck() { + echo "${red}${bold} ✘${reset} $1${reset}" + } - ####### Setup methods + ####### Setup methods - function wait_for_user() { - while : - do - read -p "${blue}==>${reset} $1 [Y/n] " imp - case $imp in - [yY] ) return 0; break ;; - '' ) echo; break ;; - [nN] ) return 1 ;; - * ) echo "Unrecognized option provided. Please provide either 'Y' or 'N'"; - esac - done - } + function wait_for_user() { + while : + do + read -p "${blue}==>${reset} $1 [Y/n] " imp + case $imp in + [yY] ) return 0; break ;; + '' ) echo; break ;; + [nN] ) return 1 ;; + * ) echo "Unrecognized option provided. Please provide either 'Y' or 'N'"; + esac + done + } - function prompt_for_input() { - while : - do - read -p "$1 " imp - echo $imp - return - done - } - - function exe() { - echo "\$ $@"; "$@" - } - - function detectOS() { - if [[ "$OSTYPE" == "linux-gnu" ]] - then - OS_TYPE="linux" - get_linux_dependencies - elif [[ "$OSTYPE" == "darwin"* ]] - then - OS_TYPE="osx" - get_osx_dependencies - else - OS_TYPE="win" - abortInstall "${red}==>${reset} ${b}OS not supported:${reset} parity one-liner currently support OS X and Linux.\nFor instructions on installing parity on other platforms please visit ${u}${blue}http://ethcore.io/${reset}" - fi + function prompt_for_input() { + while : + do + read -p "$1 " imp + echo $imp + return + done + } + + function exe() { + echo "\$ $@"; "$@" + } + + function detectOS() { + if [[ "$OSTYPE" == "linux-gnu" ]] + then + OS_TYPE="linux" + get_linux_dependencies + elif [[ "$OSTYPE" == "darwin"* ]] + then + OS_TYPE="osx" + get_osx_dependencies + else + OS_TYPE="win" + abortInstall "${red}==>${reset} ${b}OS not supported:${reset} parity one-liner currently support OS X and Linux.\nFor instructions on installing parity on other platforms please visit ${u}${blue}http://ethcore.io/${reset}" + fi - echo + echo - if [[ $depCount == $depFound ]] - then - green "Found all dependencies ($depFound/$depCount)" - else - if [[ $canContinue == true ]] - then - red "Some dependencies are missing ($depFound/$depCount)" - elif [[ $canContinue == false && $depFound == 0 ]] - then - red "All dependencies are missing and cannot be auto-installed ($depFound/$depCount)" - abortInstall "$errorMessages"; - elif [[ $canContinue == false ]] - then - red "Some dependencies which cannot be auto-installed are missing ($depFound/$depCount)" - abortInstall "$errorMessages"; - fi - fi - } + if [[ $depCount == $depFound ]] + then + green "Found all dependencies ($depFound/$depCount)" + else + if [[ $canContinue == true ]] + then + red "Some dependencies are missing ($depFound/$depCount)" + elif [[ $canContinue == false && $depFound == 0 ]] + then + red "All dependencies are missing and cannot be auto-installed ($depFound/$depCount)" + abortInstall "$errorMessages"; + elif [[ $canContinue == false ]] + then + red "Some dependencies which cannot be auto-installed are missing ($depFound/$depCount)" + abortInstall "$errorMessages"; + fi + fi + } function macos_version() { @@ -185,7 +185,7 @@ function run_installer() fi errorMessages+="${red}==>${reset} ${b}Mac OS version too old:${reset} eth requires OS X version ${red}$OSX_REQUIERED_VERSION${reset} at least in order to run.\n" - errorMessages+=" Please update the OS and reload the install process.\n" + errorMessages+=" Please update the OS and reload the install process.\n" } function get_osx_dependencies() @@ -196,38 +196,38 @@ function run_installer() find_brew } - function linux_version() - { - source /etc/lsb-release - - if [[ $DISTRIB_ID == "Ubuntu" ]]; then - if [[ $DISTRIB_RELEASE == "14.04" ]]; then - check "Ubuntu-14.04" - isUbuntu1404=true - else - check "Ubuntu, but not 14.04" - isUbuntu1404=false - fi - else - check "Ubuntu not found" - isUbuntu1404=false - fi - } + function linux_version() + { + source /etc/lsb-release + + if [[ $DISTRIB_ID == "Ubuntu" ]]; then + if [[ $DISTRIB_RELEASE == "14.04" ]]; then + check "Ubuntu-14.04" + isUbuntu1404=true + else + check "Ubuntu, but not 14.04" + isUbuntu1404=false + fi + else + check "Ubuntu not found" + isUbuntu1404=false + fi + } - function get_linux_dependencies() - { - linux_version + function get_linux_dependencies() + { + linux_version - find_multirust - find_rocksdb + find_multirust + find_rocksdb - find_curl - find_git - find_make - find_gcc + find_curl + find_git + find_make + find_gcc - find_apt - } + find_apt + } function find_brew() { @@ -243,9 +243,9 @@ function run_installer() isBrew=false INSTALL_FILES+="${blue}${dim}==> Homebrew:${reset}\n" - INSTALL_FILES+=" ${blue}${dim}➜${reset} $HOMEBREW_PREFIX/bin/brew\n" - INSTALL_FILES+=" ${blue}${dim}➜${reset} $HOMEBREW_PREFIX/Library\n" - INSTALL_FILES+=" ${blue}${dim}➜${reset} $HOMEBREW_PREFIX/share/man/man1/brew.1\n" + INSTALL_FILES+=" ${blue}${dim}➜${reset} $HOMEBREW_PREFIX/bin/brew\n" + INSTALL_FILES+=" ${blue}${dim}➜${reset} $HOMEBREW_PREFIX/Library\n" + INSTALL_FILES+=" ${blue}${dim}➜${reset} $HOMEBREW_PREFIX/share/man/man1/brew.1\n" fi depCount=$((depCount+1)) @@ -268,245 +268,245 @@ function run_installer() isRuby=false canContinue=false errorMessages+="${red}==>${reset} ${b}Couldn't find Ruby:${reset} Brew requires Ruby which could not be found.\n" - errorMessages+=" Please install Ruby using these instructions ${u}${blue}https://www.ruby-lang.org/en/documentation/installation/${reset}.\n" + errorMessages+=" Please install Ruby using these instructions ${u}${blue}https://www.ruby-lang.org/en/documentation/installation/${reset}.\n" fi } - function find_rocksdb() - { - depCount=$((depCount+1)) - if [[ $(ldconfig -v 2>/dev/null | grep rocksdb | wc -l) == 1 ]]; then - depFound=$((depFound+1)) - check "librocksdb" - isRocksDB=true - else - uncheck "librocksdb is missing" - isRocksDB=false - INSTALL_FILES+="${blue}${dim}==>${reset}\tlibrocksdb\n" - fi - } + function find_rocksdb() + { + depCount=$((depCount+1)) + if [[ $(ldconfig -v 2>/dev/null | grep rocksdb | wc -l) == 1 ]]; then + depFound=$((depFound+1)) + check "librocksdb" + isRocksDB=true + else + uncheck "librocksdb is missing" + isRocksDB=false + INSTALL_FILES+="${blue}${dim}==>${reset}\tlibrocksdb\n" + fi + } - function find_multirust() - { - depCount=$((depCount+2)) - MULTIRUST_PATH=`which multirust 2>/dev/null` - if [[ -f $MULTIRUST_PATH ]]; then - depFound=$((depFound+1)) - check "multirust" - isMultirust=true - if [[ $(multirust show-default 2>/dev/null | grep nightly | wc -l) == 4 ]]; then - depFound=$((depFound+1)) - check "rust nightly" - isMultirustNightly=true - else - uncheck "rust is not nightly" - isMultirustNightly=false - INSTALL_FILES+="${blue}${dim}==>${reset}\tmultirust -> rust nightly\n" - fi - else - uncheck "multirust is missing" - uncheck "rust nightly is missing" - isMultirust=false - isMultirustNightly=false - INSTALL_FILES+="${blue}${dim}==>${reset}\tmultirust\n" - fi - } + function find_multirust() + { + depCount=$((depCount+2)) + MULTIRUST_PATH=`which multirust 2>/dev/null` + if [[ -f $MULTIRUST_PATH ]]; then + depFound=$((depFound+1)) + check "multirust" + isMultirust=true + if [[ $(multirust show-default 2>/dev/null | grep nightly | wc -l) == 4 ]]; then + depFound=$((depFound+1)) + check "rust nightly" + isMultirustNightly=true + else + uncheck "rust is not nightly" + isMultirustNightly=false + INSTALL_FILES+="${blue}${dim}==>${reset}\tmultirust -> rust nightly\n" + fi + else + uncheck "multirust is missing" + uncheck "rust nightly is missing" + isMultirust=false + isMultirustNightly=false + INSTALL_FILES+="${blue}${dim}==>${reset}\tmultirust\n" + fi + } - function find_apt() - { - depCount=$((depCount+1)) + function find_apt() + { + depCount=$((depCount+1)) - APT_PATH=`which apt-get 2>/dev/null` + APT_PATH=`which apt-get 2>/dev/null` - if [[ -f $APT_PATH ]] - then - depFound=$((depFound+1)) - check "apt-get" - isApt=true - else - uncheck "apt-get is missing" - isApt=false + if [[ -f $APT_PATH ]] + then + depFound=$((depFound+1)) + check "apt-get" + isApt=true + else + uncheck "apt-get is missing" + isApt=false - if [[ $isGCC == false || $isGit == false || $isMake == false || $isCurl == false ]]; then - canContinue=false - errorMessages+="${red}==>${reset} ${b}Couldn't find apt-get:${reset} We can only use apt-get in order to grab our dependencies.\n" - errorMessages+=" Please switch to a distribution such as Debian or Ubuntu or manually install the missing packages.\n" - fi - fi - } + if [[ $isGCC == false || $isGit == false || $isMake == false || $isCurl == false ]]; then + canContinue=false + errorMessages+="${red}==>${reset} ${b}Couldn't find apt-get:${reset} We can only use apt-get in order to grab our dependencies.\n" + errorMessages+=" Please switch to a distribution such as Debian or Ubuntu or manually install the missing packages.\n" + fi + fi + } - function find_gcc() - { - depCount=$((depCount+1)) - GCC_PATH=`which g++ 2>/dev/null` + function find_gcc() + { + depCount=$((depCount+1)) + GCC_PATH=`which g++ 2>/dev/null` - if [[ -f $GCC_PATH ]] - then - depFound=$((depFound+1)) - check "g++" - isGCC=true - else - uncheck "g++ is missing" - isGCC=false - INSTALL_FILES+="${blue}${dim}==>${reset}\tg++\n" - fi - } + if [[ -f $GCC_PATH ]] + then + depFound=$((depFound+1)) + check "g++" + isGCC=true + else + uncheck "g++ is missing" + isGCC=false + INSTALL_FILES+="${blue}${dim}==>${reset}\tg++\n" + fi + } - function find_git() - { - depCount=$((depCount+1)) - GIT_PATH=`which git 2>/dev/null` + function find_git() + { + depCount=$((depCount+1)) + GIT_PATH=`which git 2>/dev/null` - if [[ -f $GIT_PATH ]] - then - depFound=$((depFound+1)) - check "git" - isGit=true - else - uncheck "git is missing" - isGit=false - INSTALL_FILES+="${blue}${dim}==>${reset}\tgit\n" - fi - } + if [[ -f $GIT_PATH ]] + then + depFound=$((depFound+1)) + check "git" + isGit=true + else + uncheck "git is missing" + isGit=false + INSTALL_FILES+="${blue}${dim}==>${reset}\tgit\n" + fi + } - function find_make() - { - depCount=$((depCount+1)) - MAKE_PATH=`which make 2>/dev/null` + function find_make() + { + depCount=$((depCount+1)) + MAKE_PATH=`which make 2>/dev/null` - if [[ -f $MAKE_PATH ]] - then - depFound=$((depFound+1)) - check "make" - isMake=true - else - uncheck "make is missing" - isMake=false - INSTALL_FILES+="${blue}${dim}==>${reset}\tmake\n" - fi - } + if [[ -f $MAKE_PATH ]] + then + depFound=$((depFound+1)) + check "make" + isMake=true + else + uncheck "make is missing" + isMake=false + INSTALL_FILES+="${blue}${dim}==>${reset}\tmake\n" + fi + } - function find_curl() - { - depCount=$((depCount+1)) - CURL_PATH=`which curl 2>/dev/null` + function find_curl() + { + depCount=$((depCount+1)) + CURL_PATH=`which curl 2>/dev/null` - if [[ -f $CURL_PATH ]] - then - depFound=$((depFound+1)) - check "curl" - isCurl=true - else - uncheck "curl is missing" - isCurl=false - INSTALL_FILES+="${blue}${dim}==>${reset}\tcurl\n" - fi - } + if [[ -f $CURL_PATH ]] + then + depFound=$((depFound+1)) + check "curl" + isCurl=true + else + uncheck "curl is missing" + isCurl=false + INSTALL_FILES+="${blue}${dim}==>${reset}\tcurl\n" + fi + } - function ubuntu1404_rocksdb_installer() - { - sudo apt-get update -qq - sudo apt-get install -qq -y software-properties-common - sudo apt-add-repository -y ppa:giskou/librocksdb - sudo apt-get -f -y install - sudo apt-get update -qq - sudo apt-get install -qq -y librocksdb - } + function ubuntu1404_rocksdb_installer() + { + sudo apt-get update -qq + sudo apt-get install -qq -y software-properties-common + sudo apt-add-repository -y ppa:giskou/librocksdb + sudo apt-get -f -y install + sudo apt-get update -qq + sudo apt-get install -qq -y librocksdb + } - function linux_rocksdb_installer() - { - if [[ $isUbuntu1404 == true ]]; then - ubuntu1404_rocksdb_installer - else - oldpwd=`pwd` - cd /tmp - exe git clone --branch v4.2 --depth=1 https://github.com/facebook/rocksdb.git - cd rocksdb - exe make shared_lib - sudo cp -a librocksdb.so* /usr/lib - sudo ldconfig - cd /tmp - rm -rf /tmp/rocksdb - cd $oldpwd - fi - } + function linux_rocksdb_installer() + { + if [[ $isUbuntu1404 == true ]]; then + ubuntu1404_rocksdb_installer + else + oldpwd=`pwd` + cd /tmp + exe git clone --branch v4.2 --depth=1 https://github.com/facebook/rocksdb.git + cd rocksdb + exe make shared_lib + sudo cp -a librocksdb.so* /usr/lib + sudo ldconfig + cd /tmp + rm -rf /tmp/rocksdb + cd $oldpwd + fi + } - function verify_installation() - { - ETH_PATH=`which parity 2>/dev/null` + function verify_installation() + { + ETH_PATH=`which parity 2>/dev/null` - if [[ -f $ETH_PATH ]] - then - success "Parity has been installed" - else - error "Parity is missing" - abortInstall - fi - } + if [[ -f $ETH_PATH ]] + then + success "Parity has been installed" + else + error "Parity is missing" + abortInstall + fi + } - function verify_dep_installation() - { - info "Verifying installation" + function verify_dep_installation() + { + info "Verifying installation" - if [[ $OS_TYPE == "linux" ]]; then - find_curl - find_git - find_make - find_gcc - find_rocksdb - find_multirust + if [[ $OS_TYPE == "linux" ]]; then + find_curl + find_git + find_make + find_gcc + find_rocksdb + find_multirust - if [[ $isCurl == false || $isGit == false || $isMake == false || $isGCC == false || $isRocksDB == false || $isMultirustNightly == false ]]; then - abortInstall - fi - fi - } + if [[ $isCurl == false || $isGit == false || $isMake == false || $isGCC == false || $isRocksDB == false || $isMultirustNightly == false ]]; then + abortInstall + fi + fi + } - function linux_deps_installer() - { - if [[ $isGCC == false || $isGit == false || $isMake == false || $isCurl == false ]]; then - info "Installing build dependencies..." - sudo apt-get update -qq - if [[ $isGit == false ]]; then - sudo apt-get install -q -y git - fi - if [[ $isGCC == false ]]; then - sudo apt-get install -q -y g++ gcc - fi - if [[ $isMake == false ]]; then - sudo apt-get install -q -y make - fi - if [[ $isCurl == false ]]; then - sudo apt-get install -q -y curl - fi - echo - fi - - if [[ $isRocksDB == false ]]; then - info "Installing rocksdb..." - linux_rocksdb_installer - echo - fi - - if [[ $isMultirust == false ]]; then - info "Installing multirust..." - curl -sf https://raw.githubusercontent.com/brson/multirust/master/blastoff.sh | sudo sh -s -- --yes - echo - fi - - if [[ $isMultirustNightly == false ]]; then - info "Installing rust nightly..." - sudo multirust update nightly - sudo multirust default nightly - echo + function linux_deps_installer() + { + if [[ $isGCC == false || $isGit == false || $isMake == false || $isCurl == false ]]; then + info "Installing build dependencies..." + sudo apt-get update -qq + if [[ $isGit == false ]]; then + sudo apt-get install -q -y git + fi + if [[ $isGCC == false ]]; then + sudo apt-get install -q -y g++ gcc + fi + if [[ $isMake == false ]]; then + sudo apt-get install -q -y make + fi + if [[ $isCurl == false ]]; then + sudo apt-get install -q -y curl + fi + echo fi - } + if [[ $isRocksDB == false ]]; then + info "Installing rocksdb..." + linux_rocksdb_installer + echo + fi + + if [[ $isMultirust == false ]]; then + info "Installing multirust..." + curl -sf https://raw.githubusercontent.com/brson/multirust/master/blastoff.sh | sudo sh -s -- --yes + echo + fi + + if [[ $isMultirustNightly == false ]]; then + info "Installing rust nightly..." + sudo multirust update nightly + sudo multirust default nightly + echo + fi + + } - function linux_installer() - { + function linux_installer() + { linux_deps_installer verify_dep_installation @@ -516,154 +516,154 @@ function run_installer() wget $PARITY_DEB_URL -qO $file sudo dpkg -i $file rm $file - } + } - function osx_installer() - { - info "Adding ethcore repository" - brew tap ethcore/ethcore https://github.com/ethcore/homebrew-ethcore.git - echo + function osx_installer() + { + info "Adding ethcore repository" + brew tap ethcore/ethcore https://github.com/ethcore/homebrew-ethcore.git + echo - info "Updating brew" - brew update - echo + info "Updating brew" + brew update + echo - info "Installing parity" - if [[ $isEth == true ]] - then - brew reinstall parity - else - brew install parity - brew linkapps parity - fi - echo - } + info "Installing parity" + if [[ $isEth == true ]] + then + brew reinstall parity + else + brew install parity + brew linkapps parity + fi + echo + } - function install() - { - echo - head "Installing Parity build dependencies" + function install() + { + echo + head "Installing Parity build dependencies" - if [[ $OS_TYPE == "osx" ]] - then - osx_installer - elif [[ $OS_TYPE == "linux" ]] - then - linux_installer - fi + if [[ $OS_TYPE == "osx" ]] + then + osx_installer + elif [[ $OS_TYPE == "linux" ]] + then + linux_installer + fi verify_installation - } + } - - function install_netstats() - { - echo "Installing netstats" + + function install_netstats() + { + echo "Installing netstats" - secret=$(prompt_for_input "Please enter the netstats secret:") - instance_name=$(prompt_for_input "Please enter your instance name:") - contact_details=$(prompt_for_input "Please enter your contact details (optional):") + secret=$(prompt_for_input "Please enter the netstats secret:") + instance_name=$(prompt_for_input "Please enter your instance name:") + contact_details=$(prompt_for_input "Please enter your contact details (optional):") - curl -sL https://deb.nodesource.com/setup_0.12 | bash - - sudo apt-get update + curl -sL https://deb.nodesource.com/setup_0.12 | bash - + sudo apt-get update - # install ethereum & install dependencies - sudo apt-get install -y -qq build-essential git unzip wget nodejs ntp cloud-utils + # install ethereum & install dependencies + sudo apt-get install -y -qq build-essential git unzip wget nodejs ntp cloud-utils sudo apt-get install -y -qq npm - # add node symlink if it doesn't exist - [[ ! -f /usr/bin/node ]] && sudo ln -s /usr/bin/nodejs /usr/bin/node + # add node symlink if it doesn't exist + [[ ! -f /usr/bin/node ]] && sudo ln -s /usr/bin/nodejs /usr/bin/node - # set up time update cronjob - sudo bash -c "cat > /etc/cron.hourly/ntpdate << EOF - #!/bin/sh - pm2 flush - sudo service ntp stop - sudo ntpdate -s ntp.ubuntu.com - sudo service ntp start - EOF" + # set up time update cronjob + sudo bash -c "cat > /etc/cron.hourly/ntpdate << EOF + #!/bin/sh + pm2 flush + sudo service ntp stop + sudo ntpdate -s ntp.ubuntu.com + sudo service ntp start + EOF" - sudo chmod 755 /etc/cron.hourly/ntpdate + sudo chmod 755 /etc/cron.hourly/ntpdate cd $HOME - [ ! -d "www" ] && git clone https://github.com/cubedro/eth-net-intelligence-api netstats - oldpwd= $(pwd) - cd netstats - git pull - git checkout 95d595258239a0fdf56b97dedcfb2be62f6170e6 + [ ! -d "www" ] && git clone https://github.com/cubedro/eth-net-intelligence-api netstats + oldpwd= $(pwd) + cd netstats + git pull + git checkout 95d595258239a0fdf56b97dedcfb2be62f6170e6 - sudo npm install - sudo npm install pm2 -g + sudo npm install + sudo npm install pm2 -g - cat > app.json << EOL + cat > app.json << EOL [ - { - "name" : "node-app", - "script" : "app.js", - "log_date_format" : "YYYY-MM-DD HH:mm Z", - "merge_logs" : false, - "watch" : false, - "max_restarts" : 10, - "exec_interpreter" : "node", - "exec_mode" : "fork_mode", - "env": - { - "NODE_ENV" : "production", - "RPC_HOST" : "localhost", - "RPC_PORT" : "8545", - "LISTENING_PORT" : "30303", - "INSTANCE_NAME" : "${instance_name}", - "CONTACT_DETAILS" : "${contact_details}", - "WS_SERVER" : "wss://rpc.ethstats.net", - "WS_SECRET" : "${secret}", - "VERBOSITY" : 2 - - } - } + { + "name" : "node-app", + "script" : "app.js", + "log_date_format" : "YYYY-MM-DD HH:mm Z", + "merge_logs" : false, + "watch" : false, + "max_restarts" : 10, + "exec_interpreter" : "node", + "exec_mode" : "fork_mode", + "env": + { + "NODE_ENV" : "production", + "RPC_HOST" : "localhost", + "RPC_PORT" : "8545", + "LISTENING_PORT" : "30303", + "INSTANCE_NAME" : "${instance_name}", + "CONTACT_DETAILS" : "${contact_details}", + "WS_SERVER" : "wss://rpc.ethstats.net", + "WS_SECRET" : "${secret}", + "VERBOSITY" : 2 + + } + } ] EOL - pm2 startOrRestart app.json - cd $oldpwd - } - + pm2 startOrRestart app.json + cd $oldpwd + } + - function abortInstall() - { - echo - error "Installation failed" - echo -e "$1" - echo - exit 0 - } + function abortInstall() + { + echo + error "Installation failed" + echo -e "$1" + echo + exit 0 + } - function finish() - { - echo - successHeading "All done" - # head "Next steps" - # info "Run ${cyan}\`\`${reset} to get started.${reset}" - echo - exit 0 - } + function finish() + { + echo + successHeading "All done" + # head "Next steps" + # info "Run ${cyan}\`\`${reset} to get started.${reset}" + echo + exit 0 + } - head "Checking OS dependencies" - detectOS + head "Checking OS dependencies" + detectOS - if [[ $INSTALL_FILES != "" ]]; then - echo - head "In addition to the Parity build dependencies, this script will install:" - printf "$INSTALL_FILES" - echo - fi + if [[ $INSTALL_FILES != "" ]]; then + echo + head "In addition to the Parity build dependencies, this script will install:" + printf "$INSTALL_FILES" + echo + fi - #DEBUG + #DEBUG - - head "${b}OK,${reset} let's install Parity now!" + + head "${b}OK,${reset} let's install Parity now!" if wait_for_user "${b}Last chance!${reset} Sure you want to install this software?" then install @@ -673,21 +673,21 @@ EOL finish fi - + - if [[ $OS_TYPE == "linux" ]] - then - echo "Netstats:" - head "Would you like to install and configure a netstats client?" - if wait_for_user "${b}OK,${reset} let's go!" - then - install_netstats - fi - fi + if [[ $OS_TYPE == "linux" ]] + then + echo "Netstats:" + head "Would you like to install and configure a netstats client?" + if wait_for_user "${b}OK,${reset} let's go!" + then + install_netstats + fi + fi - # Display goodbye message - finish + # Display goodbye message + finish } run_installer