#!/bin/sh
# NebulaCtrl installer.
#
# curl -fsSL https://get.nebulactrl.dev | sh
#
# Brings up a self-hosted control plane and prints the URL to open. It never
# builds from source and never talks to GitHub (docs/adr/0037, 0038): it pulls
# a published ghcr.io image and downloads deploy/compose.prod.yaml from
# get.nebulactrl.dev, which serves it from a specific release tag. Generates
# its own master key; the only things you must supply are the public URL and
# an OIDC client, because this control plane has no local accounts of its own
# (docs/adr/0012-external-oidc-only-authentication.md).
#
# With a terminal attached it asks for whatever it does not already know,
# showing a summary before it changes anything. Piped into `sh` with no
# terminal, or with -y/--yes, it never prompts: give it everything up front
# with flags or environment variables, or it lists what is missing and exits
# without touching the host.
#
# Re-running is idempotent: the master key, the database password and every
# line you or something else added to .env by hand are preserved forever,
# not just "should be" — only the settings you pass again change. Upgrade by
# re-running with a newer --version (or curl a versioned URL).
#
# It also installs a systemd service, nebula-updater, that lets an owner of
# the Default organization update from the console's Updates page
# (docs/adr/0056). The service runs `
/bin/nebula updater`, a copy of
# the binary taken from the pulled image, and talks to the control plane over
# loopback with NEBULA_UPDATER_TOKEN from .env. It needs systemd and root or
# passwordless sudo; without them the install is complete and the Updates
# page shows the command to run instead. --no-updater skips it.
#
# The master key this writes to .env encrypts every stored secret in the
# install. Lose it and they are unrecoverable. Back up .env somewhere else
# before you need to.
set -eu
# Bumped by release-please via extra-files in release-please-config.json;
# also the default --version and the image tag get.nebulactrl.dev's /vX.Y.Z
# path resolves to.
NEBULA_RELEASE="0.43.2" # x-release-please-version
DEFAULT_REPO="ghcr.io/nebulactrl/nebula"
DEFAULT_DIR="/opt/nebula"
DEFAULT_LISTEN="127.0.0.1:8080"
PROJECT="nebula"
HEALTH_TIMEOUT=180 # seconds
# Releases from FIRST_SIGNED_RELEASE on carry a detached ed25519 signature
# beside every file this script trusts (docs/adr/0061): .sig is the
# base64 of the raw signature over the file's bytes. The key below is the
# one published at https://get.nebulactrl.dev/release-signing.pub and
# embedded in the updater and cli.sh; a rotation changes all of them in one
# release signed by the old key.
FIRST_SIGNED_RELEASE="0.42.0"
RELEASE_SIGNING_KEY='-----BEGIN PUBLIC KEY-----
MCowBQYDK2VwAyEA5kR7Rk3OBo9eOz7xrgIAiyKv1yanOKJHeJJJstWPxlk=
-----END PUBLIC KEY-----'
# The line below every managed .env write; used to find where hand-added
# settings begin when merging into an existing file (see write_env_file).
MANAGED_END="# --- end of install.sh managed settings; anything below this line is yours ---"
# --- presentation ---------------------------------------------------------
#
# Colour, Unicode marks and the pull/health spinner are all cosmetic and all
# degrade the same way: plain, ASCII, static lines on anything that is not
# an interactive, UTF-8, colour-capable terminal, which is what CI logs and
# `tee`'d output are.
TTY=0
[ -t 1 ] && TTY=1
UNICODE=0
if command -v locale >/dev/null 2>&1; then
case "$(locale charmap 2>/dev/null)" in
UTF-8 | UTF8 | utf-8 | utf8) UNICODE=1 ;;
esac
fi
if [ "$UNICODE" -eq 0 ]; then
case "${LC_ALL:-${LC_CTYPE:-${LANG:-}}}" in
*UTF-8* | *UTF8* | *utf-8* | *utf8*) UNICODE=1 ;;
esac
fi
if [ "$UNICODE" -eq 1 ]; then
CHECK="✓" CROSS="✗" ARROW="▸" WARN_MARK="⚠"
SPIN_FRAMES="⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏"
BOX_TL="╭" BOX_TR="╮" BOX_BL="╰" BOX_BR="╯" BOX_H="─" BOX_V="│"
else
CHECK="[ok]" CROSS="[x]" ARROW=">" WARN_MARK="!"
SPIN_FRAMES="| / - \\"
BOX_TL="+" BOX_TR="+" BOX_BL="+" BOX_BR="+" BOX_H="-" BOX_V="|"
fi
SPIN_STATE="$SPIN_FRAMES"
# --- flags, environment and their defaults --------------------------------
BASE_URL="${NEBULA_BASE_URL:-}"
OIDC_ISSUER="${NEBULA_OIDC_ISSUER:-}"
OIDC_CLIENT_ID="${NEBULA_OIDC_CLIENT_ID:-}"
OIDC_CLIENT_SECRET="${NEBULA_OIDC_CLIENT_SECRET:-}"
OIDC_PROVIDER_NAME="${NEBULA_OIDC_PROVIDER_NAME:-}"
DATABASE_URL="${NEBULA_EXTERNAL_DATABASE_URL:-}"
LISTEN="${NEBULA_HOST_LISTEN:-}"
DIR="${NEBULA_INSTALL_DIR:-$DEFAULT_DIR}"
VERSION="${NEBULA_VERSION:-$NEBULA_RELEASE}"
IMAGE="${NEBULA_IMAGE:-}"
COMPOSE_FILE_SRC=""
YES=0
[ "${NEBULA_YES:-0}" = "1" ] && YES=1
NO_COLOR_FLAG=0
DEFAULT_GET_URL="https://get.nebulactrl.dev"
GET_URL="${NEBULA_GET_URL:-$DEFAULT_GET_URL}"
ALLOW_DOWNGRADE=0
[ "${NEBULA_ALLOW_DOWNGRADE:-0}" = "1" ] && ALLOW_DOWNGRADE=1
NO_UPDATER=0
[ "${NEBULA_NO_UPDATER:-0}" = "1" ] && NO_UPDATER=1
# Set by the updater itself when it runs this script: the unit that runs the
# updater must not be restarted or stopped from inside the update it is
# performing (see install_updater_unit).
UPDATER_RUN=0
[ "${NEBULA_UPDATER_RUN:-0}" = "1" ] && UPDATER_RUN=1
die() { printf '%s install: %s\n' "$CROSS" "$*" >&2; exit 1; }
# curl for the get site: https only, even across redirects, TLS 1.2 or newer.
# A plain-http NEBULA_GET_URL (a test mirror) is the one exception.
get_curl() {
case "$GET_URL" in
https://*) curl --proto '=https' --proto-redir '=https' --tlsv1.2 "$@" ;;
*) curl "$@" ;;
esac
}
# Scratch space for downloads that are verified before anything uses them.
# Created on first use, removed on exit by cleanup.
WORK_DIR=""
work_dir() {
[ -n "$WORK_DIR" ] || WORK_DIR=$(mktemp -d) || die "could not create a temporary directory; check that TMPDIR is writable and re-run. Nothing was changed."
}
# openssl does the verification: it is on every supported distribution, and a
# signature check done by shell code would be worse than none. It needs to
# know Ed25519 raw signatures, which is OpenSSL 1.1.1 and later.
require_openssl() {
command -v openssl >/dev/null 2>&1 ||
die "openssl is required to verify the release signature of v$VERSION and is not installed. Install it with your distribution's package manager (for example: apt-get install openssl) and re-run. Nothing was changed."
openssl pkeyutl -help 2>&1 | grep -q -- '-rawin' ||
die "this openssl ($(openssl version 2>/dev/null)) cannot verify Ed25519 signatures, which needs OpenSSL 1.1.1 or newer. Install a newer openssl and re-run. Nothing was changed."
}
# verify_download URL FILE: FILE was just downloaded from URL. Fetches
# URL.sig and checks it against FILE. On any failure FILE is deleted and the
# script stops, so an unverified file can never be used by a later step.
verify_download() {
vd_url=$1
vd_file=$2
work_dir
vd_key="$WORK_DIR/release-signing.pem"
vd_sig="$WORK_DIR/signature"
printf '%s\n' "$RELEASE_SIGNING_KEY" >"$vd_key"
if ! get_curl -fsSL --max-time 30 "$vd_url.sig" -o "$vd_sig.b64"; then
rm -f "$vd_file"
die "could not download the signature $vd_url.sig, and v$VERSION is only installed from files that verify. Nothing was changed. Check that this host can reach $GET_URL and re-run; if it keeps failing, see how to verify and install a release by hand at https://docs.nebulactrl.dev/self-hosting/upgrade/#install-a-release-by-hand."
fi
if tr -d ' \t\r\n' <"$vd_sig.b64" | openssl base64 -d -A -out "$vd_sig" 2>/dev/null &&
openssl pkeyutl -verify -pubin -inkey "$vd_key" -rawin -in "$vd_file" -sigfile "$vd_sig" >/dev/null 2>&1; then
return 0
fi
rm -f "$vd_file"
die "$vd_url does not match its signature (the release signing key did not sign these bytes), so it was not used and nothing was changed. It may have been altered in transit or on the release site. Do not run it; retry later, and if it keeps failing report it to the NebulaCtrl maintainers as a security issue."
}
usage() {
cat </api/v1/auth/callback.
--oidc-issuer URL Must serve /.well-known/openid-configuration.
Env NEBULA_OIDC_ISSUER. Required.
--oidc-client-id ID Env NEBULA_OIDC_CLIENT_ID. Required.
--oidc-client-secret SECRET Env NEBULA_OIDC_CLIENT_SECRET (preferred: argv
is visible in ps). Required.
--oidc-provider-name NAME Sign-in button label. Env
NEBULA_OIDC_PROVIDER_NAME. Default: issuer host.
--database-url URL External PostgreSQL. Env
NEBULA_EXTERNAL_DATABASE_URL. Default: run a
bundled Postgres.
--listen ADDR Host bind address. Env NEBULA_HOST_LISTEN.
Default $DEFAULT_LISTEN.
--dir PATH Install directory (.env, deploy/compose.prod.yaml).
Env NEBULA_INSTALL_DIR. Default $DEFAULT_DIR.
--version X.Y.Z Release to run. Env NEBULA_VERSION. Default:
the version this script was released with
($NEBULA_RELEASE).
--allow-downgrade Allow installing an older --version than what
is already running (migrations are forward-
only; refused otherwise). Env
NEBULA_ALLOW_DOWNGRADE=1.
--image REF Override image (mirror/registry). Env
NEBULA_IMAGE. Default $DEFAULT_REPO:.
--compose-file PATH Use a local compose file instead of downloading
https://get.nebulactrl.dev/v/compose.yaml
(air-gapped installs, or from a checkout).
-y, --yes Never prompt; fail listing every missing
required value. Env NEBULA_YES=1.
--no-color Disable colour. Env NO_COLOR (any value).
--no-updater Do not install the nebula-updater systemd service
that runs updates requested from the console.
Env NEBULA_NO_UPDATER=1.
-h, --help This help.
Env NEBULA_GET_URL overrides the download host (default
https://get.nebulactrl.dev); useful for mirrors and tests.
EOF
}
while [ $# -gt 0 ]; do
case "$1" in
--base-url) BASE_URL="${2:?--base-url needs a value}" && shift 2 ;;
--oidc-issuer) OIDC_ISSUER="${2:?--oidc-issuer needs a value}" && shift 2 ;;
--oidc-client-id) OIDC_CLIENT_ID="${2:?--oidc-client-id needs a value}" && shift 2 ;;
--oidc-client-secret) OIDC_CLIENT_SECRET="${2:?--oidc-client-secret needs a value}" && shift 2 ;;
--oidc-provider-name) OIDC_PROVIDER_NAME="${2:?--oidc-provider-name needs a value}" && shift 2 ;;
--database-url) DATABASE_URL="${2:?--database-url needs a value}" && shift 2 ;;
--listen) LISTEN="${2:?--listen needs a value}" && shift 2 ;;
--dir) DIR="${2:?--dir needs a value}" && shift 2 ;;
--version) VERSION="${2:?--version needs a value}" && shift 2 ;;
--image) IMAGE="${2:?--image needs a value}" && shift 2 ;;
--compose-file) COMPOSE_FILE_SRC="${2:?--compose-file needs a value}" && shift 2 ;;
--allow-downgrade) ALLOW_DOWNGRADE=1 && shift ;;
-y | --yes) YES=1 && shift ;;
--no-color) NO_COLOR_FLAG=1 && shift ;;
--no-updater) NO_UPDATER=1 && shift ;;
-h | --help) usage && exit 0 ;;
*) usage >&2 && die "unknown option $1" ;;
esac
done
# --- colour, now that --no-color is known ---------------------------------
COLOR_MODE=none
if [ -z "${NO_COLOR:-}" ] && [ "$NO_COLOR_FLAG" -eq 0 ] && [ "$TTY" -eq 1 ]; then
case "${TERM:-}" in
'' | dumb) COLOR_MODE=none ;;
*256color*) COLOR_MODE=256 ;;
*) COLOR_MODE=bold ;;
esac
fi
case "$COLOR_MODE" in
256)
HI=$(printf '\033[1;38;5;141m')
RESET=$(printf '\033[0m')
;;
bold)
HI=$(printf '\033[1m')
RESET=$(printf '\033[0m')
;;
*)
HI=""
RESET=""
;;
esac
say() { printf ' %s %s\n' "$ARROW" "$*"; }
ok() { printf ' %s %s\n' "$CHECK" "$*"; }
warn() { printf ' %s warning: %s\n' "$WARN_MARK" "$*" >&2; }
step() { printf '\n%s[%s/7]%s %s\n' "$HI" "$1" "$RESET" "$2"; }
# --- terminal state restore ------------------------------------------------
#
# ask_secret turns off local echo on /dev/tty for one read. If the process is
# killed mid-read (Ctrl-C, the pipe closing) the terminal must not stay in
# noecho state for whatever the user runs next.
TTY_ECHO_OFF=0
restore_tty() {
if [ "$TTY_ECHO_OFF" -eq 1 ]; then
stty echo <&3 2>/dev/null || true
TTY_ECHO_OFF=0
fi
}
# Runs on every exit: the terminal is put back and scratch downloads go.
cleanup() {
restore_tty
[ -z "$WORK_DIR" ] || rm -rf "$WORK_DIR"
}
trap cleanup EXIT INT TERM HUP
DIR=$(printf '%s' "$DIR" | sed 's:/*$::')
[ -n "$DIR" ] || DIR="/"
ENV_FILE="$DIR/.env"
COMPOSE_FILE="$DIR/deploy/compose.prod.yaml"
# Last value of KEY=... in an existing .env; empty (not an error) if the
# file or the key does not exist yet. Defined this early — ahead of every
# validation below — so each option can resolve flag > env > existing .env
# > default before anything depends on it (e.g. --listen's port check in
# step 1).
read_env() {
[ -f "$ENV_FILE" ] || return 0
sed -n "s/^$1=//p" "$ENV_FILE" | tail -1
}
# Flag/env already set $LISTEN above, or left it empty; fall back to
# whatever a previous run wrote to .env before defaulting, so a bare
# re-run with no new --listen never clobbers a customised bind address
# (and, with it, silently recreates the container on the loopback default).
LISTEN_DEFAULTED=0
[ -n "$LISTEN" ] || LISTEN=$(read_env NEBULA_HOST_LISTEN)
if [ -z "$LISTEN" ]; then
LISTEN="$DEFAULT_LISTEN"
LISTEN_DEFAULTED=1
fi
print_banner() {
if [ "$UNICODE" -eq 1 ]; then
printf '\n%s◆ NebulaCtrl%s installer · v%s\n\n' "$HI" "$RESET" "$VERSION"
else
printf '\n%s* NebulaCtrl%s installer - v%s\n\n' "$HI" "$RESET" "$VERSION"
fi
}
# Draws a border around each argument as one line. Width is computed from the
# longest line so it fits URLs, paths and commands of any length without a
# fixed guess.
print_box() {
maxlen=0
for line in "$@"; do
len=${#line}
[ "$len" -gt "$maxlen" ] && maxlen=$len
done
border=""
i=0
while [ "$i" -lt $((maxlen + 2)) ]; do
border="$border$BOX_H"
i=$((i + 1))
done
printf '%s%s%s\n' "$BOX_TL" "$border" "$BOX_TR"
for line in "$@"; do
pad=$((maxlen - ${#line}))
spaces=""
i=0
while [ "$i" -lt "$pad" ]; do
spaces="$spaces "
i=$((i + 1))
done
printf '%s %s%s %s\n' "$BOX_V" "$line" "$spaces" "$BOX_V"
done
printf '%s%s%s\n' "$BOX_BL" "$border" "$BOX_BR"
}
print_banner
# --- interactive prompting -------------------------------------------------
#
# /dev/tty, not stdin: stdin is the script body itself when piped from curl.
# Opening fd 3 once here both proves a terminal is actually reachable (some
# containers and cron have no controlling terminal at all, so /dev/tty exists
# but cannot be opened) and gives every prompt a stable descriptor to use.
INTERACTIVE=0
if [ "$YES" -eq 0 ] && [ "$TTY" -eq 1 ] && exec 3<>/dev/tty 2>/dev/null; then
INTERACTIVE=1
fi
ask() {
label=$1
default=$2
if [ -n "$default" ]; then
printf ' %s [%s]: ' "$label" "$default" >&3
else
printf ' %s: ' "$label" >&3
fi
IFS= read -r reply <&3 || reply=""
if [ -z "$reply" ]; then
printf '%s' "$default"
else
printf '%s' "$reply"
fi
}
ask_secret() {
label=$1
have=$2
TTY_ECHO_OFF=1
stty -echo <&3 2>/dev/null || true
if [ -n "$have" ]; then
printf ' %s [keep existing]: ' "$label" >&3
else
printf ' %s: ' "$label" >&3
fi
IFS= read -r reply <&3 || reply=""
stty echo <&3 2>/dev/null || true
TTY_ECHO_OFF=0
printf '\n' >&3
if [ -z "$reply" ]; then
printf '%s' "$have"
else
printf '%s' "$reply"
fi
}
confirm() {
printf '\n%s [Y/n]: ' "$1" >&3
IFS= read -r reply <&3 || reply=""
case "$reply" in
'' | [Yy] | [Yy][Ee][Ss]) return 0 ;;
*) return 1 ;;
esac
}
# --- spinner ---------------------------------------------------------------
#
# spin_tick is called directly, never as $(spin_tick): a command substitution
# runs in a subshell, and the rotation it advances would be lost the moment
# the subshell exited instead of persisting to the next call.
spin_tick() {
frame=${SPIN_STATE%% *}
case "$SPIN_STATE" in
*" "*) SPIN_STATE="${SPIN_STATE#* } $frame" ;;
*) SPIN_STATE="$frame" ;;
esac
printf '\r%s %s ' "$frame" "$1"
}
clear_line() { printf '\r%-72s\r' ' '; }
# Runs "$@" in the background; animates $1... on a TTY, prints a plain
# progress line otherwise (this is what CI and `tee`'d logs get). On failure,
# the command's combined output is shown so the person running this sees why.
with_spinner() {
msg=$1
shift
log=$(mktemp 2>/dev/null) || log="/tmp/nebula-install.$$.log"
"$@" >"$log" 2>&1 &
pid=$!
if [ "$TTY" -eq 1 ]; then
SPIN_STATE="$SPIN_FRAMES"
while kill -0 "$pid" 2>/dev/null; do
spin_tick "$msg"
sleep 0.2
done
clear_line
else
printf '%s...\n' "$msg"
fi
rc=0
wait "$pid" || rc=$?
if [ "$rc" -ne 0 ]; then
sed 's/^/ /' "$log" >&2
fi
rm -f "$log"
return "$rc"
}
# --- validation --------------------------------------------------------
is_http_url() {
case "$1" in
http://* | https://*) return 0 ;;
*) return 1 ;;
esac
}
strip_slash() { printf '%s' "${1%/}"; }
provider_name_from_issuer() { printf '%s' "$1" | sed -E 's#^https?://##; s#/.*##'; }
validate_listen() {
case "$1" in
*:*) : ;;
*) return 1 ;;
esac
host=${1%:*}
port=${1##*:}
[ -n "$host" ] || return 1
case "$port" in '' | *[!0-9]*) return 1 ;; esac
[ "$port" -ge 1 ] && [ "$port" -le 65535 ]
}
# Accepts a leading "v" (the versioned get.nebulactrl.dev/vX.Y.Z path shape)
# and semver's optional -prerelease suffix; rejects everything else so a typo
# fails here instead of as a confusing image-pull or download 404 later.
validate_semver() {
v=$1
case "$v" in
*-*)
core=${v%%-*}
pre=${v#*-}
;;
*)
core=$v
pre=""
;;
esac
oldifs=$IFS
IFS=.
set -f
# shellcheck disable=SC2086 # intentional splitting on IFS=. to read 3 parts
set -- $core
set +f
IFS=$oldifs
[ $# -eq 3 ] || return 1
for part in "$1" "$2" "$3"; do
case "$part" in '' | *[!0-9]*) return 1 ;; esac
done
if [ -n "$pre" ]; then
case "$pre" in '' | *[!0-9A-Za-z.-]*) return 1 ;; esac
fi
return 0
}
# Strips leading zeros from a numeric string. Shell arithmetic treats a
# leading zero as octal (so "08" is a syntax error and "023" silently means
# 19), and versions like 0.23.2 are exactly the kind of input that trips it.
strip_lead_zeros() {
z=$1
z=${z#"${z%%[!0]*}"}
[ -n "$z" ] || z=0
printf '%s' "$z"
}
# True (exit 0) if semver $1 is strictly older than semver $2, comparing
# only the numeric X.Y.Z core (a -prerelease suffix, if any, is not
# ordered). Both arguments are assumed already validate_semver-clean.
version_lt() {
a_core=${1%%-*}
b_core=${2%%-*}
oldifs=$IFS
IFS=.
set -f
# shellcheck disable=SC2086 # intentional splitting on IFS=.
set -- $a_core
set +f
IFS=$oldifs
a_major=$(strip_lead_zeros "$1") a_minor=$(strip_lead_zeros "$2") a_patch=$(strip_lead_zeros "$3")
oldifs=$IFS
IFS=.
set -f
# shellcheck disable=SC2086 # intentional splitting on IFS=.
set -- $b_core
set +f
IFS=$oldifs
b_major=$(strip_lead_zeros "$1") b_minor=$(strip_lead_zeros "$2") b_patch=$(strip_lead_zeros "$3")
[ "$a_major" -lt "$b_major" ] && return 0
[ "$a_major" -gt "$b_major" ] && return 1
[ "$a_minor" -lt "$b_minor" ] && return 0
[ "$a_minor" -gt "$b_minor" ] && return 1
[ "$a_patch" -lt "$b_patch" ]
}
# True if a Linux socket is already LISTENing on $1, read straight from
# /proc/net/tcp{,6} (Linux is already required by preflight) rather than
# depending on ss/netstat/lsof being installed.
port_listening() {
hexport=$(printf '%04X' "$1")
for f in /proc/net/tcp /proc/net/tcp6; do
[ -r "$f" ] || continue
if awk -v want="$hexport" '
NR>1 { split($2,a,":"); if (toupper(a[2])==want && $4=="0A") found=1 }
END { exit !found }
' "$f"; then
return 0
fi
done
return 1
}
# --- docker, run through sudo only when the socket needs it --------------
USE_SUDO_DOCKER=0
DOCKER_DISPLAY="docker"
docker_cmd() {
if [ "$USE_SUDO_DOCKER" -eq 1 ]; then
sudo docker "$@"
else
docker "$@"
fi
}
# --profile local-db only when this install runs the bundled Postgres.
compose_cmd() {
if [ -n "$DATABASE_URL" ]; then
docker_cmd compose -p "$PROJECT" -f "$COMPOSE_FILE" --env-file "$ENV_FILE" "$@"
else
docker_cmd compose -p "$PROJECT" -f "$COMPOSE_FILE" --env-file "$ENV_FILE" --profile local-db "$@"
fi
}
# --- console updates -------------------------------------------------------
#
# The updater is optional by design: an install that cannot have it is a
# complete install, so every failure below warns and carries on.
UNIT_NAME="nebula-updater.service"
UNIT_FILE="/etc/systemd/system/$UNIT_NAME"
UPDATER_BLOCKER=""
UPDATER_OK=0
# Prints why this host cannot run the updater service, or nothing when it can.
updater_blocker() {
if [ "$NO_UPDATER" -eq 1 ]; then
printf '%s' "it was turned off with --no-updater"
elif ! command -v systemctl >/dev/null 2>&1 || [ ! -d /run/systemd/system ]; then
printf '%s' "this host does not run systemd"
elif [ "$(id -u)" -ne 0 ] && ! sudo -n true >/dev/null 2>&1; then
printf '%s' "installing a systemd service needs root or passwordless sudo, and $(id -un) has neither"
else
# ExecStart is written unquoted, so a path systemd would split or
# expand cannot be used.
case "$DIR" in
*[[:space:]]* | *%* | *\$*) printf '%s' "$DIR contains a space, % or \$, which the service file cannot hold" ;;
*)
case "$GET_URL" in
*[[:space:]]* | *%* | *\$*) printf '%s' "$GET_URL contains a space, % or \$, which the service file cannot hold" ;;
esac
;;
esac
fi
}
run_root() {
if [ "$(id -u)" -eq 0 ]; then
"$@"
else
sudo -n "$@"
fi
}
# Copies /usr/local/bin/nebula out of $IMAGE to $DIR/bin/nebula, which is what
# the service runs. The file is staged beside its destination and renamed into
# place, so a running updater never sees half a binary, and it is streamed
# through tar into a file this user owns (docker cp to a path would make it
# root's when docker runs through sudo).
install_updater_binary() {
bin_dir="$DIR/bin"
mkdir -p "$bin_dir" || return 1
stage=$(mktemp -d "$bin_dir/.nebula.XXXXXX") || return 1
copied=1
if cid=$(docker_cmd create "$IMAGE" 2>/dev/null); then
if docker_cmd cp "$cid:/usr/local/bin/nebula" - 2>/dev/null | tar -xOf - >"$stage/nebula" 2>/dev/null &&
[ -s "$stage/nebula" ] && chmod 0755 "$stage/nebula"; then
copied=0
fi
docker_cmd rm "$cid" >/dev/null 2>&1 || true
fi
# A binary that does not run here, or is not this release, is worse than
# none: the updater would restart onto it.
if [ "$copied" -eq 0 ]; then
bin_reported=$("$stage/nebula" version 2>/dev/null | head -1) || bin_reported=""
case "$bin_reported" in
*"$VERSION"*) : ;;
*) copied=1 ;;
esac
fi
if [ "$copied" -eq 0 ] && ! mv -f "$stage/nebula" "$bin_dir/nebula"; then
copied=1
fi
rm -rf "$stage"
return "$copied"
}
# Writes the nebula-updater unit and starts it. Under NEBULA_UPDATER_RUN=1 this
# script is a child of that very service, so it never restarts or stops it:
# that would kill the update in progress. There it only rewrites a changed
# unit and reloads systemd; the updater exits by itself once it has reported,
# and Restart=always starts the new binary.
install_updater_unit() {
# A mirror the installer was pointed at is where every later update comes
# from too; the default needs no flag.
updater_args="--dir $DIR"
if [ "$GET_URL" != "$DEFAULT_GET_URL" ]; then
updater_args="$updater_args --get-url $GET_URL"
fi
unit_tmp=$(mktemp "${TMPDIR:-/tmp}/nebula-updater.XXXXXX") || return 1
cat >"$unit_tmp" </dev/null 2>&1 || return 1
run_root systemctl restart "$UNIT_NAME" || return 1
ok "$UNIT_NAME is running $DIR/bin/nebula updater"
}
################################################################################
# [1/7] Checking your system
################################################################################
step 1 "Checking your system"
os=$(uname -s)
[ "$os" = "Linux" ] || die "NebulaCtrl only supports Linux hosts (this one reports $os); nothing was changed."
arch=$(uname -m)
case "$arch" in
x86_64 | amd64 | aarch64 | arm64) : ;;
*) die "NebulaCtrl only publishes linux/amd64 and linux/arm64 images; this host is $arch, so nothing was changed." ;;
esac
ok "Linux ($arch)"
command -v curl >/dev/null 2>&1 || die "curl is required but not installed; install it with your distribution's package manager and re-run."
ok "curl"
command -v docker >/dev/null 2>&1 ||
die "docker is not installed. NebulaCtrl runs in containers and does not install Docker for you: see https://docs.docker.com/engine/install/ and re-run."
if ! docker info >/dev/null 2>&1; then
if sudo -n docker info >/dev/null 2>&1; then
# The daemon answers root but not this user. Drive it through
# passwordless sudo rather than adding anyone to the docker group,
# which is root-equivalent and would need a re-login anyway.
USE_SUDO_DOCKER=1
DOCKER_DISPLAY="sudo docker"
else
die "cannot talk to the docker daemon as $(id -un) or through passwordless sudo. Start Docker, or add $(id -un) to the docker group or grant it passwordless sudo, then re-run."
fi
fi
docker_cmd compose version >/dev/null 2>&1 ||
die "the docker compose plugin is not installed. NebulaCtrl does not install Docker for you: see https://docs.docker.com/engine/install/ (it ships the compose plugin) and re-run."
ok "Docker + compose plugin ($DOCKER_DISPLAY)"
# Get write access to $DIR with the least privilege that works: try it
# unprivileged first, and only reach for sudo — once, to fix ownership — if
# that fails, so every write after this point stays unprivileged.
if [ -d "$DIR" ] && [ -w "$DIR" ]; then
:
elif mkdir -p "$DIR" 2>/dev/null; then
:
elif sudo -n mkdir -p "$DIR" 2>/dev/null && sudo -n chown -R "$(id -u):$(id -g)" "$DIR" 2>/dev/null; then
:
else
die "cannot create or write $DIR as $(id -un), and no passwordless sudo is available. Run: sudo mkdir -p $DIR && sudo chown $(id -un) $DIR, then re-run."
fi
ok "$DIR is writable"
validate_listen "$LISTEN" || die "--listen must be host:port (got '$LISTEN')."
listen_port=${LISTEN##*:}
existing_cid=""
if [ -f "$ENV_FILE" ] && [ -f "$COMPOSE_FILE" ]; then
existing_cid=$(compose_cmd ps -q nebula 2>/dev/null) || existing_cid=""
fi
if [ -z "$existing_cid" ] && port_listening "$listen_port"; then
die "port $listen_port is already in use by something else on this host. Pick a free one with --listen, or stop whatever is using it and re-run."
fi
################################################################################
# [2/7] Configuration
################################################################################
step 2 "Configuration"
[ -n "$BASE_URL" ] || BASE_URL=$(read_env NEBULA_BASE_URL)
[ -n "$OIDC_ISSUER" ] || OIDC_ISSUER=$(read_env NEBULA_OIDC_ISSUER)
[ -n "$OIDC_CLIENT_ID" ] || OIDC_CLIENT_ID=$(read_env NEBULA_OIDC_CLIENT_ID)
[ -n "$OIDC_CLIENT_SECRET" ] || OIDC_CLIENT_SECRET=$(read_env NEBULA_OIDC_CLIENT_SECRET)
[ -n "$OIDC_PROVIDER_NAME" ] || OIDC_PROVIDER_NAME=$(read_env NEBULA_OIDC_PROVIDER_NAME)
[ -n "$DATABASE_URL" ] || DATABASE_URL=$(read_env NEBULA_EXTERNAL_DATABASE_URL)
if [ "$INTERACTIVE" -eq 1 ]; then
while [ -z "$BASE_URL" ] || ! is_http_url "$BASE_URL"; do
[ -n "$BASE_URL" ] && printf ' a http(s) URL is required.\n' >&3
BASE_URL=$(ask "Base URL (public, e.g. https://nebula.example.com)" "$BASE_URL")
done
while [ -z "$OIDC_ISSUER" ] || ! is_http_url "$OIDC_ISSUER"; do
[ -n "$OIDC_ISSUER" ] && printf ' a http(s) URL is required.\n' >&3
OIDC_ISSUER=$(ask "OIDC issuer" "$OIDC_ISSUER")
done
while [ -z "$OIDC_CLIENT_ID" ]; do
OIDC_CLIENT_ID=$(ask "OIDC client ID" "$OIDC_CLIENT_ID")
done
while [ -z "$OIDC_CLIENT_SECRET" ]; do
OIDC_CLIENT_SECRET=$(ask_secret "OIDC client secret" "$OIDC_CLIENT_SECRET")
done
if [ ! -f "$ENV_FILE" ]; then
# First install only: also ask about the optional settings,
# skipping anything already supplied by a flag or environment
# variable. A re-run (an existing .env) only ever re-prompts for
# whichever of the four required values above is still missing.
if [ -z "$OIDC_PROVIDER_NAME" ]; then
OIDC_PROVIDER_NAME=$(ask "Sign-in button label" "$(provider_name_from_issuer "$OIDC_ISSUER")")
fi
if [ -z "$DATABASE_URL" ]; then
printf ' leave blank to run a bundled Postgres container.\n' >&3
while :; do
DATABASE_URL=$(ask "Database (postgres://...)" "$DATABASE_URL")
[ -z "$DATABASE_URL" ] && break
case "$DATABASE_URL" in postgres://* | postgresql://*) break ;; esac
printf ' must start with postgres:// or postgresql:// (or leave blank for the bundled database).\n' >&3
done
fi
if [ "$LISTEN_DEFAULTED" -eq 1 ]; then
printf ' the default expects a reverse proxy terminating TLS in front of it; 0.0.0.0:8080 exposes it directly.\n' >&3
while :; do
LISTEN=$(ask "Listen address" "$LISTEN")
validate_listen "$LISTEN" && break
printf ' must be host:port.\n' >&3
done
fi
fi
else
missing=""
is_http_url "$BASE_URL" 2>/dev/null || missing="$missing
base URL --base-url URL (or NEBULA_BASE_URL)"
is_http_url "$OIDC_ISSUER" 2>/dev/null || missing="$missing
OIDC issuer --oidc-issuer URL (or NEBULA_OIDC_ISSUER)"
[ -n "$OIDC_CLIENT_ID" ] || missing="$missing
OIDC client ID --oidc-client-id ID (or NEBULA_OIDC_CLIENT_ID)"
[ -n "$OIDC_CLIENT_SECRET" ] || missing="$missing
OIDC client secret --oidc-client-secret SECRET (or NEBULA_OIDC_CLIENT_SECRET)"
if [ -n "$missing" ]; then
printf '%s install: missing required configuration; nothing was changed. Set:%s\n' "$CROSS" "$missing" >&2
exit 1
fi
fi
BASE_URL=$(strip_slash "$BASE_URL")
OIDC_ISSUER=$(strip_slash "$OIDC_ISSUER")
if [ -z "$OIDC_PROVIDER_NAME" ]; then
OIDC_PROVIDER_NAME=$(provider_name_from_issuer "$OIDC_ISSUER")
fi
INSECURE_HTTP=false
case "$OIDC_ISSUER" in
http://*)
INSECURE_HTTP=true
warn "the issuer is plain http; that is a development configuration (NEBULA_OIDC_INSECURE_HTTP=true)"
;;
esac
validate_semver "$VERSION" || die "--version must look like 0.24.0 (got '$VERSION')."
# Migrations are forward-only: refuse to move an
# existing install to an older version before anything is touched, rather
# than silently downgrading because a stale cached script (or its baked-in
# default) is older than what is already running.
INSTALLED_APP_IMAGE=$(read_env NEBULA_APP_IMAGE)
if [ -n "$INSTALLED_APP_IMAGE" ]; then
installed_tag=${INSTALLED_APP_IMAGE%%@*}
installed_version=${installed_tag##*:}
if [ "$ALLOW_DOWNGRADE" -ne 1 ] && version_lt "$VERSION" "$installed_version"; then
die "$DIR is already running v$installed_version; v$VERSION was requested, which is older, and migrations are forward-only — nothing was changed. Pass --allow-downgrade (or set NEBULA_ALLOW_DOWNGRADE=1) if you really mean to go back."
fi
fi
# Everything this script takes from the get site for v$VERSION is verified
# before anything is pulled, written or started (docs/adr/0061): release.json,
# which pins the control-plane image's digest, and compose.yaml. The first
# fetch of this script itself rests on TLS alone.
SIGNED=0
version_lt "$VERSION" "$FIRST_SIGNED_RELEASE" || SIGNED=1
EXPECTED_DIGEST=""
VERIFIED_COMPOSE=""
if [ "$SIGNED" -eq 1 ]; then
if [ -z "$IMAGE" ] || [ -z "$COMPOSE_FILE_SRC" ]; then
require_openssl
ok "openssl, to verify the release signatures"
fi
if [ -z "$IMAGE" ]; then
work_dir
release_url="$GET_URL/v$VERSION/release.json"
get_curl -fsSL --max-time 30 "$release_url" -o "$WORK_DIR/release.json" ||
die "could not download $release_url. Check v$VERSION exists (https://docs.nebulactrl.dev/installation/) and that this host can reach $GET_URL. Nothing was changed."
verify_download "$release_url" "$WORK_DIR/release.json"
# Signed by us, so the layout is ours: one "version" and one
# "controlPlane" string, whether pretty-printed or not.
release_version=$(grep -o '"version"[[:space:]]*:[[:space:]]*"[^"]*"' "$WORK_DIR/release.json" | head -n 1 | sed 's/.*"\([^"]*\)"$/\1/')
release_image=$(grep -o '"controlPlane"[[:space:]]*:[[:space:]]*"[^"]*"' "$WORK_DIR/release.json" | head -n 1 | sed 's/.*"\([^"]*\)"$/\1/')
# A signature binds bytes, not a version: a correctly signed
# release.json of another release must not stand in for this one.
[ "$release_version" = "$VERSION" ] ||
die "$release_url is the signed release.json of v${release_version:-unknown}, not v$VERSION, so it was not used and nothing was changed. Retry later; if it keeps failing report it to the NebulaCtrl maintainers as a security issue."
case "$release_image" in
"$DEFAULT_REPO:$VERSION@sha256:"*) EXPECTED_DIGEST=${release_image#*@} ;;
*) die "the signed $release_url does not pin $DEFAULT_REPO:$VERSION@sha256:... (it says '${release_image:-nothing}'), so the image cannot be checked and nothing was changed. Report it to the NebulaCtrl maintainers." ;;
esac
ok "release.json is signed; it pins $EXPECTED_DIGEST"
else
warn "--image is used as given: it is not checked against the signed release.json, so its digest is not verified"
fi
if [ -z "$COMPOSE_FILE_SRC" ]; then
work_dir
compose_url="$GET_URL/v$VERSION/compose.yaml"
VERIFIED_COMPOSE="$WORK_DIR/compose.yaml"
get_curl -fsSL --max-time 30 "$compose_url" -o "$VERIFIED_COMPOSE" ||
die "could not download $compose_url. Check v$VERSION exists (https://docs.nebulactrl.dev/installation/) and that this host can reach $GET_URL, or pass --compose-file for an air-gapped install. Nothing was changed."
verify_download "$compose_url" "$VERIFIED_COMPOSE"
ok "compose.yaml is signed"
fi
else
warn "v$VERSION was published before releases were signed, so none of its files can be verified; continuing because you asked for this version by hand"
fi
if command -v curl >/dev/null 2>&1; then
if curl -fsS --max-time 15 "$OIDC_ISSUER/.well-known/openid-configuration" >/dev/null 2>&1; then
ok "issuer $OIDC_ISSUER answers discovery"
else
warn "$OIDC_ISSUER/.well-known/openid-configuration did not answer; the control plane will refuse to start if it stays unreachable"
fi
fi
if [ -n "$DATABASE_URL" ]; then
say "using the external database you supplied; starting no Postgres here"
else
say "running a Postgres container; its data lives in a docker volume on this host"
fi
if [ "$INTERACTIVE" -eq 1 ]; then
printf '\nSummary\n'
print_box \
"$(printf '%-15s%s' 'Base URL' "$BASE_URL")" \
"$(printf '%-15s%s' 'OIDC issuer' "$OIDC_ISSUER")" \
"$(printf '%-15s%s' 'Client ID' "$OIDC_CLIENT_ID")" \
"$(printf '%-15s%s' 'Provider name' "$OIDC_PROVIDER_NAME")" \
"$(printf '%-15s%s' 'Database' "${DATABASE_URL:-bundled Postgres}")" \
"$(printf '%-15s%s' 'Listen' "$LISTEN")" \
"$(printf '%-15s%s' 'Directory' "$DIR")" \
"$(printf '%-15s%s' 'Version' "$VERSION")"
confirm "Apply?" || {
printf '\nAborted; nothing was changed.\n'
exit 0
}
fi
################################################################################
# [3/7] Pulling the image
################################################################################
step 3 "Pulling ${IMAGE:-$DEFAULT_REPO:$VERSION}"
[ -n "$IMAGE" ] || IMAGE="$DEFAULT_REPO:$VERSION"
if ! with_spinner "pulling $IMAGE" docker_cmd pull -q "$IMAGE"; then
die "could not pull $IMAGE. If v$VERSION was just released its images may still be publishing — retry in a few minutes, or check $GET_URL/version for the currently published release."
fi
repo_digest=$(docker_cmd image inspect --format '{{index .RepoDigests 0}}' "$IMAGE" 2>/dev/null) || repo_digest=""
[ -n "$repo_digest" ] ||
die "could not resolve a content digest for $IMAGE. Is it a locally built image with no registry digest? Push it to a registry first, or drop --image to use the published $DEFAULT_REPO image."
digest_repo=${repo_digest%@*}
digest_sha=${repo_digest#*@}
# Before the image is run for anything, even its version command.
if [ -n "$EXPECTED_DIGEST" ] && [ "$digest_sha" != "$EXPECTED_DIGEST" ]; then
die "$IMAGE resolved to $digest_sha, but the signed release.json for v$VERSION pins $EXPECTED_DIGEST. The image was pulled but never started, and nothing else was changed. The registry or its tag may have been altered, so do not use this image; report it to the NebulaCtrl maintainers as a security issue."
fi
reported=$(docker_cmd run --rm "$IMAGE" version 2>/dev/null | head -1) || reported=""
case "$reported" in
*"$VERSION"*) : ;;
*) die "$IMAGE reports version '$reported', not $VERSION; nothing was changed." ;;
esac
ok "pulled $IMAGE ($reported)"
APP_IMAGE="$digest_repo:$VERSION@$digest_sha"
################################################################################
# [4/7] Writing configuration
################################################################################
step 4 "Writing configuration"
MASTER_KEY=$(read_env NEBULA_MASTER_KEY)
if [ -z "$MASTER_KEY" ]; then
MASTER_KEY=$(head -c 32 /dev/urandom | base64 | tr -d '\n')
warn "generated a new master key — back up $ENV_FILE now, it cannot be recovered if lost"
else
ok "keeping the existing master key"
fi
DB_PASSWORD=$(read_env POSTGRES_PASSWORD)
if [ -z "$DB_PASSWORD" ]; then
# 48 bytes encode to 64 base64 characters; stripping the three that need
# escaping in a URL leaves far more than the 32 kept, which is the
# shortest secret this product generates.
DB_PASSWORD=$(head -c 48 /dev/urandom | base64 | tr -d '\n/+=' | cut -c1-32)
fi
# The token the control plane and the updater service share. Generated only
# when this install will have an updater: with no token the Updates page says
# to re-run the installer, which is the right advice for a host that could
# not take one. An existing token is always kept, even under --no-updater.
UPDATER_BLOCKER=$(updater_blocker)
UPDATER_TOKEN=$(read_env NEBULA_UPDATER_TOKEN)
if [ -z "$UPDATER_TOKEN" ] && [ -z "$UPDATER_BLOCKER" ]; then
UPDATER_TOKEN=$(head -c 32 /dev/urandom | od -An -tx1 | tr -d ' \n')
say "generated the console updates token"
fi
if [ -n "$DATABASE_URL" ]; then
EFFECTIVE_DATABASE_URL="$DATABASE_URL"
else
EFFECTIVE_DATABASE_URL="postgres://nebula:$DB_PASSWORD@postgres:5432/nebula?sslmode=disable"
fi
# Every managed key this writes, in the order they appear in .env. Anything
# in an existing .env whose key is not in this list is kept verbatim, below
# MANAGED_END — see the merge below.
write_env_file() {
cat </dev/null; then
awk -v end="$MANAGED_END" 'found{print} $0==end{found=1}' "$ENV_FILE"
else
# The first run of this installer against a pre-existing .env: it
# has no marker yet, so anything not one of our keys is preserved,
# comments included — a one-time duplicate of old boilerplate
# comments is a harmless price for never dropping a hand-added
# setting like NEBULA_TRUSTED_PROXIES.
managed_keys=" POSTGRES_PASSWORD NEBULA_DATABASE_URL NEBULA_EXTERNAL_DATABASE_URL NEBULA_MASTER_KEY NEBULA_BASE_URL NEBULA_HOST_LISTEN NEBULA_OIDC_ISSUER NEBULA_OIDC_CLIENT_ID NEBULA_OIDC_CLIENT_SECRET NEBULA_OIDC_PROVIDER_NAME NEBULA_OIDC_SCOPES NEBULA_OIDC_INSECURE_HTTP NEBULA_UPDATER_TOKEN NEBULA_APP_IMAGE "
awk -v keys="$managed_keys" '
{ eq=index($0,"="); key=(eq>0)?substr($0,1,eq-1):""
if (key=="" || index(keys," " key " ")==0) print }
' "$ENV_FILE"
fi
fi
}
new_env=$(write_env_file)
if [ -f "$ENV_FILE" ] && [ "$(cat "$ENV_FILE" 2>/dev/null)" = "$new_env" ]; then
ok "$ENV_FILE is already up to date"
else
if [ -f "$ENV_FILE" ]; then
backup="$ENV_FILE.bak-$(date -u +%Y%m%dT%H%M%SZ)"
cp -p "$ENV_FILE" "$backup"
warn "$ENV_FILE changed; the previous version is backed up at $backup"
fi
tmp=$(mktemp "$ENV_FILE.XXXXXX")
printf '%s\n' "$new_env" >"$tmp"
chmod 600 "$tmp"
mv -f "$tmp" "$ENV_FILE"
ok "wrote $ENV_FILE"
fi
if [ -n "$COMPOSE_FILE_SRC" ]; then
[ -f "$COMPOSE_FILE_SRC" ] || die "--compose-file $COMPOSE_FILE_SRC does not exist."
mkdir -p "$(dirname "$COMPOSE_FILE")"
tmp=$(mktemp "$COMPOSE_FILE.XXXXXX")
cp "$COMPOSE_FILE_SRC" "$tmp"
mv -f "$tmp" "$COMPOSE_FILE"
ok "copied $COMPOSE_FILE_SRC to $COMPOSE_FILE"
else
mkdir -p "$(dirname "$COMPOSE_FILE")"
tmp=$(mktemp "$COMPOSE_FILE.XXXXXX")
if [ -n "$VERIFIED_COMPOSE" ]; then
cp "$VERIFIED_COMPOSE" "$tmp"
elif ! get_curl -fsSL --max-time 30 "$GET_URL/v$VERSION/compose.yaml" -o "$tmp"; then
rm -f "$tmp"
die "could not download $GET_URL/v$VERSION/compose.yaml. Check v$VERSION exists (https://docs.nebulactrl.dev/installation/) and that this host can reach $GET_URL, or pass --compose-file for an air-gapped install."
fi
if [ -f "$COMPOSE_FILE" ] && cmp -s "$tmp" "$COMPOSE_FILE"; then
rm -f "$tmp"
ok "$COMPOSE_FILE is already up to date"
else
mv -f "$tmp" "$COMPOSE_FILE"
ok "downloaded $COMPOSE_FILE"
fi
fi
################################################################################
# [5/7] Starting containers
################################################################################
step 5 "Starting containers"
if ! compose_cmd up -d --no-build --remove-orphans --wait 2>/dev/null; then
compose_cmd up -d --no-build --remove-orphans
fi
ok "containers started"
################################################################################
# [6/7] Waiting for health
################################################################################
step 6 "Waiting for the control plane to become healthy"
probe_host=${LISTEN%:*}
[ "$probe_host" = "0.0.0.0" ] && probe_host="127.0.0.1"
probe="http://$probe_host:${LISTEN##*:}/healthz"
healthy=0
elapsed=0
SPIN_STATE="$SPIN_FRAMES"
while [ "$elapsed" -lt "$HEALTH_TIMEOUT" ]; do
if curl -fsS --max-time 3 "$probe" >/dev/null 2>&1; then
healthy=1
break
fi
if [ "$TTY" -eq 1 ]; then
spin_tick "waiting for $probe (${elapsed}s)"
elif [ $((elapsed % 20)) -eq 0 ]; then
printf ' still waiting for %s (%ss elapsed)...\n' "$probe" "$elapsed"
fi
sleep 2
elapsed=$((elapsed + 2))
done
[ "$TTY" -eq 1 ] && clear_line
if [ "$healthy" -ne 1 ]; then
printf '%s did not become healthy within %ss; its last log lines:\n' "$probe" "$HEALTH_TIMEOUT" >&2
compose_cmd logs --tail 40 nebula >&2
die "install did not finish. Fix whatever the log above shows and re-run — .env and the compose file are already in place, so nothing needs to be redone."
fi
ok "healthy"
################################################################################
# [7/7] Setting up console updates
################################################################################
step 7 "Setting up console updates"
if [ -n "$UPDATER_BLOCKER" ]; then
warn "console updates are off: $UPDATER_BLOCKER; update with the installer command instead"
elif ! install_updater_binary; then
warn "console updates are off: could not copy a working nebula binary out of $IMAGE into $DIR/bin; update with the installer command instead"
elif ! install_updater_unit; then
warn "console updates are off: could not install and start $UNIT_NAME (see the messages above); update with the installer command instead"
else
UPDATER_OK=1
fi
################################################################################
# Ready
################################################################################
redirect="$BASE_URL/api/v1/auth/callback"
print_box \
"$(printf '%-14s%s' 'Open' "$BASE_URL")" \
"$(printf '%-14s%s' 'Sign in with' "$OIDC_PROVIDER_NAME")" \
"" \
"Redirect URI to register with your OIDC provider:" \
" $redirect"
COMPOSE_PROFILE=""
[ -n "$DATABASE_URL" ] || COMPOSE_PROFILE=" --profile local-db"
# Left unboxed and untruncated: with a real path and env-file the docker
# compose commands run long, and boxing them — plus a wide ⚠ glyph whose
# display width print_box's byte-count padding gets wrong — is what blew
# the box out past a readable width.
printf '\n%-9s%s\n' 'Logs' "$DOCKER_DISPLAY compose -p $PROJECT -f $COMPOSE_FILE --env-file $ENV_FILE$COMPOSE_PROFILE logs -f nebula"
printf '%-9s%s\n' 'Stop' "$DOCKER_DISPLAY compose -p $PROJECT -f $COMPOSE_FILE --env-file $ENV_FILE$COMPOSE_PROFILE down"
printf '%-9s%s\n' 'Upgrade' "curl -fsSL $GET_URL | sh -s -- --dir $DIR"
if [ "$UPDATER_OK" -eq 1 ]; then
printf '%-9s%s\n' 'Updater' "systemctl status $UNIT_NAME"
fi
printf '\n%s Back up %s now — it holds the master key and cannot be regenerated.\n' "$WARN_MARK" "$ENV_FILE"
printf '\nThe first person to sign in becomes the owner of a new organization; everyone after that needs an invitation from them.\n'