-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·50 lines (45 loc) · 1.14 KB
/
install.sh
File metadata and controls
executable file
·50 lines (45 loc) · 1.14 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
#!/bin/bash
set -e
REPO="andreimerlescu/aigcm"
BINARY_NAME="aigcm"
VERSION="1.0.0"
INSTALL_DIR="/usr/local/bin"
function install_with_go() {
echo "✅ Go is installed. Installing with 'go install'..."
go install "github.com/${REPO}@v${VERSION}"
echo "🚀 '${BINARY_NAME}' installed successfully!"
}
function install_without_go() {
local goos
local goarch
goos=$(uname -s | tr '[:upper:]' '[:lower:]')
case $(uname -m) in
x86_64)
goarch="amd64"
;;
aarch64 | arm64)
goarch="arm64"
;;
*)
echo "❌ Unsupported architecture: $(uname -m)"
exit 1
;;
esac
local url="https://github.com/${REPO}/releases/download/v${VERSION}/${BINARY_NAME}-${goos}-${goarch}"
local dest="${INSTALL_DIR}/${BINARY_NAME}"
if [ -w "${INSTALL_DIR}" ]; then
curl -sSLf "${url}" -o "${dest}" 1> /dev/null
else
sudo curl -sSLf "${url}" -o "${dest}" 1> /dev/null
fi
sudo chmod +x "${dest}"
echo "🚀 '${BINARY_NAME}' version ${VERSION} installed successfully to ${dest}"
}
function main() {
if ! command -v go &> /dev/null; then
install_without_go
else
install_with_go
fi
}
main "$@"