#!/bin/sh # Based on MeCodeGood's cli/install.sh. # Installs the OddsSimply CLI on Mac and Linux: https://oddssimply.com/cli # curl -fsSL https://oddssimply.com/install | sh # # It needs Node 20 or newer. It downloads one file from oddssimply.com, checks it against its # published SHA-256 checksum, puts it in ~/.local/share/oddssimply, and adds a `oddssimply` # command in ~/.local/bin. It changes nothing else: if that folder isn't on your PATH, it tells # you the one line to add. set -eu BASE="${ODDSSIMPLY_URL:-https://oddssimply.com}" BIN_DIR="${ODDSSIMPLY_BIN_DIR:-$HOME/.local/bin}" SHARE_DIR="${ODDSSIMPLY_SHARE_DIR:-$HOME/.local/share/oddssimply}" fail() { printf 'oddssimply install: %s\n' "$*" >&2 exit 1 } if ! command -v node >/dev/null 2>&1; then fail "OddsSimply's CLI needs Node 20 or newer, and Node isn't installed. Get the LTS version from https://nodejs.org, then run this again." fi major=$(node -p 'process.versions.node.split(".")[0]') if [ "$major" -lt 20 ]; then fail "OddsSimply's CLI needs Node 20 or newer; you have $(node -v). Update it from https://nodejs.org, then run this again." fi fetch() { if command -v curl >/dev/null 2>&1; then curl -fsSL "$1" elif command -v wget >/dev/null 2>&1; then wget -qO- "$1" else fail "Neither curl nor wget is installed." fi } sha256() { if command -v sha256sum >/dev/null 2>&1; then sha256sum "$1" | cut -d' ' -f1 else shasum -a 256 "$1" | cut -d' ' -f1 fi } tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT INT TERM fetch "$BASE/cli/oddssimply.mjs" > "$tmp/oddssimply.mjs" || fail "Couldn't download $BASE/cli/oddssimply.mjs. Check your connection and try again." fetch "$BASE/cli/oddssimply.mjs.sha256" > "$tmp/oddssimply.mjs.sha256" || fail "Couldn't download the checksum. Check your connection and try again." expected=$(cut -d' ' -f1 "$tmp/oddssimply.mjs.sha256") actual=$(sha256 "$tmp/oddssimply.mjs") [ "$expected" = "$actual" ] || fail "The download didn't match its checksum, so nothing was installed. Try again in a few minutes." mkdir -p "$SHARE_DIR" "$BIN_DIR" cp "$tmp/oddssimply.mjs" "$SHARE_DIR/oddssimply.mjs" chmod 755 "$SHARE_DIR/oddssimply.mjs" cat > "$BIN_DIR/oddssimply" <> %s\n\n' "$BIN_DIR" "$profile" printf 'Then: oddssimply games\n' ;; esac