-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall_aimit.sh
More file actions
116 lines (96 loc) · 2.82 KB
/
install_aimit.sh
File metadata and controls
116 lines (96 loc) · 2.82 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
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
set -e
REPO_URL="https://raw.githubusercontent.com/TutTrue/Aimit/refs/heads/main"
BINARY_NAME="aimit"
INSTALL_DIR="/usr/local/bin"
detect_platform() {
local os arch
# Detect OS
case "$(uname -s)" in
Linux*) os="linux" ;;
Darwin*) os="macos" ;;
CYGWIN* | MINGW* | MSYS*) os="windows" ;;
*)
echo "Unsupported operating system: $(uname -s)" >&2
exit 1
;;
esac
# Detect architecture
case "$(uname -m)" in
x86_64 | amd64) arch="x86_64" ;;
aarch64 | arm64) arch="aarch64" ;;
armv7l) arch="armv7" ;;
*)
echo "Unsupported architecture: $(uname -m)" >&2
exit 1
;;
esac
# Special case for macOS ARM64 (Apple Silicon)
if [[ "$os" == "macos" && "$arch" == "aarch64" ]]; then
arch="aarch64"
fi
echo "${os}-${arch}"
}
get_binary_name() {
local platform="$1"
case "$platform" in
*windows*) echo "${BINARY_NAME}.exe" ;;
*) echo "$BINARY_NAME" ;;
esac
}
download_binary() {
local platform="$1"
local binary_name="$2"
# Use platform-specific binary name: aimit-{platform}
local platform_binary_name="aimit-${platform}"
local url="$REPO_URL/bin/$platform_binary_name"
echo "Detected platform: $platform"
echo "Downloading binary: $platform_binary_name..."
# Check if wget or curl is available
if command -v wget >/dev/null 2>&1; then
wget -q "$url" -O "$INSTALL_DIR/$binary_name.new"
mv "$INSTALL_DIR/$binary_name.new" "$INSTALL_DIR/$binary_name"
elif command -v curl >/dev/null 2>&1; then
curl -sL "$url" -o "$INSTALL_DIR/$binary_name.new"
mv "$INSTALL_DIR/$binary_name.new" "$INSTALL_DIR/$binary_name"
else
echo "Error: Neither wget nor curl is available. Please install one of them." >&2
exit 1
fi
}
main() {
echo "Installing aimit..."
# Detect platform
platform=$(detect_platform)
binary_name=$(get_binary_name "$platform")
# Create install directory if it doesn't exist
if [[ ! -d "$INSTALL_DIR" ]]; then
echo "Creating install directory: $INSTALL_DIR"
sudo mkdir -p "$INSTALL_DIR"
fi
# Download the appropriate binary
download_binary "$platform" "$binary_name"
# Make binary executable (skip for Windows)
if [[ "$platform" != *"windows"* ]]; then
chmod +x "$INSTALL_DIR/$binary_name"
fi
# Verify installation
if [[ -f "$INSTALL_DIR/$binary_name" ]]; then
echo "Installation successful!"
echo "Binary installed to: $INSTALL_DIR/$binary_name"
echo "Platform: $platform"
# Test if the binary works
if [[ "$platform" != *"windows"* ]]; then
if "$INSTALL_DIR/$binary_name" --version >/dev/null 2>&1; then
echo "Binary is working correctly!"
else
echo "Warning: Binary was installed but may not be working correctly."
fi
fi
else
echo "Installation failed. Please check the script and repository." >&2
exit 1
fi
}
# Run main function
main "$@"