-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·70 lines (60 loc) · 1.72 KB
/
install.sh
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
#! /usr/bin/env bash
# TODO(add support for another target)
if ! command -v curl &>/dev/null; then
echo "curl not installed. Please install curl."
exit
elif ! command -v sed &>/dev/null; then
echo "sed not installed. Please install sed."
exit
fi
REPO_URL="https://github.com/recrin/recrin-cli"
LATEST_RELEASE_URL="https://api.github.com/repos/recrin/recrin-cli/releases/latest"
# shellcheck disable=SC2001
LATEST_VERSION=$(curl $LATEST_RELEASE_URL -s | grep -o '"tag_name": *"[^"]*"' | cut -d '"' -f 4)
_install_binary() {
echo "Installing pre-built binary..."
case "$OSTYPE" in
linux*)
arch=$(uname -m)
case "$arch" in
x86_64) target="Linux_x86_64" ;;
arm64) target="Linux_arm64" ;;
i386) target="Linux_i386 " ;;
*)
echo "Unsupported architecture: $arch"
exit 1
;;
esac
;;
darwin*)
arch=$(uname -m)
case "$arch" in
x86_64) target="Darwin_x86_64" ;;
arm64) target="Darwin_arm64" ;;
*)
echo "Unsupported architecture: $arch"
exit 1
;;
esac
;;
*)
echo "Unsupported operating system: $OSTYPE"
exit 1
;;
esac
echo "Target to install: $target"
EXTENSION="tar.gz"
FILE_NAME="recrin-cli_$target.$EXTENSION"
temp_dir=$(mktemp -d)
pushd "$temp_dir" >/dev/null || exit 1
curl -LO "$REPO_URL/releases/download/$LATEST_VERSION/$FILE_NAME"
mkdir $target && tar -xzf $FILE_NAME -C $target
# tar -xzf "test-release_Darwin_x86_64.tar.gz"
echo "Installing to $HOME/.recrin/bin/recrin"
mkdir -p "$HOME/.recrin/bin/" && mv "$target/recrin" "$HOME/.recrin/bin/"
popd >/dev/null || exit 1
if [[ ":$PATH:" != *":$HOME/.recrin/bin:"* ]]; then
echo "Add $HOME/.recrin/bin to PATH to run recrin"
fi
}
_install_binary