Skip to content

Commit 2175394

Browse files
authored
Cleanup install script (#197)
- Pull latest version from GitHub directly - Remove legacy download option (since S3 is going away) - Remove amplitude analytics
1 parent ce2b879 commit 2175394

File tree

1 file changed

+4
-63
lines changed

1 file changed

+4
-63
lines changed

static/install.sh

Lines changed: 4 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,13 @@ if [[ ! -t 0 || -n ${CI-} ]]; then
88
NONINTERACTIVE=1
99
fi
1010

11-
LEGACY_DOWNLOAD=1
1211
TEMP_LOCAL="/tmp/opta_local"
1312

1413
abort() {
1514
printf "%s\n" "$1"
1615
exit 1
1716
}
1817

19-
sendamplitudeevent() {
20-
(curl -X POST https://api2.amplitude.com/2/httpapi \
21-
-H 'Content-Type: application/json' \
22-
-H 'Accept: */*' \
23-
-s \
24-
-o /dev/null \
25-
--data-binary @- <<EOF
26-
{
27-
"api_key": "751db5fc75ff34f08a83381f4d54ead6",
28-
"events": [
29-
{
30-
"device_id": "${MAC_ADDRESS}",
31-
"user_id": "${GIT_EMAIL}",
32-
"app_version": "${VERSION}",
33-
"os_name": "${OS}",
34-
"event_type": "$1"
35-
}
36-
]
37-
}
38-
EOF
39-
) || true
40-
}
41-
42-
errorevent() {
43-
sendamplitudeevent "OPTA_INSTALL_FAILURE"
44-
}
45-
46-
trap "errorevent" ERR
47-
4818
# Compares two version numbers.
4919
# Returns 0 if the versions are equal, 1 if the first version is higher, and 2 if the second version is higher.
5020
# Source Code: https://stackoverflow.com/questions/4023830/how-to-compare-two-strings-in-dot-separated-version-format-in-bash
@@ -130,53 +100,26 @@ VERSION="${VERSION:-}"
130100
if [[ -z ${VERSION} ]]; then
131101
# Determine latest VERSION
132102
echo "Determining latest version"
133-
VERSION="$(curl -s https://dev-runx-opta-binaries.s3.amazonaws.com/latest)"
103+
VERSION="$(curl -s https://api.github.com/repos/run-x/opta/releases/latest | grep 'tag_name' | grep -oP '[0-9.]+')"
134104
else
135105
VERSION=$(trim_version "${VERSION}")
136106
fi
137107

138-
if [[ $(compare_version "$VERSION" "0.27.2") == 1 ]]; then
139-
LEGACY_DOWNLOAD=0
140-
fi
141-
142108
echo "Going to install opta v${VERSION}"
143109

144110
if [[ ${OS} == "Linux" ]]; then
145111
SPECIFIC_OS_ID=$(grep "ID=" /etc/os-release | awk -F"=" '{print $2;exit}' | tr -d '"')
146112
if [[ ${SPECIFIC_OS_ID} == "amzn" ]] || [[ ${SPECIFIC_OS_ID} == "centos" ]]; then
147-
if [[ ${LEGACY_DOWNLOAD} == "1" ]]; then
148-
PACKAGE=https://dev-runx-opta-binaries.s3.amazonaws.com/centos/$VERSION/opta.zip
149-
else
150-
PACKAGE=https://github.com/run-x/opta/releases/download/v$VERSION/opta_centos.zip
151-
fi
113+
PACKAGE=https://github.com/run-x/opta/releases/download/v$VERSION/opta_centos.zip
152114
else
153-
if [[ ${LEGACY_DOWNLOAD} == "1" ]]; then
154-
PACKAGE=https://dev-runx-opta-binaries.s3.amazonaws.com/linux/$VERSION/opta.zip
155-
else
156-
PACKAGE=https://github.com/run-x/opta/releases/download/v$VERSION/opta_linux.zip
157-
fi
115+
PACKAGE=https://github.com/run-x/opta/releases/download/v$VERSION/opta_linux.zip
158116
fi
159-
MAC_ADDRESS=$(cat /sys/class/net/eth0/address 2>/dev/null) || true
160117
elif [[ ${OS} == "Darwin" ]]; then
161-
if [[ ${LEGACY_DOWNLOAD} == "1" ]]; then
162-
PACKAGE=https://dev-runx-opta-binaries.s3.amazonaws.com/mac/$VERSION/opta.zip
163-
else
164-
PACKAGE=https://github.com/run-x/opta/releases/download/v$VERSION/opta_mac.zip
165-
fi
166-
MAC_ADDRESS=$(ifconfig en1 2>/dev/null | awk '/ether/{print $2}') || true
118+
PACKAGE=https://github.com/run-x/opta/releases/download/v$VERSION/opta_mac.zip
167119
else
168120
abort "Opta is only supported on macOS and Linux."
169121
fi
170122

171-
if [[ ${MAC_ADDRESS} == "" ]]; then
172-
MAC_ADDRESS="unknown"
173-
fi
174-
175-
GIT_EMAIL=$(git config user.email 2>/dev/null) || true
176-
if [[ ${GIT_EMAIL} == "" ]]; then
177-
GIT_EMAIL="unknown"
178-
fi
179-
180123
echo "Downloading installation package..."
181124
curl -s -L "${PACKAGE}" -o /tmp/opta.zip --fail
182125
if [[ $? != 0 ]]; then
@@ -232,5 +175,3 @@ else
232175
echo "export PATH=\$PATH:${RUNPATH}"
233176
echo "to your terminal profile."
234177
fi
235-
236-
sendamplitudeevent "OPTA_INSTALL_SUCCESS"

0 commit comments

Comments
 (0)