diff --git a/scripts/install-darwin-multi-user.sh b/scripts/install-darwin-multi-user.sh index 01a0e4ff..a2e120bf 100644 --- a/scripts/install-darwin-multi-user.sh +++ b/scripts/install-darwin-multi-user.sh @@ -43,6 +43,20 @@ readonly EXTRACTED_NIX_PATH="$(dirname "$0")" readonly ROOT_HOME="/var/root" +if [ -t 0 ]; then + readonly IS_HEADLESS='no' +else + readonly IS_HEADLESS='yes' +fi + +headless() { + if [ "$IS_HEADLESS" = "yes" ]; then + return 0 + else + return 1 + fi +} + contactme() { echo "We'd love to help if you need it." echo "" @@ -173,6 +187,11 @@ failure() { ui_confirm() { _textout "$GREEN$GREEN_UL" "$1" + if headless; then + echo "No TTY, assuming you would say yes :)" + return 0 + fi + local prompt="[y/n] " echo -n "$prompt" while read -r y; do @@ -210,9 +229,10 @@ __sudo() { _sudo() { local expl="$1" shift - if __sudo "$expl" "$*"; then - sudo "$@" + if ! headless; then + __sudo "$expl" "$*" fi + sudo "$@" } @@ -397,6 +417,9 @@ setup_report() { row " Build Users" "$NIX_USER_COUNT" row " Build Group ID" "$NIX_BUILD_GROUP_ID" row "Build Group Name" "$NIX_BUILD_GROUP_NAME" + if [ "${ALLOW_PREEXISTING_INSTALLATION:-}" != "" ]; then + row "Preexisting Install" "Allowed" + fi subheader "build users:" @@ -606,6 +629,27 @@ EOF chat_about_sudo() { header "let's talk about sudo" + if headless; then + cat <