From b01eaa6114545410dd5968894336f3cd3f250409 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Thu, 13 Jul 2017 17:22:54 -0400 Subject: [PATCH 1/5] Assume yes if we have no TTY Starve the TTY of input to ensure this works, but provide yes to the current installer to handle the current broken case. --- scripts/install-darwin-multi-user.sh | 11 +++++++++++ tests/install-darwin.sh | 5 +++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/install-darwin-multi-user.sh b/scripts/install-darwin-multi-user.sh index 01a0e4ff..368d9957 100644 --- a/scripts/install-darwin-multi-user.sh +++ b/scripts/install-darwin-multi-user.sh @@ -43,6 +43,12 @@ 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 + contactme() { echo "We'd love to help if you need it." echo "" @@ -173,6 +179,11 @@ failure() { ui_confirm() { _textout "$GREEN$GREEN_UL" "$1" + if [ "$IS_HEADLESS" = "yes" ]; then + echo "No TTY, assuming you would say yes :)" + return 0 + fi + local prompt="[y/n] " echo -n "$prompt" while read -r y; do diff --git a/tests/install-darwin.sh b/tests/install-darwin.sh index d2a7ab45..b7f87467 100755 --- a/tests/install-darwin.sh +++ b/tests/install-darwin.sh @@ -53,7 +53,8 @@ trap finish EXIT # First setup Nix cleanup -curl https://nixos.org/nix/install | bash +curl -o install https://nixos.org/nix/install +yes | bash ./install verify @@ -82,7 +83,7 @@ verify cleanup - yes | ./install + echo -n "" | ./install verify cleanup From 6b6d4b69c1c84631e1af47c624951c13fee1a696 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Thu, 13 Jul 2017 18:01:22 -0400 Subject: [PATCH 2/5] Ensure PINCH_ME_IM_SILLY allows a /nix/store to stick around between builds Also output in the status report that the user is very silly --- scripts/install-darwin-multi-user.sh | 8 +++----- tests/install-darwin.sh | 7 ++++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/install-darwin-multi-user.sh b/scripts/install-darwin-multi-user.sh index 368d9957..b1d258e0 100644 --- a/scripts/install-darwin-multi-user.sh +++ b/scripts/install-darwin-multi-user.sh @@ -408,6 +408,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 [ "${PINCH_ME_IM_SILLY:-}" != "" ]; then + row " Silliness" "Very Silly" + fi subheader "build users:" @@ -757,11 +760,6 @@ main() { exit 1 fi - if [ "${PINCH_ME_IM_SILLY:-}" != "" ]; then - exit 1 - fi - - create_build_group create_build_users create_directories diff --git a/tests/install-darwin.sh b/tests/install-darwin.sh index b7f87467..3f64944e 100755 --- a/tests/install-darwin.sh +++ b/tests/install-darwin.sh @@ -80,11 +80,16 @@ verify yes | ./install verify - cleanup echo -n "" | ./install verify + cleanup + sudo mkdir -p /nix/store + sudo touch /nix/store/.silly-hint + echo -n "" | PINCH_ME_IM_SILLY=true ./install + verify + test -e /nix/store/.silly-hint cleanup ) From 6ba624f25ab1fbb434e937087c7322546709520b Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Thu, 13 Jul 2017 19:03:35 -0400 Subject: [PATCH 3/5] If there is no TTY, also skip verbose sudo messages --- scripts/install-darwin-multi-user.sh | 36 +++++++++++++++++++++++++--- tests/install-darwin.sh | 1 + 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/scripts/install-darwin-multi-user.sh b/scripts/install-darwin-multi-user.sh index b1d258e0..cde40a7f 100644 --- a/scripts/install-darwin-multi-user.sh +++ b/scripts/install-darwin-multi-user.sh @@ -49,6 +49,14 @@ 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 "" @@ -179,7 +187,7 @@ failure() { ui_confirm() { _textout "$GREEN$GREEN_UL" "$1" - if [ "$IS_HEADLESS" = "yes" ]; then + if headless; then echo "No TTY, assuming you would say yes :)" return 0 fi @@ -221,9 +229,10 @@ __sudo() { _sudo() { local expl="$1" shift - if __sudo "$expl" "$*"; then - sudo "$@" + if ! headless; then + __sudo "$expl" "$*" fi + sudo "$@" } @@ -620,6 +629,27 @@ EOF chat_about_sudo() { header "let's talk about sudo" + if headless; then + cat < Date: Fri, 14 Jul 2017 06:28:24 -0400 Subject: [PATCH 4/5] Rename PINCH_ME_IM_SILLY to ALLOW_PREEXISTING_INSTALLATION --- scripts/install-darwin-multi-user.sh | 6 +++--- tests/install-darwin.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/install-darwin-multi-user.sh b/scripts/install-darwin-multi-user.sh index cde40a7f..a2e120bf 100644 --- a/scripts/install-darwin-multi-user.sh +++ b/scripts/install-darwin-multi-user.sh @@ -417,8 +417,8 @@ 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 [ "${PINCH_ME_IM_SILLY:-}" != "" ]; then - row " Silliness" "Very Silly" + if [ "${ALLOW_PREEXISTING_INSTALLATION:-}" != "" ]; then + row "Preexisting Install" "Allowed" fi subheader "build users:" @@ -777,7 +777,7 @@ main() { welcome_to_nix chat_about_sudo - if [ "${PINCH_ME_IM_SILLY:-}" = "" ]; then + if [ "${ALLOW_PREEXISTING_INSTALLATION:-}" = "" ]; then validate_starting_assumptions fi diff --git a/tests/install-darwin.sh b/tests/install-darwin.sh index eb251fa3..c99ce84a 100755 --- a/tests/install-darwin.sh +++ b/tests/install-darwin.sh @@ -88,7 +88,7 @@ verify sudo mkdir -p /nix/store sudo touch /nix/store/.silly-hint - echo -n "" | PINCH_ME_IM_SILLY=true ./install + echo -n "" | ALLOW_PREEXISTING_INSTALLATION=true ./install verify test -e /nix/store/.silly-hint From 41f0a08a31a5b66a8cc3ae6d887eead8760214d3 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 14 Jul 2017 06:28:47 -0400 Subject: [PATCH 5/5] bump version to 1.11.13 --- version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version b/version index 15d68a2c..5f207e32 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.11.12 \ No newline at end of file +1.11.13 \ No newline at end of file