forked from pranshuparmar/witr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
48 lines (40 loc) · 1.21 KB
/
install.sh
File metadata and controls
48 lines (40 loc) · 1.21 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
# Installs the latest release of witr from GitHub
# Repo: https://github.com/pranshuparmar/witr
#!/usr/bin/env bash
set -euo pipefail
REPO="pranshuparmar/witr"
INSTALL_PATH="/usr/local/bin/witr"
# Detect architecture
ARCH=$(uname -m)
case "$ARCH" in
x86_64|amd64)
ARCH=amd64
;;
aarch64|arm64)
ARCH=arm64
;;
*)
echo "Unsupported architecture: $ARCH" >&2
exit 1
;;
esac
# Get latest release tag from GitHub API
LATEST=$(curl -fsSL "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name"' | cut -d '"' -f4)
if [[ -z "$LATEST" ]]; then
echo "Could not determine latest release tag." >&2
exit 1
fi
URL="https://github.com/$REPO/releases/download/$LATEST/witr-linux-$ARCH"
TMP=$(mktemp)
MANURL="https://github.com/$REPO/releases/download/$LATEST/witr.1"
MAN_TMP=$(mktemp)
# Download binary
curl -fL "$URL" -o "$TMP"
curl -fL "$MANURL" -o "$MAN_TMP"
# Install
sudo install -m 755 "$TMP" "$INSTALL_PATH"
rm -f "$TMP"
sudo install -D -m 644 "$MAN_TMP" /usr/local/share/man/man1/witr.1
rm -f "$MAN_TMP"
echo "witr installed successfully to $INSTALL_PATH (version: $LATEST, arch: $ARCH)"
echo "Man page installed to /usr/local/share/man/man1/witr.1"