-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·103 lines (87 loc) · 2.59 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·103 lines (87 loc) · 2.59 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env sh
set -eu
REPO="${ORANGE_HYPER_REPO:-KoreanCode/orange-hyper}"
VERSION="${ORANGE_HYPER_VERSION:-1.1.0-beta.1}"
INSTALL_DIR="${ORANGE_HYPER_INSTALL_DIR:-"$HOME/.local/bin"}"
TMP_DIR="${TMPDIR:-/tmp}/orange-hyper-install-$$"
cleanup() {
rm -rf "$TMP_DIR"
}
trap cleanup EXIT INT TERM
mkdir -p "$TMP_DIR"
platform="$(uname -s)"
arch="$(uname -m)"
case "$platform" in
Darwin) orange_platform="macos" ;;
Linux) orange_platform="linux" ;;
*) echo "Unsupported platform: $platform" >&2; exit 1 ;;
esac
case "$arch" in
x86_64|amd64) orange_arch="x64" ;;
arm64|aarch64) orange_arch="arm64" ;;
*) echo "Unsupported architecture: $arch" >&2; exit 1 ;;
esac
filename="orange-${orange_platform}-${orange_arch}"
if [ "$orange_platform" = "linux" ] && [ "$orange_arch" != "x64" ]; then
echo "Unsupported Linux architecture: $orange_arch" >&2
exit 1
fi
if [ -n "${ORANGE_HYPER_BASE_URL:-}" ]; then
base_url="${ORANGE_HYPER_BASE_URL%/}"
elif [ "$VERSION" = "latest" ]; then
base_url="https://github.com/$REPO/releases/latest/download"
else
case "$VERSION" in
v*) tag="$VERSION" ;;
*) tag="v$VERSION" ;;
esac
base_url="https://github.com/$REPO/releases/download/$tag"
fi
download() {
url="$1"
output="$2"
if command -v curl >/dev/null 2>&1; then
curl -fsSL "$url" -o "$output"
elif command -v wget >/dev/null 2>&1; then
wget -q "$url" -O "$output"
else
echo "curl or wget is required to download Orange Hyper." >&2
exit 1
fi
}
sha256_file() {
file="$1"
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "$file" | awk '{print $1}'
elif command -v shasum >/dev/null 2>&1; then
shasum -a 256 "$file" | awk '{print $1}'
else
echo "sha256sum or shasum is required to verify Orange Hyper." >&2
exit 1
fi
}
binary_tmp="$TMP_DIR/$filename"
checksums_tmp="$TMP_DIR/checksums.txt"
download "$base_url/checksums.txt" "$checksums_tmp"
download "$base_url/$filename" "$binary_tmp"
expected="$(grep " $filename\$" "$checksums_tmp" | awk '{print $1}')"
if [ -z "$expected" ]; then
echo "Checksum entry not found for $filename." >&2
exit 1
fi
actual="$(sha256_file "$binary_tmp")"
if [ "$actual" != "$expected" ]; then
echo "Checksum mismatch for $filename." >&2
echo "expected: $expected" >&2
echo "actual: $actual" >&2
exit 1
fi
mkdir -p "$INSTALL_DIR"
chmod 755 "$binary_tmp"
cp "$binary_tmp" "$INSTALL_DIR/orange"
chmod 755 "$INSTALL_DIR/orange"
echo "Installed Orange Hyper to $INSTALL_DIR/orange"
if ! command -v orange >/dev/null 2>&1; then
echo "Add this directory to PATH if needed:"
echo " export PATH=\"$INSTALL_DIR:\$PATH\""
fi