betterNAS/scripts/install-betternas-node.sh
Harivansh Rathi 18b4ce1a40 Add install script, CI workflows, and release pipeline
- Install script: curl-pipe-sh installer that downloads the right
  binary for the user's OS/arch from GitHub Releases
- CI workflow: runs go vet + go test for both Go modules and builds
  the web app on push/PR
- Release workflow: goreleaser builds cross-platform binaries
  (linux/darwin, amd64/arm64) on version tags
- Node-agent defaults BETTERNAS_CONTROL_PLANE_URL to
  https://api.betternas.com so users only need username/password
2026-04-01 20:37:40 -04:00

70 lines
1.8 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
repo="${BETTERNAS_NODE_REPO:-harivansh-afk/betterNAS}"
binary_name="betternas-node"
install_dir="${BETTERNAS_INSTALL_DIR:-$HOME/.local/bin}"
version="${BETTERNAS_NODE_VERSION:-}"
release_api_url="${BETTERNAS_NODE_RELEASE_API_URL:-https://api.github.com/repos/${repo}/releases/latest}"
download_base_url="${BETTERNAS_NODE_DOWNLOAD_BASE_URL:-https://github.com/${repo}/releases/download}"
if [[ -z "$version" ]]; then
version="$(
curl -fsSL "${release_api_url}" | \
python3 -c 'import json,sys; print(json.load(sys.stdin)["tag_name"])'
)"
fi
os_name="$(uname -s)"
arch_name="$(uname -m)"
case "$os_name" in
Darwin) os="darwin" ;;
Linux) os="linux" ;;
*)
echo "Unsupported OS: $os_name" >&2
exit 1
;;
esac
case "$arch_name" in
x86_64|amd64) arch="amd64" ;;
arm64|aarch64) arch="arm64" ;;
*)
echo "Unsupported architecture: $arch_name" >&2
exit 1
;;
esac
archive_name="${binary_name}_${version}_${os}_${arch}.tar.gz"
download_url="${download_base_url}/${version}/${archive_name}"
tmp_dir="$(mktemp -d)"
cleanup() {
rm -rf "$tmp_dir"
}
trap cleanup EXIT
echo "Downloading ${download_url}"
curl -fsSL "$download_url" -o "${tmp_dir}/${archive_name}"
mkdir -p "$install_dir"
tar -xzf "${tmp_dir}/${archive_name}" -C "$tmp_dir"
install -m 0755 "${tmp_dir}/${binary_name}" "${install_dir}/${binary_name}"
cat <<EOF
Installed ${binary_name} to ${install_dir}/${binary_name}
If ${install_dir} is not in your PATH, add this to your shell profile:
export PATH="${install_dir}:\$PATH"
Then run the node with:
BETTERNAS_USERNAME=your-username \\
BETTERNAS_PASSWORD=your-password \\
BETTERNAS_EXPORT_PATH=/path/to/export \\
BETTERNAS_NODE_DIRECT_ADDRESS=https://your-public-node-url \\
${binary_name}
The control plane defaults to https://api.betternas.com.
EOF