Update install.sh
This commit is contained in:
parent
b4f4c344c0
commit
9178e329b1
41
install.sh
41
install.sh
|
@ -1,16 +1,9 @@
|
||||||
|
|
||||||
### 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
|
#!/bin/bash
|
||||||
|
|
||||||
# Define the installation directory and binary name
|
|
||||||
INSTALL_DIR="/usr/local/bin"
|
INSTALL_DIR="/usr/local/bin"
|
||||||
BINARY_NAME="haste-it"
|
BINARY_NAME="haste-it"
|
||||||
|
BASE_URL="https://git.nixc.us/Nixius/haste-it/raw/branch/main/dist"
|
||||||
|
|
||||||
# Define supported architectures and corresponding binaries
|
|
||||||
declare -A binaries
|
declare -A binaries
|
||||||
binaries["linux/amd64"]="haste-it_linux_amd64"
|
binaries["linux/amd64"]="haste-it_linux_amd64"
|
||||||
binaries["linux/arm64"]="haste-it_linux_arm64"
|
binaries["linux/arm64"]="haste-it_linux_arm64"
|
||||||
|
@ -18,42 +11,30 @@ binaries["linux/arm/v7"]="haste-it_linux_arm"
|
||||||
binaries["darwin/amd64"]="haste-it_darwin_amd64"
|
binaries["darwin/amd64"]="haste-it_darwin_amd64"
|
||||||
binaries["darwin/arm64"]="haste-it_darwin_arm64"
|
binaries["darwin/arm64"]="haste-it_darwin_arm64"
|
||||||
|
|
||||||
# Detect the OS and architecture
|
|
||||||
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
||||||
ARCH="$(uname -m)"
|
ARCH="$(uname -m)"
|
||||||
|
|
||||||
case $ARCH in
|
case $ARCH in
|
||||||
x86_64)
|
x86_64) ARCH="amd64" ;;
|
||||||
ARCH="amd64"
|
arm64 | aarch64) ARCH="arm64" ;;
|
||||||
;;
|
arm*) ARCH="arm/v7" ;;
|
||||||
arm64)
|
|
||||||
ARCH="arm64"
|
|
||||||
;;
|
|
||||||
aarch64)
|
|
||||||
ARCH="arm64"
|
|
||||||
;;
|
|
||||||
arm*)
|
|
||||||
ARCH="arm/v7"
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Construct the key for finding the binary
|
|
||||||
KEY="${OS}/${ARCH}"
|
KEY="${OS}/${ARCH}"
|
||||||
|
|
||||||
# Check if the binary exists for this architecture
|
|
||||||
if [[ -z "${binaries[$KEY]}" ]]; then
|
if [[ -z "${binaries[$KEY]}" ]]; then
|
||||||
echo "No pre-built binary for your system architecture ($KEY)."
|
echo "No pre-built binary for your system architecture ($KEY)."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install the binary
|
BINARY_URL="${BASE_URL}/${binaries[$KEY]}"
|
||||||
BINARY_PATH="dist/${binaries[$KEY]}"
|
|
||||||
if [[ -f "$BINARY_PATH" ]]; then
|
echo "Downloading and installing $BINARY_NAME from $BINARY_URL..."
|
||||||
sudo cp "$BINARY_PATH" "$INSTALL_DIR/$BINARY_NAME"
|
sudo curl -sSL "$BINARY_URL" -o "${INSTALL_DIR}/${BINARY_NAME}"
|
||||||
sudo chmod +x "$INSTALL_DIR/$BINARY_NAME"
|
if [[ $? -eq 0 ]]; then
|
||||||
|
sudo chmod +x "${INSTALL_DIR}/${BINARY_NAME}"
|
||||||
echo "Installed $BINARY_NAME to $INSTALL_DIR"
|
echo "Installed $BINARY_NAME to $INSTALL_DIR"
|
||||||
else
|
else
|
||||||
echo "Binary file not found: $BINARY_PATH"
|
echo "Failed to download or install $BINARY_NAME."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue