-
Notifications
You must be signed in to change notification settings - Fork 9
/
install.sh
48 lines (40 loc) · 1.09 KB
/
install.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
#!/bin/bash -e
#
# Download and install the latest release
# Give up on any failure
set -e
set -o pipefail
REPO="walles/px"
PXPREFIX=${PXPREFIX:-/usr/local/bin}
# Get the download URL for the latest release
TEMPFILE=$(mktemp || mktemp -t px-install-releasesjson.XXXXXXXX)
curl -s https://api.github.com/repos/${REPO}/releases >"${TEMPFILE}"
if grep "API rate limit exceeded" "${TEMPFILE}" >/dev/null; then
cat "${TEMPFILE}" >&2
exit 1
fi
URL=$(
grep browser_download_url "${TEMPFILE}" |
cut -d '"' -f 4 |
head -n 1
)
rm "${TEMPFILE}"
echo "Downloading the latest release..."
echo " ${URL}"
TEMPFILE=$(mktemp || mktemp -t px-install.XXXXXXXX)
curl -L -s "${URL}" >"${TEMPFILE}"
chmod a+x "${TEMPFILE}"
echo "Installing the latest release..."
echo
echo "sudo install px.pex ${PXPREFIX}/px"
sudo install "${TEMPFILE}" "${PXPREFIX}/px"
echo "sudo ln px ${PXPREFIX}/ptop"
sudo ln -sf px "${PXPREFIX}/ptop"
echo "sudo ln px ${PXPREFIX}/pxtree"
sudo ln -sf px "${PXPREFIX}/pxtree"
rm -f "${TEMPFILE}"
echo
echo "Installation done, now run one or all of:"
echo " ptop"
echo " pxtree"
echo " px"