moved parity-related build stuff from install-deps into install-parity

This commit is contained in:
KKudryavtsev 2016-02-04 22:40:19 +00:00
parent 6142c6aae5
commit 6af69d7057
2 changed files with 70 additions and 364 deletions

View File

@ -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
}

View File

@ -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
}