forked from cubedro/eth-net-intelligence-api
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdate.sh
executable file
·83 lines (67 loc) · 1.35 KB
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# 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
if [[ -f /usr/bin/geth ]];
then
ethtype="geth"
success "Found geth"
else
if [[ -f /usr/bin/eth ]];
then
ethtype="eth"
success "Found eth"
else
error "Couldn't find ethereum"
exit 0
fi
fi
heading "Stopping processes"
pm2 stop all
heading "Flushing logs"
pm2 flush
rm -Rf ~/logs/*
rm -rf ~/.local/share/Trash/*
heading "Stopping pm2"
pm2 kill
heading "Killing remaining node processes"
echo `ps auxww | grep node | awk '{print $2}'`
kill -9 `ps auxww | grep node | awk '{print $2}'`
heading "Removing ethereum"
sudo apt-get remove -y $ethtype
heading "Updating repos"
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
heading "Installing ethereum"
sudo apt-get install -y $ethtype
heading "Updating eth-netstats client"
cd ~/bin/www
git pull
sudo npm update
cd ..
success "Ethereum was updated successfully"
heading "Restarting processes"
pm2 start processes.json