forked from raiden-network/raiden
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdownload_geth.sh
executable file
·64 lines (49 loc) · 1.19 KB
/
download_geth.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
#!/usr/bin/env bash
set -e
fail() {
if [[ $- == *i* ]]; then
red=`tput setaf 1`
reset=`tput sgr0`
echo "${red}==> ${@}${reset}"
fi
exit 1
}
info() {
if [[ $- == *i* ]]; then
blue=`tput setaf 4`
reset=`tput sgr0`
echo "${blue}${@}${reset}"
fi
}
success() {
if [[ $- == *i* ]]; then
green=`tput setaf 2`
reset=`tput sgr0`
echo "${green}${@}${reset}"
fi
}
warn() {
if [[ $- == *i* ]]; then
yellow=`tput setaf 3`
reset=`tput sgr0`
echo "${yellow}${@}${reset}"
fi
}
[ -z "${GETH_URL}" ] && fail 'missing GETH_URL'
[ -z "${GETH_VERSION}" ] && fail 'missing GETH_VERSION'
if [ ! -x $HOME/.bin/geth-${GETH_VERSION} ]; then
mkdir -p $HOME/.bin
TEMP=$(mktemp -d)
cd $TEMP
wget -O geth.tar.gz $GETH_URL
tar xzf geth.tar.gz
cd geth*/
install -m 755 geth $HOME/.bin/geth-${GETH_VERSION}
success "geth ${GETH_VERSION} installed"
else
info 'using cached geth'
fi
# always recreate the symlink since we dont know if it's pointing to a different
# version
[ -h $HOME/.bin/geth ] && unlink $HOME/.bin/geth
ln -s $HOME/.bin/geth-${GETH_VERSION} $HOME/.bin/geth