-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-nethermind
74 lines (59 loc) · 1.86 KB
/
update-nethermind
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
#!/bin/bash
__arch=$(uname -m)
if [ "${__arch}" = "aarch64" ]; then
arch="arm64"
elif [ "${__arch}" = "x86_64" ]; then
arch="amd64"
else
echo "Architecture ${__arch} not recognized. Aborting."
exit 1
fi
lastver=$(curl --silent "https://api.github.com/repos/nethermindeth/nethermind/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')
read -p "Update Nethermind to Version [$lastver]: " ver
ver=${ver:-$lastver}
sha=$(curl --silent "https://api.github.com/repos/nethermindeth/nethermind/git/ref/tags/${ver}" | grep -Po '"sha": "\K.*?(?=")')
echo
read -p "Are you sure you want to update Nethermind to Version [$ver - ${sha:0:8}]? (y/n)" -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
echo
echo "Downloading Nethermind Version: $ver"
echo
curl -LO "https://nethdev.blob.core.windows.net/builds/nethermind-$ver-${sha:0:8}-linux-$arch.zip"
echo
echo "Importing build server public keys..."
gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 34E353C6 CB6DA407
echo
echo "Checking File Signature..."
curl -LO "https://nethdev.blob.core.windows.net/builds/nethermind-$ver-${sha:0:8}-linux-$arch.zip.asc" --silent
if ! gpg --verify nethermind-$ver-${sha:0:8}-linux-$arch.zip.asc; then
echo
echo "Signature Error!"
exit 1
fi
echo
echo "Signature OK!"
echo
echo "Stopping Nethermind Service..."
sudo systemctl stop nethermind
echo
echo "Extracting..."
unzip nethermind-$ver-${sha:0:8}-linux-$arch.zip -d nethermind
sudo rm -r /usr/local/bin/nethermind 2>/dev/null
sudo cp -a nethermind /usr/local/bin/nethermind
echo
read -p "Restart Nethermind Service?" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo
echo "Starting Services..."
sudo systemctl daemon-reload
sudo systemctl start nethermind
fi
echo
echo "Cleaning Up..."
rm nethermind-$ver-${sha:0:8}-linux-$arch.zip
rm nethermind-$ver-${sha:0:8}-linux-$arch.zip.asc
rm -r nethermind