-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·92 lines (77 loc) · 2.56 KB
/
install.sh
File metadata and controls
executable file
·92 lines (77 loc) · 2.56 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
#!/usr/bin/env sh
# __
# _____ _______ ____ ____ ____ _____ __ ___/ |_
# \__ \\_ __ \/ ___\ / _ \ / \\__ \ | | \ __\
# / __ \| | \/ /_/ > <_> ) | \/ __ \| | /| |
# (____ /__| \___ / \____/|___| (____ /____/ |__|
# \/ /_____/ \/ \/
# Installer
set -eu
# check that all required commands are available
for cmd in curl tar awk; do
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "Error: $cmd is required but not installed." >&2
exit 1
fi
done
# Optional commands that we have fallbacks for
for cmd in mktemp install; do
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "Warning: $cmd not found, using fallback method" >&2
fi
done
REPO="darksworm/argonaut"
BIN="argonaut"
VERSION="${1:-}"
INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
os=$(uname -s | tr 'A-Z' 'a-z')
case "$os" in
linux|darwin) ;;
*) echo "Unsupported OS: $os" >&2; exit 1 ;;
esac
arch=$(uname -m)
case "$arch" in
x86_64|amd64) arch=amd64 ;;
aarch64|arm64) arch=arm64 ;;
*) echo "Unsupported architecture: $arch" >&2; exit 1 ;;
esac
# Use standard variant for all Linux systems (musl targets no longer built)
libc_suffix=""
if [ -z "$VERSION" ]; then
# use curl to fetch the latest version from GitHub
VERSION="$(curl -s -L "https://api.github.com/repos/$REPO/releases/latest" \
| awk -F'"' '/"tag_name":/ { print $4; exit }' | cut -c 2-)"
if [ -z "$VERSION" ]; then
echo "Error: Failed to fetch latest version from GitHub API" >&2
exit 1
fi
fi
filename="${BIN}-${VERSION}-${os}-${arch}${libc_suffix}.tar.gz"
url="https://github.com/${REPO}/releases/download/v${VERSION}/${filename}"
# Inform user about detected system
if [ "$os" = "linux" ]; then
echo "Detected Linux system, downloading standard variant..."
fi
echo "Downloading $url..."
# Create temporary directory with fallback for systems without mktemp
if command -v mktemp >/dev/null 2>&1; then
tmp="$(mktemp -d)"
else
tmp="/tmp/argonaut-install-$$"
mkdir -p "$tmp"
fi
trap 'rm -rf "$tmp"' EXIT INT TERM
# Download the release
if ! curl -s -L -o "$tmp/$filename" "$url" || [ ! -s "$tmp/$filename" ]; then
echo "Error: Failed to download $filename" >&2
exit 1
fi
tar -xzf "$tmp/$filename" -C "$tmp"
# Install binary with fallback for systems without install command
if command -v install >/dev/null 2>&1; then
install -m 0755 "$tmp/$BIN" "$INSTALL_DIR/$BIN"
else
cp "$tmp/$BIN" "$INSTALL_DIR/$BIN"
chmod 755 "$INSTALL_DIR/$BIN"
fi
echo "Installed $BIN to $INSTALL_DIR"