Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ jobs:
with:
name: build
path: build/
test-install-script:
name: Test install script
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get install -y fzf
- name: Test install script
run: |
curl -sSLf https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/install.sh | sh -s -- --url "https://github.com/mads-bisgaard/bayesh/releases/download/v0.0.1/bayesh-v0.0.1-linux-amd64.tar.gz"
bayesh --version
bats-tests:
name: Bats tests
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Bayesh is the auto-suggestion feature on your phone when you write messages —
2. **Install Bayesh:**
To install Bayesh run
```sh
curl -sL https://raw.githubusercontent.com/mads-bisgaard/bayesh/refs/heads/main/install.sh | bash
curl -sSLf https://raw.githubusercontent.com/mads-bisgaard/bayesh/refs/heads/main/install.sh | sh
```

3. **Go!**
Expand Down
23 changes: 11 additions & 12 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

set -e
set -o pipefail

version=v0.0.1
_sudo="sudo"
command -v sudo &> /dev/null || _sudo=""
command -v sudo > /dev/null 2>&1 || _sudo=""
target_dir="/usr/local/bin"
[ -d "$target_dir" ] || target_dir="/usr/bin"
[ -d "$target_dir" ] || { echo "- Error: Could not find /usr/local/bin nor /usr/bin directories." >&2; exit 1; }
Expand All @@ -24,7 +23,7 @@ case "$arch" in
;;
esac

function _usage() {
_usage() {
echo "Usage: install.sh [--help] [--url <url>]"
echo "Install Bayesh."
echo "Options:"
Expand All @@ -34,7 +33,7 @@ function _usage() {
}

url="https://github.com/mads-bisgaard/bayesh/releases/download/${version}/bayesh-${version}-linux-${goarch}.tar.gz"
while [[ $# -gt 0 ]]; do
while [ $# -gt 0 ]; do
case $1 in
--help)
_usage
Expand All @@ -52,22 +51,22 @@ while [[ $# -gt 0 ]]; do
done


function _check_dependency() {
command -v "$1" &> /dev/null || { echo "- Error: Required dependency $1 is not installed." >&2; exit 1; }
_check_dependency() {
command -v "$1" > /dev/null 2>&1 || { echo "- Error: Required dependency $1 is not installed." >&2; exit 1; }
}

function _install_bayesh(){
_install_bayesh(){
echo "- downloading Bayesh ${version} for architecture ${goarch} to ${target_dir}/bayesh"
${_sudo} curl -sSL "$url" | ${_sudo} tar -xzf - -C "${target_dir}"
${_sudo} chmod +x "${target_dir}/bayesh"
command -v "bayesh" &> /dev/null || { echo "- Error: bayesh could not be found after installation." >&2; exit 1; }
command -v "bayesh" > /dev/null 2>&1 || { echo "- Error: bayesh could not be found after installation." >&2; exit 1; }
}

function _print_bayesh() {
_print_bayesh() {
CYAN="\033[94m"
RESET="\033[0m"

echo -e "${CYAN}"
printf "%b\n" "${CYAN}"
echo "░████████ ░██ "
echo "░██ ░██ ░██ "
echo "░██ ░██ ░██████ ░██ ░██ ░███████ ░███████ ░████████ "
Expand All @@ -77,7 +76,7 @@ function _print_bayesh() {
echo "░█████████ ░█████░██ ░█████░██ ░███████ ░███████ ░██ ░██ "
echo " ░██ "
echo " ░███████ "
echo -e "${RESET}"
printf "%b\n" "${RESET}"
echo "- For documentation, see https://github.com/mads-bisgaard/bayesh"
}

Expand Down