This commit is contained in:
Your Name 2025-05-12 19:08:33 +12:00
parent 4955908984
commit 20fc331bd2

View File

@ -8,18 +8,16 @@ if [[ $EUID -ne 0 ]]; then
fi
# Installs bb64 on the local machine.
# 1. determines the architecture of the local machine
# 2. downloads the appropriate bb64 binary from the latest public release on Gitea (https://gitea.jde.nz/j/bb64/releases)
# 3. makes the bb64 binary executable
# 4. moves the bb64 binary to /usr/local/bin
# 5. prints a message to the user
# 1. Determine architecture
# -----------------------------------------------------------------------------
ARCH=$(uname -m)
if [[ "$ARCH" == "x86_64" ]]; then
BIN=bb64.amd64
@ -31,6 +29,7 @@ else
fi
# 2. Get latest release tag from Gitea API
# -----------------------------------------------------------------------------
REPO_API="https://gitea.jde.nz/api/v1/repos/j/bb64/releases"
if command -v jq >/dev/null 2>&1; then
TAG=$(curl -s "$REPO_API" | jq -r '.[0].tag_name')
@ -45,6 +44,7 @@ fi
echo "Latest version of bb64 is: $TAG"
# 3. Download the appropriate binary to a temp directory
# -----------------------------------------------------------------------------
TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT
URL="https://gitea.jde.nz/j/bb64/releases/download/$TAG/$BIN"
@ -53,11 +53,16 @@ echo "Downloading $BIN from $URL..."
curl -L -o "$TMPDIR/bb64" "$URL"
# 4. Make it executable
# -----------------------------------------------------------------------------
chmod +x "$TMPDIR/bb64"
# 5. Move to /usr/local/bin
# -----------------------------------------------------------------------------
mv "$TMPDIR/bb64" /usr/local/bin/bb64
# 6. Print success message
# -----------------------------------------------------------------------------
echo "bb64 installed successfully to /usr/local/bin/bb64 (version $TAG, arch $ARCH)"
echo " "
echo "try it out with:"
echo " bb64 ZWNobyAiSGVsbG8td29ybGQhIGJiNjQgaXMgd29ya2luZy4i"