From a1ca8fb9bd827f0a277a2692b4d3c8a09666f8a7 Mon Sep 17 00:00:00 2001 From: Sylvain Lefebvre Date: Mon, 26 Aug 2024 19:44:07 +0200 Subject: [PATCH] non interactive mode for getting started Linux script --- get_started_linux.sh | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/get_started_linux.sh b/get_started_linux.sh index e702cb76..0b5a8d0b 100755 --- a/get_started_linux.sh +++ b/get_started_linux.sh @@ -6,14 +6,23 @@ echo "--------------------------------------------------------------------" echo " >>>> it will request sudo access to install packages <<<<" echo "--------------------------------------------------------------------" -read -p "Please type 'y' to go ahead, any other key to exit: " -n 1 -r -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - echo - echo "Exiting." - exit +non_interactive=false +if [[ "$1" == "--non-interactive" ]]; then + non_interactive=true +fi + +if [ "$non_interactive" = true ]; then + echo "non-interactive mode" +else + read -p "Please type 'y' to go ahead, any other key to exit: " -n 1 -r + if [[ ! $REPLY =~ ^[Yy]$ ]] + then + echo + echo "Exiting." + exit + fi + echo "" fi -echo "" # -------------- install packages ---------------------------- # attempt to guess