added install script
This commit is contained in:
43
install.sh
Normal file
43
install.sh
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
HOST="https://git.briannelson.dev" # your Gitea URL, no trailing slash
|
||||
REPO="brian/rusty-pw"
|
||||
BIN="rusty-pw"
|
||||
DIR="$HOME/.local/bin"
|
||||
|
||||
# Only Apple Silicon Macs are supported for now. Fail clearly otherwise.
|
||||
if [ "$(uname -s)" != "Darwin" ] || [ "$(uname -m)" != "arm64" ]; then
|
||||
echo "This installer only supports macOS on Apple Silicon." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ask Gitea for the newest release tag.
|
||||
tag=$(curl -fsSL "$HOST/api/v1/repos/$REPO/releases/latest" \
|
||||
| sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p' | head -n 1)
|
||||
|
||||
if [ -z "$tag" ]; then
|
||||
echo "Could not find a release for $REPO" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Download and install. curl downloads aren't quarantined, so no Gatekeeper prompt.
|
||||
mkdir -p "$DIR"
|
||||
echo "Downloading $BIN $tag..."
|
||||
curl -fsSL "$HOST/$REPO/releases/download/$tag/$BIN-macos-arm64" -o "$DIR/$BIN"
|
||||
chmod +x "$DIR/$BIN"
|
||||
|
||||
# Put the install folder on PATH for future terminals (zsh is the macOS default).
|
||||
case ":$PATH:" in
|
||||
*":$DIR:"*) ;;
|
||||
*)
|
||||
rc="$HOME/.zshrc"
|
||||
line='export PATH="$HOME/.local/bin:$PATH"'
|
||||
if ! grep -qsF "$line" "$rc"; then
|
||||
echo "$line" >> "$rc"
|
||||
fi
|
||||
echo "Added $DIR to PATH in $rc. Open a new terminal window to use it."
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Installed $BIN $tag. Run: $BIN"
|
||||
Reference in New Issue
Block a user