From fbb683b4e38724ee299f082d4011bf062e656179 Mon Sep 17 00:00:00 2001 From: spekulaas Date: Sat, 25 Sep 2021 02:17:52 +0200 Subject: [PATCH] added extra arguments to auto install everything --- install.sh | 92 +++++++++++++++++++++++++++++++------------- src/services/help.sh | 5 ++- 2 files changed, 69 insertions(+), 28 deletions(-) diff --git a/install.sh b/install.sh index 055868c..f7e1b61 100755 --- a/install.sh +++ b/install.sh @@ -16,26 +16,33 @@ create_app_folder() { } zsh_prompt() { - # selection menu for zsh - printf %s "$YELLOW" + + if [[ $usezsh == "" ]]; then + # selection menu for zsh + printf %s "$YELLOW" - deleteOption="" - echo "Do you want Oh-My-ZSH as terminal extension?" - echo "To use 'Oh-My-ZSH' enter 'y' to to continue in bash enter 'n'" - read deleteOption + zshOption="" + echo "Do you want Oh-My-ZSH as terminal extension?" + echo "To use 'Oh-My-ZSH' enter 'y' to to continue in bash enter 'n'" + read zshOption - # check for valid input - while [ ${deleteOption,,} != "y" ] && [ ${deleteOption,,} != "n" ]; do - echo "Invalid input. Please press 'y' or 'n'" - read deleteOption - done + # check for valid input + while [ ${zshOption,,} != "y" ] && [ ${zshOption,,} != "n" ]; do + echo "Invalid input. Please press 'y' or 'n'" + read zshOption + done - printf %s "$RESET" + printf %s "$RESET" + elif [[ $usezsh == "bash" ]]; then + zshOption="n" + elif [[ $usezsh == "zsh" ]]; then + zshOption="y" + fi # run option - if [[ ${deleteOption,,} = "n" ]]; then + if [[ ${zshOption,,} = "n" ]]; then return - elif [[ ${deleteOption,,} = "y" ]]; then + elif [[ ${zshOption,,} = "y" ]]; then echo "nice choice lets use zsh" fi } @@ -61,9 +68,17 @@ get_files() { } select_files() { + cd ../temp + + if $downloadall; then + # remove all numbers from items + sed -i 's/[^ ]* //' installations.txt + clear + return + fi + printf %s "$YELLOW" # Show all the options - cd ../temp echo "The following items will be installed." cat installations.txt @@ -176,23 +191,44 @@ install_files() { } check_arguments() { - if [[ $1 = "-h" || $1 = "-help" ]]; then - print_logo - print_help - exit 1 - elif [[ $1 = "-v" || $1 = "-version" ]]; then - print_version - exit 1 - fi + case $1 in + -h|--help) # display help + print_logo + print_help + exit 1 + ;; + -v|--version) # display help + print_version + exit 1 + ;; + esac } check_sudo_arguments() { check_arguments $@ - if [[ $1 = "-d" || $1 = "-debug" ]]; then - debug=true - main - fi + while getopts ":abdz" option; do + case $option in + d) # enable debug + debug=true + ;; + a) # enable all + downloadall=true + ;; + z) # enable zsh + usezsh="zsh" + ;; + b) # enable bash + usezsh="bash" + ;; + *) # incorrect option + echo "Wrong argument given, please use '-h' to see what arguments are available." + exit 1 + ;; + esac + done + + main } main() { @@ -254,6 +290,8 @@ fi # Safe important variables homedir="$(getent passwd $SUDO_USER | cut -d: -f6)" debug=false +downloadall=false +usezsh="" # run the program if [ $# -eq 0 ]; then diff --git a/src/services/help.sh b/src/services/help.sh index 2f57fc3..b23b635 100755 --- a/src/services/help.sh +++ b/src/services/help.sh @@ -51,7 +51,10 @@ Usage: Sudo ./install.sh [command oprions] Command options: -h, -help Show a list of all commands -v, -version Show the current version of the application - -d, -debug Display all the download information + -d Run the install in debug mode + -a Download all the files without a command prompt + -b Use bash as main terminal + -z Use Oh-My-Zsh as main terminal EOF # set color to default printf %s "$RESET"