68 lines
1.7 KiB
Bash
Executable File
68 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
# Detect architecture
|
|
ARCH=$(uname -m)
|
|
case "$ARCH" in
|
|
x86_64)
|
|
ARCH="x86_64"
|
|
;;
|
|
aarch64|arm64)
|
|
ARCH="aarch64"
|
|
;;
|
|
*)
|
|
echo "Unsupported architecture: $ARCH"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
# Detect OS
|
|
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
|
if [ "$OS" != "linux" ]; then
|
|
echo "This installer only supports Linux. Detected OS: $OS"
|
|
exit 1
|
|
fi
|
|
|
|
# Set installation directory
|
|
INSTALL_DIR="${HOME}/.local/bin"
|
|
INSTALL_PATH="${INSTALL_DIR}/dshash"
|
|
|
|
# Create installation directory if it doesn't exist
|
|
mkdir -p "${INSTALL_DIR}"
|
|
|
|
# Download dshash binary
|
|
echo "Downloading dshash for ${OS}/${ARCH}..."
|
|
DOWNLOAD_URL="https://getbin.xyz/dshash:latest-${ARCH}"
|
|
|
|
if command -v curl >/dev/null 2>&1; then
|
|
curl -L -s -o "${INSTALL_PATH}" "${DOWNLOAD_URL}"
|
|
elif command -v wget >/dev/null 2>&1; then
|
|
wget -q -O "${INSTALL_PATH}" "${DOWNLOAD_URL}"
|
|
else
|
|
echo "Error: Neither curl nor wget is available. Please install one of them."
|
|
exit 1
|
|
fi
|
|
|
|
# Make it executable
|
|
chmod +x "${INSTALL_PATH}"
|
|
|
|
# Verify installation
|
|
if "${INSTALL_PATH}" /dev/null 2>/dev/null; then
|
|
echo "dshash has been successfully installed to ${INSTALL_PATH}"
|
|
|
|
# Check if directory is in PATH
|
|
if [[ ":$PATH:" != *":${INSTALL_DIR}:"* ]]; then
|
|
echo ""
|
|
echo "Note: ${INSTALL_DIR} is not in your PATH."
|
|
echo "Add the following line to your shell configuration file (.bashrc, .zshrc, etc.):"
|
|
echo " export PATH=\"${INSTALL_DIR}:\$PATH\""
|
|
fi
|
|
else
|
|
echo "Error: Installation verification failed"
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
echo "Installation complete! You can now use 'dshash' to compute SHA256 hashes."
|
|
echo "Usage: dshash [-v] <file_or_directory>" |