#!/usr/bin/env bash
set -euo pipefail

# shellcheck disable=SC1091
source /usr/lib/biglinux-livecd/live-state

# Best-effort: the installer has to start even when the live state cannot be
# written. Under set -e a sudo without a matching sudoers rule aborted the
# script before the exec below.
initialize_default_live_state || true
install_live_state_defaults || true

if [[ -x /usr/bin/konsole ]]; then
	/usr/bin/konsole -e /usr/bin/nmtui-connect
elif [[ -x /usr/bin/urxvt ]]; then
	/usr/bin/urxvt -e /usr/bin/nmtui-connect
fi

exec /usr/bin/calamares-biglinux_polkit
