37 lines
884 B
Bash
37 lines
884 B
Bash
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
# Get script directory
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
|
|
|
|
PROJECT="simple-object-server"
|
|
|
|
# Set target directory - use ~/.local/bin by default, /usr/local/bin if root
|
|
if [ "$(id -u)" = "0" ]; then
|
|
TARGET_DIR="/usr/local/bin"
|
|
else
|
|
TARGET_DIR="${HOME}/.local/bin"
|
|
# Create ~/.local/bin if it doesn't exist
|
|
mkdir -p "${TARGET_DIR}"
|
|
fi
|
|
|
|
if ! command -v wget >/dev/null 2>&1; then
|
|
echo "wget is not installed. Please install wget and try again."
|
|
exit 1
|
|
fi
|
|
|
|
ARCH=$(uname -m)
|
|
if [ "${ARCH}" = "x86_64" ]; then
|
|
ARCH="amd64"
|
|
elif [ "${ARCH}" = "aarch64" ]; then
|
|
ARCH="arm64"
|
|
else
|
|
echo "Unsupported architecture: ${ARCH}"
|
|
exit 1
|
|
fi
|
|
|
|
wget https://getbin.xyz/simple-object-server:${ARCH} -O "${TARGET_DIR}/simple-object-server"
|
|
chmod +x "${TARGET_DIR}/simple-object-server"
|
|
|