-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathget-windows.sh
More file actions
89 lines (74 loc) · 2.41 KB
/
get-windows.sh
File metadata and controls
89 lines (74 loc) · 2.41 KB
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
84
85
86
87
88
89
#!/bin/sh
# Sources cited:
# - https://raw.githubusercontent.com/goreleaser/get/master/get
# Use:
#
# Install janus executable to system PATH.
#
# curl -sL https://raw.githubusercontent.com/ETCDEVTeam/janus/master/get.sh | bash
# export PATH=$PATH:$PWD/janusbin
set -e
TAR_FILE="/tmp/janus.zip"
TAR_FILE_SIG="/tmp/janus.zip.sig"
ISAAC_GPG_FILE="/tmp/isaac-gpg.txt"
ISAAC_GPG_URL="https://raw.githubusercontent.com/ethereumproject/volunteer/7a78a94307d67a0b20e418568b7bccac83c3d143/Volunteer-Public-Keys/isaac.ardis%40gmail.com"
DOWNLOAD_URL="https://github.com/ETCDEVTeam/janus/releases/download"
test -z "$TMPDIR" && TMPDIR="$(mktemp -d)"
# Hardcode to override appveyor system names. (ie MSYS_*blah_wahtever)
WINDOWS_EXT="Windows_x86_64.zip"
last_version() {
# The new and improved sans-GithubAPI-rate-limited curler.
# https://github.com/goreleaser/goreleaser/issues/157
curl -sL -o /dev/null -w %{url_effective} https://github.com/ETCDEVTeam/janus/releases/latest | rev | cut -f1 -d'/'| rev
}
download() {
test -z "$VERSION" && VERSION="$(last_version)"
test -z "$VERSION" && {
echo "Unable to get janus version." >&2
exit 1
}
echo "Version: $VERSION"
rm -f "$TAR_FILE"
download_target="$DOWNLOAD_URL/$VERSION/janus_${VERSION}_$WINDOWS_EXT"
echo "Downloading Janus: $download_target"
curl -s -L -o "$TAR_FILE" \
"$download_target"
# Get and verify signature.
rm -f "$TAR_FILE_SIG"
sig_target="$DOWNLOAD_URL/$VERSION/janus_${VERSION}_$WINDOWS_EXT.sig"
echo "Downloading signature: $sig_target"
curl -s -L -o "$TAR_FILE_SIG" \
"$sig_target"
# Ensure our newly downloaded files exists.
if ! [ -f "$TAR_FILE" ]; then
echo "Tar file not found."
exit 1
fi
if ! [ -f "$TAR_FILE_SIG" ]; then
echo "Tar sig file not found."
exit 1
fi
}
verify() {
# Verify signature if gpg is available.
if command -v gpg 2> /dev/null; then
echo "Downloading Isaac's key file: $ISAAC_GPG_URL"
curl -s -L -o "$ISAAC_GPG_FILE" \
"$ISAAC_GPG_URL"
gpg --import "$ISAAC_GPG_FILE"
gpg --verify "$TAR_FILE_SIG" "$TAR_FILE"
fi
}
install() {
echo "Extracting janus..."
7z e "$TAR_FILE" janus.exe -y
echo "Moving 'janus' binary to ./janusbin/janus"
mkdir janusbin
mv janus.exe janusbin/
echo "Please ensure janus is added to PATH."
echo "Use:"
echo " - export PATH=$PATH:$PWD/janusbin"
}
download
verify
install