-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
install.sh
executable file
·48 lines (40 loc) · 1.49 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/sh
# This is a convenience script that can be downloaded from GitHub and
# piped into "sh" for conveniently downloading the latest GitHub release
# of the pizza CLI:
#
# curl -fsSL https://raw.githubusercontent.com/open-sauced/pizza-cli/main/install.sh | sh
#
# Warning: It may not be advisable to pipe scripts from GitHub directly into
# a command line interpreter! If you do not fully trust the source, first
# download the script, inspect it manually to ensure its integrity, and then
# run it:
#
# curl -fsSL https://raw.githubusercontent.com/open-sauced/pizza-cli/main/install.sh > install.sh
# vim install.sh
# ./install.sh
PIZZA_REPO="open-sauced/pizza-cli"
ARCH=""
# Detect architecture
case "$(uname -m)" in
x86_64) ARCH="x86_64" ;;
arm64) ARCH="arm64" ;;
*) echo "Unsupported architecture"; exit 1 ;;
esac
# Detect OS system type. Windows not supported.
case "$(uname -s)" in
Darwin) OSTYPE="darwin" ;;
*) OSTYPE="linux" ;;
esac
# Fetch download URL for the architecture from the GitHub API
ASSET_URL=$(curl -s https://api.github.com/repos/$PIZZA_REPO/releases/latest | \
grep -o "https:\/\/github\.com\/open-sauced\/pizza-cli\/releases\/download\/.*${OSTYPE}-${ARCH}.*")
if [ -z "$ASSET_URL" ]; then
echo "Could not find a binary for latest version of Pizza CLI release and architecture ${ARCH} on OS type ${OSTYPE}"
exit 1
fi
# Download and install
curl -L "${ASSET_URL}" -o ./pizza
chmod +x ./pizza
echo
echo "Download complete. Stay saucy 🍕"