#!/bin/sh # One-line onboarding for a new or existing InovSea developer, macOS and Linux. Run: # curl -fsSL https://get.inovsea.com/devtools.sh | sh (public copy, founder decision D1) # gh api repos/InovSea/inovsea-dev-cli/contents/scripts/bootstrap.sh --jq .content | base64 -d | sh # No gh yet? Install it first (macOS: brew install gh; Debian/Ubuntu: sudo apt-get install -y gh), run # gh auth login --web, then the line above. Or, once signed in: gh repo clone InovSea/inovsea-dev-cli and sh scripts/bootstrap.sh. # It installs Homebrew (macOS) or apt basics, gh, signs you in with your own GitHub account, clones inovsea-dev-cli into # ~/inovsea.com, builds inovsea and runs `inovsea setup`. Safe to run again. It never stores a secret or creates a token. # INOVSEA_BOOTSTRAP_DRY=1 prints the steps and changes nothing. set -eu # Everything runs inside main, called on the last line: a truncated download runs nothing. main() { root="${INOVSEA_ROOT:-$HOME/inovsea.com}" dry="${INOVSEA_BOOTSTRAP_DRY:-}" say() { printf 'bootstrap: %s\n' "$*"; } run() { if [ -n "$dry" ]; then say "would run: $*"; else "$@"; fi; } have() { command -v "$1" >/dev/null 2>&1; } case "$(uname -s)" in Darwin) if ! have brew; then say "installing Homebrew (official installer)" if [ -n "$dry" ]; then say "would run: the official Homebrew installer" else /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; fi [ -x /opt/homebrew/bin/brew ] && eval "$(/opt/homebrew/bin/brew shellenv)" fi have gh || run brew install gh have go || run brew install go have git || run brew install git ;; Linux) sudo=""; [ "$(id -u)" = 0 ] || sudo=sudo if have apt-get; then if ! { have gh && have go && have git && have make; }; then run $sudo apt-get update; run $sudo apt-get install -y git curl make golang-go gh fi else if ! { have gh && have go && have git; }; then say "no apt-get: install git, gh, go and make yourself, then run this again"; exit 1; fi fi ;; *) say "unsupported system $(uname -s)"; exit 1 ;; esac if [ -z "$dry" ] && ! gh auth status >/dev/null 2>&1; then say "sign in with your own GitHub account" gh auth login --web /dev/null 2>&1; then who=$(gh api user --jq .login 2>/dev/null || echo "unknown") say "your GitHub account '$who' cannot see the InovSea repositories yet." say "1. Accept your invite: https://github.com/orgs/InovSea/invitation (or check your e-mail from GitHub)." say "2. Wrong account? Run: gh auth logout && gh auth login --web, and sign in with the account you were invited with." say "3. Then run this again. Still stuck: ask the tech lead to check your InovSea membership." exit 1 fi repo="$root/inovsea-dev-cli" run mkdir -p "$root" if [ ! -d "$repo/.git" ]; then run gh repo clone InovSea/inovsea-dev-cli "$repo" elif [ -z "$dry" ]; then # An existing checkout must be updated first, or it may lack `inovsea setup`. Only a clean main is touched. if [ "$(git -C "$repo" branch --show-current)" = main ] && [ -z "$(git -C "$repo" status --porcelain)" ]; then git -C "$repo" pull --ff-only || { say "you must update $repo (git pull) and run this again"; exit 1; } else say "you must update $repo to the latest main (clean tree, branch main) and run this again"; exit 1 fi else say "would run: git -C $repo pull --ff-only (clean main only)"; fi if [ -n "$dry" ]; then say "would run: make install in $repo, then inovsea setup"; exit 0; fi (cd "$repo" && make install) PATH="$HOME/.local/bin:$PATH"; export PATH say "make sure ~/.local/bin is on your PATH" exec inovsea setup } main "$@"