ethstats-client/bin/update.sh

80 lines
1.3 KiB
Bash
Raw Normal View History

2015-04-06 01:49:31 +02:00
#!/bin/bash
2015-04-06 02:56:08 +02:00
# setup colors
red=`tput setaf 1`
green=`tput setaf 2`
cyan=`tput setaf 6`
bold=`tput bold`
reset=`tput sgr0`
heading()
{
echo
echo "${cyan}==>${reset}${bold} $1${reset}"
}
success()
{
echo
echo "${green}==>${bold} $1${reset}"
}
error()
{
echo
echo "${red}==>${bold} Error: $1${reset}"
}
heading "Updating ethereum"
# figure out what we have to update
2015-04-06 01:49:31 +02:00
if [[ -f /usr/bin/geth ]];
then
ethtype="geth"
2015-04-06 02:56:08 +02:00
success "Found geth"
2015-04-06 01:49:31 +02:00
else
2015-04-06 20:47:05 +02:00
if [[ -f /usr/bin/eth ]];
2015-04-06 02:56:08 +02:00
then
ethtype="eth"
success "Found eth"
else
error "Couldn't find ethereum"
exit 0
fi
2015-04-06 01:49:31 +02:00
fi
2015-05-14 19:20:59 +02:00
heading "Flushing logs"
pm2 flush
rm -Rf ~/logs/*
2015-04-06 02:56:08 +02:00
heading "Stopping processes"
2015-04-06 01:49:31 +02:00
pm2 kill
2015-04-06 02:56:08 +02:00
2015-05-18 23:39:05 +02:00
heading "Killing remaining node processes"
echo `ps auxww | grep node | awk '{print $2}'`
kill -9 `ps auxww | grep node | awk '{print $2}'`
2015-04-06 02:56:08 +02:00
heading "Removing ethereum"
2015-04-06 21:08:00 +02:00
sudo apt-get remove -y $ethtype
2015-04-06 01:49:31 +02:00
2015-04-06 02:56:08 +02:00
heading "Updating repos"
2015-04-06 01:49:31 +02:00
sudo apt-get clean
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo add-apt-repository -y ppa:ethereum/ethereum-dev
sudo apt-get update -y
sudo apt-get upgrade -y
2015-04-06 02:56:08 +02:00
heading "Installing ethereum"
2015-04-06 21:08:00 +02:00
sudo apt-get install -y $ethtype
2015-04-06 01:49:31 +02:00
2015-04-06 02:56:08 +02:00
heading "Updating eth-netstats client"
2015-04-06 01:49:31 +02:00
cd ~/bin/www
git pull
sudo npm update
cd ..
2015-04-06 02:56:08 +02:00
success "Ethereum was updated successfully"
heading "Restarting processes"
2015-04-06 01:49:31 +02:00
pm2 start processes.json