Working!
This commit is contained in:
parent
9fdb979c26
commit
4955908984
49
install.sh
Normal file → Executable file
49
install.sh
Normal file → Executable file
@ -1,4 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Require root
|
||||||
|
if [[ $EUID -ne 0 ]]; then
|
||||||
|
echo "This script must be run as root." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Installs bb64 on the local machine.
|
# Installs bb64 on the local machine.
|
||||||
|
|
||||||
@ -12,3 +19,45 @@
|
|||||||
|
|
||||||
# 5. prints a message to the user
|
# 5. prints a message to the user
|
||||||
|
|
||||||
|
# 1. Determine architecture
|
||||||
|
ARCH=$(uname -m)
|
||||||
|
if [[ "$ARCH" == "x86_64" ]]; then
|
||||||
|
BIN=bb64.amd64
|
||||||
|
elif [[ "$ARCH" == "aarch64" || "$ARCH" == "arm64" ]]; then
|
||||||
|
BIN=bb64.arm64
|
||||||
|
else
|
||||||
|
echo "Unsupported architecture: $ARCH" >&2
|
||||||
|
exit 1
|
||||||
|
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')
|
||||||
|
else
|
||||||
|
TAG=$(curl -s "$REPO_API" | grep -m1 '"tag_name"' | sed 's/.*"tag_name"[ ]*:[ ]*"\([^"]*\)".*/\1/')
|
||||||
|
fi
|
||||||
|
if [ -z "$TAG" ] || [ "$TAG" = "null" ]; then
|
||||||
|
echo "Could not determine latest release tag from $REPO_API" >&2
|
||||||
|
exit 1
|
||||||
|
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"
|
||||||
|
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)"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user