-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·84 lines (68 loc) · 2.66 KB
/
install.sh
File metadata and controls
executable file
·84 lines (68 loc) · 2.66 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env bash
# plainapp-cli installer
# Usage: bash <(curl -fsSL https://raw.githubusercontent.com/plainhub/plainapp-cli/main/install.sh)
set -euo pipefail
REPO="plainhub/plainapp-cli"
BIN="plainapp-cli"
INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
# ── detect OS and architecture ─────────────────────────────────────────────────
OS=$(uname -s)
ARCH=$(uname -m)
case "$OS" in
Darwin)
case "$ARCH" in
arm64) ASSET="${BIN}-macos-arm64" ;;
x86_64) ASSET="${BIN}-macos-x86_64" ;;
*) echo "Unsupported macOS arch: $ARCH" >&2; exit 1 ;;
esac
;;
Linux)
case "$ARCH" in
x86_64) ASSET="${BIN}-linux-x86_64" ;;
*) echo "Unsupported Linux arch: $ARCH" >&2; exit 1 ;;
esac
;;
*)
echo "Unsupported OS: $OS (Windows users: download from GitHub Releases)" >&2
exit 1
;;
esac
# ── find the latest release ────────────────────────────────────────────
echo "Fetching latest release..."
if command -v curl &>/dev/null; then
FETCH="curl -fsSL"
elif command -v wget &>/dev/null; then
FETCH="wget -qO-"
else
echo "curl or wget is required" >&2; exit 1
fi
TAG=$(
$FETCH "https://api.github.com/repos/${REPO}/releases/latest" \
| grep '"tag_name"' \
| sed 's/.*"tag_name": *"//' \
| sed 's/".*//'
)
if [[ -z "$TAG" ]]; then
echo "Could not find a release. Is there a published release?" >&2
exit 1
fi
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${TAG}/${ASSET}"
echo "Downloading ${ASSET} from ${TAG}..."
# ── download ───────────────────────────────────────────────────────────────────
TMP=$(mktemp)
trap 'rm -f "$TMP"' EXIT
$FETCH "$DOWNLOAD_URL" > "$TMP"
chmod +x "$TMP"
# ── install ────────────────────────────────────────────────────────────────────
if [[ -w "$INSTALL_DIR" ]]; then
mv "$TMP" "${INSTALL_DIR}/${BIN}"
else
echo "Installing to ${INSTALL_DIR} (sudo required)..."
sudo mv "$TMP" "${INSTALL_DIR}/${BIN}"
fi
echo "Installed: $(which ${BIN}) — $(${BIN} --version)"
echo ""
echo "Next steps:"
echo " ${BIN} --init # create example config at ~/.config/plainapp-cli/config.toml"
echo " ${BIN} --schema # fetch GraphQL schema"
echo " ${BIN} -e '{\"query\":\"{ app { battery } }\",\"variables\":null}'"