added extra arguments to auto install everything

This commit is contained in:
Ryan Bakkes 2021-09-25 02:17:52 +02:00
parent 5831098a67
commit fbb683b4e3
2 changed files with 69 additions and 28 deletions

View File

@ -16,26 +16,33 @@ create_app_folder() {
} }
zsh_prompt() { zsh_prompt() {
# selection menu for zsh
printf %s "$YELLOW"
deleteOption="" if [[ $usezsh == "" ]]; then
echo "Do you want Oh-My-ZSH as terminal extension?" # selection menu for zsh
echo "To use 'Oh-My-ZSH' enter 'y' to to continue in bash enter 'n'" printf %s "$YELLOW"
read deleteOption
# check for valid input zshOption=""
while [ ${deleteOption,,} != "y" ] && [ ${deleteOption,,} != "n" ]; do echo "Do you want Oh-My-ZSH as terminal extension?"
echo "Invalid input. Please press 'y' or 'n'" echo "To use 'Oh-My-ZSH' enter 'y' to to continue in bash enter 'n'"
read deleteOption read zshOption
done
printf %s "$RESET" # check for valid input
while [ ${zshOption,,} != "y" ] && [ ${zshOption,,} != "n" ]; do
echo "Invalid input. Please press 'y' or 'n'"
read zshOption
done
printf %s "$RESET"
elif [[ $usezsh == "bash" ]]; then
zshOption="n"
elif [[ $usezsh == "zsh" ]]; then
zshOption="y"
fi
# run option # run option
if [[ ${deleteOption,,} = "n" ]]; then if [[ ${zshOption,,} = "n" ]]; then
return return
elif [[ ${deleteOption,,} = "y" ]]; then elif [[ ${zshOption,,} = "y" ]]; then
echo "nice choice lets use zsh" echo "nice choice lets use zsh"
fi fi
} }
@ -61,9 +68,17 @@ get_files() {
} }
select_files() { select_files() {
cd ../temp
if $downloadall; then
# remove all numbers from items
sed -i 's/[^ ]* //' installations.txt
clear
return
fi
printf %s "$YELLOW" printf %s "$YELLOW"
# Show all the options # Show all the options
cd ../temp
echo "The following items will be installed." echo "The following items will be installed."
cat installations.txt cat installations.txt
@ -176,23 +191,44 @@ install_files() {
} }
check_arguments() { check_arguments() {
if [[ $1 = "-h" || $1 = "-help" ]]; then case $1 in
print_logo -h|--help) # display help
print_help print_logo
exit 1 print_help
elif [[ $1 = "-v" || $1 = "-version" ]]; then exit 1
print_version ;;
exit 1 -v|--version) # display help
fi print_version
exit 1
;;
esac
} }
check_sudo_arguments() { check_sudo_arguments() {
check_arguments $@ check_arguments $@
if [[ $1 = "-d" || $1 = "-debug" ]]; then while getopts ":abdz" option; do
debug=true case $option in
main d) # enable debug
fi 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() { main() {
@ -254,6 +290,8 @@ fi
# Safe important variables # Safe important variables
homedir="$(getent passwd $SUDO_USER | cut -d: -f6)" homedir="$(getent passwd $SUDO_USER | cut -d: -f6)"
debug=false debug=false
downloadall=false
usezsh=""
# run the program # run the program
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then

View File

@ -51,7 +51,10 @@ Usage: Sudo ./install.sh [command oprions]
Command options: Command options:
-h, -help Show a list of all commands -h, -help Show a list of all commands
-v, -version Show the current version of the application -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 EOF
# set color to default # set color to default
printf %s "$RESET" printf %s "$RESET"