60 lines
1.5 KiB
Bash
Executable File
60 lines
1.5 KiB
Bash
Executable File
|
|
### Installation Script (`install.sh`)
|
|
|
|
Here's a simple bash script to automate the installation process. This script will detect the architecture, find the appropriate binary in the `dist` directory, and install it to `/usr/local/bin`.
|
|
|
|
```bash
|
|
#!/bin/bash
|
|
|
|
# Define the installation directory and binary name
|
|
INSTALL_DIR="/usr/local/bin"
|
|
BINARY_NAME="haste-it"
|
|
|
|
# Define supported architectures and corresponding binaries
|
|
declare -A binaries
|
|
binaries["linux/amd64"]="haste-it_linux_amd64"
|
|
binaries["linux/arm64"]="haste-it_linux_arm64"
|
|
binaries["linux/arm/v7"]="haste-it_linux_arm"
|
|
binaries["darwin/amd64"]="haste-it_darwin_amd64"
|
|
binaries["darwin/arm64"]="haste-it_darwin_arm64"
|
|
|
|
# Detect the OS and architecture
|
|
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
|
ARCH="$(uname -m)"
|
|
|
|
case $ARCH in
|
|
x86_64)
|
|
ARCH="amd64"
|
|
;;
|
|
arm64)
|
|
ARCH="arm64"
|
|
;;
|
|
aarch64)
|
|
ARCH="arm64"
|
|
;;
|
|
arm*)
|
|
ARCH="arm/v7"
|
|
;;
|
|
esac
|
|
|
|
# Construct the key for finding the binary
|
|
KEY="${OS}/${ARCH}"
|
|
|
|
# Check if the binary exists for this architecture
|
|
if [[ -z "${binaries[$KEY]}" ]]; then
|
|
echo "No pre-built binary for your system architecture ($KEY)."
|
|
exit 1
|
|
fi
|
|
|
|
# Install the binary
|
|
BINARY_PATH="dist/${binaries[$KEY]}"
|
|
if [[ -f "$BINARY_PATH" ]]; then
|
|
sudo cp "$BINARY_PATH" "$INSTALL_DIR/$BINARY_NAME"
|
|
sudo chmod +x "$INSTALL_DIR/$BINARY_NAME"
|
|
echo "Installed $BINARY_NAME to $INSTALL_DIR"
|
|
else
|
|
echo "Binary file not found: $BINARY_PATH"
|
|
exit 1
|
|
fi
|
|
|