#!/bin/sh # Puts the Governate installer on this machine. # # curl -fsSL https://v2.governate.com/install | sudo sh # # It needs Docker, which Governate runs on. It fetches the installer for this # machine's kind of processor from the public registry, puts it on the path # as "governate-install", and says what to run next. It changes nothing else. # # GOVERNATE_INSTALL_DOCKER=1 install Docker first if it is missing # (Debian and Ubuntu) # GOVERNATE_INSTALLER_IMAGE another image to take the installer from, # for example your own mirror # GOVERNATE_BIN_DIR where to put it (default /usr/local/bin) # # Everything is inside one function that runs on the last line, so that a # download cut short runs nothing. set -eu main() { image="${GOVERNATE_INSTALLER_IMAGE:-docker.io/startaworldpeace/governate-install:latest}" bin="${GOVERNATE_BIN_DIR:-/usr/local/bin}" say() { printf '%s\n' "$*"; } fail() { printf '\nerror: %s\n' "$*" >&2; exit 1; } [ "$(uname -s)" = Linux ] || fail "Governate is installed on Linux servers. This is $(uname -s)." case "$(uname -m)" in x86_64|amd64|aarch64|arm64) ;; *) fail "This machine's processor ($(uname -m)) is not one Governate is built for (Intel/AMD 64-bit or ARM 64-bit)." ;; esac [ "$(id -u)" = 0 ] || fail "Run this as root: curl -fsSL https://v2.governate.com/install | sudo sh" if ! command -v docker >/dev/null 2>&1; then if [ "${GOVERNATE_INSTALL_DOCKER:-}" = 1 ] && command -v apt-get >/dev/null 2>&1; then say "Installing Docker..." export DEBIAN_FRONTEND=noninteractive apt-get update -qq >/dev/null apt-get install -y -qq docker.io docker-compose-v2 >/dev/null || fail "Docker could not be installed. See https://docs.docker.com/engine/install/" else fail "Docker is not installed. Install it (https://docs.docker.com/engine/install/) and run this again, or on Debian and Ubuntu let this script do it: curl -fsSL https://v2.governate.com/install | sudo GOVERNATE_INSTALL_DOCKER=1 sh" fi fi docker info >/dev/null 2>&1 || fail "Docker is installed but not running, or this user cannot use it." docker compose version >/dev/null 2>&1 || fail "Docker's compose plugin is missing. See https://docs.docker.com/compose/install/" say "Fetching the Governate installer..." # An image already on this machine, loaded from a file where there is no # outside connection, is used when the registry cannot be reached. docker pull -q "$image" >/dev/null 2>&1 || docker image inspect "$image" >/dev/null 2>&1 || fail "Could not fetch $image. Is this machine able to reach the registry?" id="$(docker create "$image")" trap 'docker rm -f "$id" >/dev/null 2>&1 || true' EXIT mkdir -p "$bin" docker cp "$id:/governate-install" "$bin/governate-install.new" >/dev/null chmod 755 "$bin/governate-install.new" mv "$bin/governate-install.new" "$bin/governate-install" docker rm -f "$id" >/dev/null 2>&1 || true trap - EXIT version="$("$bin/governate-install" -version 2>/dev/null || echo unknown)" cat < plan.json sudo governate-install -plan plan.json Only check this machine? governate-install -check Guide: https://v2.governate.com/get-started DONE } main "$@"