#!/bin/sh # Installs the infinitodo agent runner on this Mac or Linux computer: # # curl -fsSL https://infinitodo.com/downloads/agent-runner/install.sh | sh # # It downloads the single-file app for this computer into ~/.local/bin # (checking its SHA-256), sets it to run in the background from login on, # and opens its setup page. Nothing needs sudo. Run it again to update. # # INFINITODO_DOWNLOADS where to download from (default below) # INFINITODO_BIN_DIR where to put it (default ~/.local/bin) set -eu base=${INFINITODO_DOWNLOADS:-https://infinitodo.com/downloads/agent-runner} bin_dir=${INFINITODO_BIN_DIR:-$HOME/.local/bin} fail() { echo "infinitodo: $*" >&2; exit 1; } case "$(uname -s)" in Darwin) os=darwin ;; Linux) os=linux ;; *) fail "this installer is for macOS and Linux. On Windows, in PowerShell: irm $base/install.ps1 | iex" ;; esac case "$(uname -m)" in arm64 | aarch64) arch=arm64 ;; x86_64 | amd64) arch=x64 ;; *) fail "no agent runner for this processor ($(uname -m))." ;; esac # An Intel build of the shell on Apple silicon (Rosetta) still gets arm64. if [ "$os" = darwin ] && [ "$arch" = x64 ] && [ "$(sysctl -n sysctl.proc_translated 2>/dev/null)" = 1 ]; then arch=arm64 fi file="infinitodo-agent-$os-$arch" tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT echo "Downloading the infinitodo agent runner ($os, $arch)…" if command -v curl >/dev/null 2>&1; then get() { curl -fsSL "$1" -o "$2"; } elif command -v wget >/dev/null 2>&1; then get() { wget -qO "$2" "$1"; } else fail "needs curl or wget." fi get "$base/$file" "$tmp/$file" || fail "couldn't download $base/$file" get "$base/SHA256SUMS" "$tmp/SHA256SUMS" || fail "couldn't download $base/SHA256SUMS" expected=$(awk -v f="$file" '$2 == f { print $1 }' "$tmp/SHA256SUMS") if command -v sha256sum >/dev/null 2>&1; then actual=$(sha256sum "$tmp/$file" | awk '{ print $1 }') else actual=$(shasum -a 256 "$tmp/$file" | awk '{ print $1 }') fi [ -n "$expected" ] && [ "$expected" = "$actual" ] || fail "the download didn't check out (SHA-256); try again." mkdir -p "$bin_dir" chmod 755 "$tmp/$file" # Moving (not copying over) lets an update replace the app while it's running. mv -f "$tmp/$file" "$bin_dir/infinitodo-agent" echo "Installed $bin_dir/infinitodo-agent" "$bin_dir/infinitodo-agent" install case ":$PATH:" in *":$bin_dir:"*) ;; *) echo "(To use the infinitodo-agent command, add $bin_dir to your PATH.)" ;; esac echo "To remove it later: Uninstall at the bottom of its setup page, or run: $bin_dir/infinitodo-agent uninstall"