-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
70 lines (54 loc) · 1.34 KB
/
install.sh
File metadata and controls
70 lines (54 loc) · 1.34 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
#!/bin/bash
set -e
OS=$(uname -s | tr 'A-Z' 'a-z')
ARCH=$(uname -m)
case "$ARCH" in
x86_64)
ARCH=amd64
;;
aarch64|arm64)
ARCH=arm64
;;
*)
echo "Unsupported architecture: $ARCH" >&2
exit 1
;;
esac
echo "Select the ffwebp variant to install:"
echo " 1) core"
echo " 2) full (default)"
echo " 3) full-play"
read -p "Enter choice [1-3]: " VARIANT_CHOICE || true
case "$VARIANT_CHOICE" in
1)
VARIANT="core"
;;
3)
VARIANT="full-play"
;;
*)
VARIANT="full"
;;
esac
echo "Resolving latest version..."
VERSION=$(curl -sL https://api.github.com/repos/coalaura/ffwebp/releases/latest | grep -Po '"tag_name": *"\K.*?(?=")')
if ! printf '%s\n' "$VERSION" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "Error: '$VERSION' is not in vMAJOR.MINOR.PATCH format" >&2
exit 1
fi
rm -f /tmp/ffwebp
BIN="ffwebp_${VERSION}_${VARIANT}_${OS}_${ARCH}"
URL="https://github.com/coalaura/ffwebp/releases/download/${VERSION}/${BIN}"
echo "Downloading ${BIN}..."
if ! curl -sL "$URL" -o /tmp/ffwebp; then
echo "Error: failed to download $URL" >&2
exit 1
fi
trap 'rm -f /tmp/ffwebp' EXIT
chmod +x /tmp/ffwebp
echo "Installing to /usr/local/bin/ffwebp requires sudo"
if ! sudo install -m755 /tmp/ffwebp /usr/local/bin/ffwebp; then
echo "Error: install failed" >&2
exit 1
fi
echo "ffwebp $VERSION ($VARIANT) installed to /usr/local/bin/ffwebp"