-
Notifications
You must be signed in to change notification settings - Fork 499
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·67 lines (59 loc) · 1.63 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·67 lines (59 loc) · 1.63 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
#!/bin/sh
{
set -e
LATEST_URL="https://github.com/goss-org/goss/releases/latest"
LATEST_EFFECTIVE=$(curl -s -L -o /dev/null ${LATEST_URL} -w '%{url_effective}')
LATEST=${LATEST_EFFECTIVE##*/}
DGOSS_VER=$GOSS_VER
if [ -z "$GOSS_VER" ]; then
GOSS_VER=${GOSS_VER:-$LATEST}
DGOSS_VER='master'
fi
if [ -z "$GOSS_VER" ]; then
echo "ERROR: Could not automatically detect latest version, set GOSS_VER env var and re-run"
exit 1
fi
GOSS_DST=${GOSS_DST:-/usr/local/bin}
INSTALL_LOC="${GOSS_DST%/}/goss"
DGOSS_INSTALL_LOC="${GOSS_DST%/}/dgoss"
touch "$INSTALL_LOC" || { echo "ERROR: Cannot write to $GOSS_DST set GOSS_DST elsewhere or use sudo"; exit 1; }
# Reference: https://wiki.debian.org/ArchitectureSpecificsMemo
case "$(uname -m)" in
x86_64)
arch="x86_64"
;;
aarch32|arm)
arch="arm"
;;
aarch64|arm64)
arch="arm64"
;;
s390x)
arch="s390x"
;;
i?86)
arch="i386"
;;
ppcle|ppc64le)
arch="ppc64le"
;;
*)
echo "error: unknown/unsupported architecture: $(uname -m)" >&2
exit 1
;;
esac
url="https://github.com/goss-org/goss/releases/download/$GOSS_VER/goss_${GOSS_VER#v}_linux_$arch.tar.gz"
echo "Downloading $url"
tmp=$(mktemp -d)
trap "rm -rf $tmp" EXIT
curl -L "$url" | tar xz -C "$tmp"
mv "$tmp/goss" "$INSTALL_LOC"
echo "Goss $GOSS_VER has been installed to $INSTALL_LOC"
echo "goss --version"
"$INSTALL_LOC" --version
dgoss_url="https://raw.githubusercontent.com/goss-org/goss/$DGOSS_VER/extras/dgoss/dgoss"
echo "Downloading $dgoss_url"
curl -L "$dgoss_url" -o "$DGOSS_INSTALL_LOC"
chmod +rx "$DGOSS_INSTALL_LOC"
echo "dgoss $DGOSS_VER has been installed to $DGOSS_INSTALL_LOC"
}