#!/bin/sh # SPDX-FileCopyrightText: 2026 Mycel UG (haftungsbeschränkt) # SPDX-License-Identifier: MIT # # Install osf, the OmniScript command-line tool, on Linux or macOS. # # curl -fsSL https://osf.mycel.me/install.sh | sh # # Options (environment variables): # OSF_VERSION=2.0.0-alpha.6 install this version (default: latest) # OSF_INSTALL_DIR=~/bin install here (default: ~/.local/bin) # # The archive is downloaded from osf.mycel.me and checked against its # SHA-256 sum before anything is installed. set -eu BASE="https://osf.mycel.me/download" DIR="${OSF_INSTALL_DIR:-$HOME/.local/bin}" say() { printf 'osf-install: %s\n' "$*" >&2; } die() { say "error: $*"; exit 1; } need() { command -v "$1" >/dev/null 2>&1 || die "this installer needs '$1'"; } need curl need tar need uname case "$(uname -s)" in Linux) os=unknown-linux-gnu ;; Darwin) os=apple-darwin ;; *) die "unsupported system $(uname -s); on Windows use: irm https://osf.mycel.me/install.ps1 | iex" ;; esac case "$(uname -m)" in x86_64 | amd64) arch=x86_64 ;; aarch64 | arm64) arch=aarch64 ;; *) die "unsupported processor $(uname -m)" ;; esac # A shell running under Rosetta on Apple silicon reports x86_64. if [ "$os" = apple-darwin ] && [ "$arch" = x86_64 ] && [ "$(sysctl -n sysctl.proc_translated 2>/dev/null || echo 0)" = 1 ]; then arch=aarch64 fi target="$arch-$os" version="${OSF_VERSION:-}" if [ -z "$version" ]; then version=$(curl -fsSL --proto '=https' --tlsv1.2 "$BASE/latest" | sed -n 's/.*"version": *"\([^"]*\)".*/\1/p' | head -n 1) [ -n "$version" ] || die "could not find the latest version" fi case "$version" in *[!0-9A-Za-z.-]*) die "bad version '$version'" ;; esac file="osf-cli-$target.tar.xz" tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT INT TERM say "downloading osf $version for $target" curl -fSL --proto '=https' --tlsv1.2 --progress-bar -o "$tmp/$file" "$BASE/$version/$file" curl -fsSL --proto '=https' --tlsv1.2 -o "$tmp/$file.sha256" "$BASE/$version/$file.sha256" expected=$(cut -d ' ' -f 1 "$tmp/$file.sha256") if command -v sha256sum >/dev/null 2>&1; then actual=$(sha256sum "$tmp/$file" | cut -d ' ' -f 1) elif command -v shasum >/dev/null 2>&1; then actual=$(shasum -a 256 "$tmp/$file" | cut -d ' ' -f 1) else die "need sha256sum or shasum to verify the download" fi [ "$expected" = "$actual" ] || die "checksum mismatch for $file (expected $expected, got $actual)" tar -xJf "$tmp/$file" -C "$tmp" mkdir -p "$DIR" install -m 0755 "$tmp/osf-cli-$target/osf" "$DIR/osf" 2>/dev/null || { cp "$tmp/osf-cli-$target/osf" "$DIR/osf" chmod 0755 "$DIR/osf" } say "installed $("$DIR/osf" --version) to $DIR/osf" case ":$PATH:" in *":$DIR:"*) ;; *) say "add $DIR to your PATH, e.g.: echo 'export PATH=\"$DIR:\$PATH\"' >> ~/.profile" ;; esac