-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathgetFrogbot.sh
109 lines (97 loc) · 2.34 KB
/
getFrogbot.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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
FROGBOT_OS="na"
FILE_NAME="na"
VERSION="[RELEASE]"
PLATFORM_URL="https://releases.jfrog.io"
setFrogbotVersion() {
if [ $# -eq 1 ]
then
VERSION=$1
echo "Downloading version $VERSION of Frogbot..."
else
echo "Downloading the latest version of Frogbot..."
fi
}
setFrogbotRemoteRepositoryIfNeeded() {
if [ -n "${JF_RELEASES_REPO}" ]
then
PLATFORM_URL="${JF_URL%%/}"
REMOTE_PATH="$JF_RELEASES_REPO/artifactory/"
fi
}
setWindowsProperties() {
FROGBOT_OS="windows"
URL="${PLATFORM_URL}/artifactory/${REMOTE_PATH}frogbot/v2/${VERSION}/frogbot-windows-amd64/frogbot.exe"
FILE_NAME="frogbot.exe"
}
setMacProperties() {
FROGBOT_OS="mac"
URL="${PLATFORM_URL}/artifactory/${REMOTE_PATH}frogbot/v2/${VERSION}/frogbot-mac-386/frogbot"
FILE_NAME="frogbot"
}
setLinuxProperties() {
FROGBOT_OS="linux"
MACHINE_TYPE="$(uname -m)"
case $MACHINE_TYPE in
i386 | i486 | i586 | i686 | i786 | x86)
ARCH="386"
;;
amd64 | x86_64 | x64)
ARCH="amd64"
;;
arm | armv7l)
ARCH="arm"
;;
aarch64)
ARCH="arm64"
;;
s390x)
ARCH="s390x"
;;
ppc64)
ARCH="ppc64"
;;
ppc64le)
ARCH="ppc64le"
;;
*)
echo "Unknown machine type: $MACHINE_TYPE"
exit 1
;;
esac
URL="${PLATFORM_URL}/artifactory/${REMOTE_PATH}frogbot/v2/${VERSION}/frogbot-${FROGBOT_OS}-${ARCH}/frogbot"
FILE_NAME="frogbot"
}
setFrogbotDownloadProperties() {
if echo "${OSTYPE}" | grep -q msys; then
setWindowsProperties
elif echo "${OSTYPE}" | grep -q darwin; then
setMacProperties
else
setLinuxProperties
fi
}
setPermissions() {
chmod u+x "${FILE_NAME}"
}
echoGreetings() {
echo "Frogbot downloaded successfully!"
}
getDownloadCommand() {
if [ -n "${REMOTE_PATH}" ]; then
if [ -n "${JF_ACCESS_TOKEN}" ]; then
curl -fLg -H "Authorization:Bearer ${JF_ACCESS_TOKEN}" -X GET "${URL}" -o "${FILE_NAME}"
else
curl -fLg -u "${JF_USER}:${JF_PASSWORD}" -X GET "${URL}" -o "${FILE_NAME}"
fi
else
curl -fLg -X GET "${URL}" -o "${FILE_NAME}"
fi
}
download() {
getDownloadCommand && setPermissions && echoGreetings
}
setFrogbotVersion "$@"
setFrogbotRemoteRepositoryIfNeeded
setFrogbotDownloadProperties
download