-
Notifications
You must be signed in to change notification settings - Fork 30
/
install
executable file
·38 lines (29 loc) · 1.14 KB
/
install
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
#!/usr/bin/env bash
# this the install script for Dirac CLI tool
set -e -o pipefail
INSTALL_LOCATION=${1:-/usr/local/bin}
NAME="dirac"
SOURCE_URL="https://raw.githubusercontent.com/binaryage/dirac/master/dirac"
TARGET="$INSTALL_LOCATION/$NAME"
EXPECTED_CHECKSUM=${DIRAC_INSTALL_EXPECTED_CHECKSUM:-8e580df350401c1a00c0d93aa720103177dfc4050bdc4ded5e817ff5c403c8ed}
TMP_FILE=$(mktemp "/tmp/dirac.XXXXXX")
echo "Downloading Dirac CLI tool..."
curl -s "$SOURCE_URL" >"$TMP_FILE"
# here we perform a paranoid checksum test to make sure we got expected file
if [[ -n "$EXPECTED_CHECKSUM" ]]; then
CHECKSUM=$(shasum -a 256 "$TMP_FILE" | cut -d " " -f 1)
if [[ "$CHECKSUM" != "$EXPECTED_CHECKSUM" ]]; then
echo "SHA checksum of downloaded file does not match expected value"
echo " URL: $SOURCE_URL"
echo " FILE: $TMP_FILE"
echo " '$CHECKSUM' != '$EXPECTED_CHECKSUM'"
echo
echo "If this is not a network issue, please file an issue at https://github.com/binaryage/dirac/issues"
exit 1
fi
fi
echo "Installing Dirac CLI tool as '$TARGET'..."
mkdir -p "$(dirname "$TARGET")"
cp "$TMP_FILE" "$TARGET"
chmod a+rx "$TARGET"
command -v $NAME