From c8a9e2100ac8f16104d19e4afa82efbee9511ca5 Mon Sep 17 00:00:00 2001 From: Orazio Date: Thu, 28 May 2020 15:16:45 +0200 Subject: [PATCH] Changed how undocumented flags are managed - Renamed '--i_do_not_follow_recommendations' to '--skip-space-check', since the argument actually skips the space check. - Obtain the unattended configuration dynamically, by looking at the argument next to '--unattended', instead of looking at the second argument, which was a too fragile parsing. - Because of the previous one, figuring out when no argument has been passed to '--unattended' doesn't seem trivial, because the next argument could be an undocumented flag as well, which would be intepreted as a filename. --- auto_install/install.sh | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/auto_install/install.sh b/auto_install/install.sh index 8658120..dae00c4 100755 --- a/auto_install/install.sh +++ b/auto_install/install.sh @@ -102,25 +102,27 @@ main(){ fi # Check arguments for the undocumented flags - for var in "$@"; do - case "$var" in - "--i_do_not_follow_recommendations" ) skipSpaceCheck=false;; - "--unattended" ) runUnattended=true;; - "--reconfigure" ) reconfigure=true;; + for ((i=1; i <= "$#"; i++)); do + j="$((i+1))" + case "${!i}" in + "--skip-space-check" ) skipSpaceCheck=true;; + "--unattended" ) runUnattended=true; unattendedConfig="${!j}";; + "--reconfigure" ) reconfigure=true;; "--show-unsupported-nics" ) showUnsupportedNICs=true;; esac done if [[ "${runUnattended}" == true ]]; then echo "::: --unattended passed to install script, no whiptail dialogs will be displayed" - if [ -z "$2" ]; then - echo "::: No configuration file passed, using default settings..." + if [ -z "$unattendedConfig" ]; then + echo "::: No configuration file passed" + exit 1 else - if [ -r "$2" ]; then - # shellcheck disable=SC1090 - source "$2" + if [ -r "$unattendedConfig" ]; then + # shellcheck disable=SC1090 + source "$unattendedConfig" else - echo "::: Can't open $2" + echo "::: Can't open $unattendedConfig" exit 1 fi fi @@ -165,7 +167,7 @@ main(){ # Start the installer # Verify there is enough disk space for the install if [[ "${skipSpaceCheck}" == true ]]; then - echo "::: --i_do_not_follow_recommendations passed to script, skipping free disk space verification!" + echo "::: --skip-space-check passed to script, skipping free disk space verification!" else verifyFreeDiskSpace fi