-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·83 lines (67 loc) · 2.15 KB
/
install.sh
File metadata and controls
executable file
·83 lines (67 loc) · 2.15 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
#!/bin/sh
# Diecut installer — https://github.com/raiderrobert/diecut
# Usage: curl -fsSL https://diecut.dev/install.sh | sh
set -e
REPO="raiderrobert/diecut"
INSTALL_DIR="${DIECUT_INSTALL_DIR:-/usr/local/bin}"
main() {
platform="$(detect_platform)"
arch="$(detect_arch)"
asset="$(asset_name "$platform" "$arch")"
if [ -z "$asset" ]; then
echo "Error: unsupported platform/architecture: ${platform}/${arch}" >&2
echo "Pre-built binaries are available for:" >&2
echo " - macOS (Apple Silicon / aarch64)" >&2
echo " - Linux (x86_64)" >&2
echo "" >&2
echo "You can build from source instead: cargo install --path ." >&2
exit 1
fi
url="https://github.com/${REPO}/releases/latest/download/${asset}"
echo "Detected: ${platform}/${arch}"
echo "Downloading: ${url}"
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
if command -v curl > /dev/null 2>&1; then
curl -fsSL "$url" -o "${tmpdir}/${asset}"
elif command -v wget > /dev/null 2>&1; then
wget -qO "${tmpdir}/${asset}" "$url"
else
echo "Error: curl or wget is required" >&2
exit 1
fi
tar xzf "${tmpdir}/${asset}" -C "$tmpdir"
if [ -w "$INSTALL_DIR" ]; then
mv "${tmpdir}/diecut" "${INSTALL_DIR}/diecut"
else
echo "Installing to ${INSTALL_DIR} (requires sudo)"
sudo mv "${tmpdir}/diecut" "${INSTALL_DIR}/diecut"
fi
chmod +x "${INSTALL_DIR}/diecut"
echo "Installed diecut to ${INSTALL_DIR}/diecut"
"${INSTALL_DIR}/diecut" --version 2>/dev/null || true
}
detect_platform() {
case "$(uname -s)" in
Linux*) echo "linux" ;;
Darwin*) echo "macos" ;;
*) echo "unknown" ;;
esac
}
detect_arch() {
case "$(uname -m)" in
x86_64|amd64) echo "x86_64" ;;
arm64|aarch64) echo "aarch64" ;;
*) echo "unknown" ;;
esac
}
asset_name() {
platform="$1"
arch="$2"
case "${arch}-${platform}" in
x86_64-linux) echo "diecut-x86_64-linux.tar.gz" ;;
aarch64-macos) echo "diecut-aarch64-macos.tar.gz" ;;
*) echo "" ;;
esac
}
main