change user input
This commit is contained in:
parent
ebb472dae7
commit
0e60f84c22
@ -46,7 +46,7 @@ do
|
||||
echo "$list_backups"
|
||||
echo
|
||||
echo "0) Exit"
|
||||
read -rt 120 -p "Please type a number: " selection
|
||||
read -rt 240 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; }
|
||||
restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}')
|
||||
if [[ $selection == 0 ]]; then
|
||||
echo "Exiting.."
|
||||
@ -67,16 +67,16 @@ do
|
||||
clear -x
|
||||
echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point"
|
||||
echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?"
|
||||
echo -e "1) Yes\n2) Exit\n"
|
||||
read -rt 120 -p "Please type a number: " yesno
|
||||
echo -e "Y) Yes\nN) No\n"
|
||||
read -rt 120 -p "Please type a number: " yesno || { echo -e "\nFailed to make a selection in time" ; exit; }
|
||||
case $yesno in
|
||||
1)
|
||||
[Yy])
|
||||
echo -e "\nDeleting $restore_point"
|
||||
cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null || { echo "Failed to delete backup.."; exit; }
|
||||
echo "Sucessfully deleted"
|
||||
break
|
||||
;;
|
||||
2)
|
||||
[Nn])
|
||||
echo "Exiting"
|
||||
exit
|
||||
;;
|
||||
@ -90,14 +90,14 @@ do
|
||||
while true
|
||||
do
|
||||
echo "Delete more?"
|
||||
echo "1) Yes"
|
||||
echo "2) No"
|
||||
read -rt 120 -p "Please type a number: " yesno
|
||||
echo "Y) Yes"
|
||||
echo "N) No"
|
||||
read -rt 120 -p "Please type a number: " yesno || { echo -e "\nFailed to make a selection in time" ; exit; }
|
||||
case $yesno in
|
||||
1)
|
||||
[Yy])
|
||||
break
|
||||
;;
|
||||
2)
|
||||
[Nn])
|
||||
exit
|
||||
;;
|
||||
*)
|
||||
@ -131,7 +131,7 @@ do
|
||||
echo "$list_backups"
|
||||
echo
|
||||
echo "0) Exit"
|
||||
read -rt 120 -p "Please type a number: " selection
|
||||
read -rt 240 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; }
|
||||
restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}')
|
||||
if [[ $selection == 0 ]]; then
|
||||
echo "Exiting.."
|
||||
@ -152,15 +152,15 @@ do
|
||||
clear -x
|
||||
echo -e "\nWARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible"
|
||||
echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?"
|
||||
echo -e "1) Yes\n2) Exit\n"
|
||||
read -rt 120 -p "Please type a number: " yesno
|
||||
echo -e "Y) Yes\nN) No\n"
|
||||
read -rt 120 -p "Please type a number: " yesno || { echo -e "\nFailed to make a selection in time" ; exit; }
|
||||
case $yesno in
|
||||
1)
|
||||
[Yy])
|
||||
echo -e "\nStarting Backup, this will take a LONG time."
|
||||
cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || { echo "Failed to delete backup.."; exit; }
|
||||
exit
|
||||
;;
|
||||
2)
|
||||
[Nn])
|
||||
echo "Exiting"
|
||||
exit
|
||||
;;
|
||||
|
@ -29,7 +29,7 @@ case $selection in
|
||||
mount="true"
|
||||
;;
|
||||
4)
|
||||
read -rt 120 -p "What is the maximun number of backups you would like?: " number_of_backups
|
||||
read -rt 120 -p "What is the maximun number of backups you would like?: " number_of_backups || echo "Failed to make a selection"
|
||||
backup="true"
|
||||
;;
|
||||
5)
|
||||
@ -53,56 +53,61 @@ case $selection in
|
||||
echo
|
||||
echo "0) Exit"
|
||||
echo
|
||||
read -rt 120 -p "Please type the number associated with the flag above: " current_selection
|
||||
if [[ $current_selection == 1 ]]; then
|
||||
while true
|
||||
do
|
||||
echo -e "\nHow many applications do you want updating at the same time?"
|
||||
read -rt 120 -p "Please type an integer greater than 0: " up_async
|
||||
if [[ $up_async == 0 ]]; then
|
||||
echo "Error: \"$up_async\" is less than 1"
|
||||
echo "NOT adding it to the list"
|
||||
sleep 3
|
||||
continue
|
||||
elif ! [[ $up_async =~ ^[0-9]+$ ]]; then
|
||||
echo "Error: \"$up_async\" is invalid, it needs to be an integer"
|
||||
echo "NOT adding it to the list"
|
||||
sleep 3
|
||||
continue
|
||||
else
|
||||
update_selection+=("-U" "$up_async")
|
||||
break
|
||||
fi
|
||||
done
|
||||
break
|
||||
elif [[ $current_selection == 2 ]]; then
|
||||
while true
|
||||
do
|
||||
echo -e "\nHow many applications do you want updating at the same time?"
|
||||
read -rt 120 -p "Please type an integer greater than 0: " up_async
|
||||
if [[ $up_async == 0 ]]; then
|
||||
echo "Error: \"$up_async\" is less than 1"
|
||||
echo "NOT adding it to the list"
|
||||
sleep 3
|
||||
continue
|
||||
elif ! [[ $up_async =~ ^[0-9]+$ ]]; then
|
||||
echo "Error: \"$up_async\" is invalid, it needs to be an integer"
|
||||
echo "NOT adding it to the list"
|
||||
sleep 3
|
||||
continue
|
||||
else
|
||||
update_selection+=("-u" "$up_async")
|
||||
break
|
||||
fi
|
||||
done
|
||||
break
|
||||
elif [[ $current_selection == 0 ]]; then
|
||||
echo "Exiting.."
|
||||
exit
|
||||
else
|
||||
echo "$current_selection was not an option, try again" && sleep 3
|
||||
continue
|
||||
fi
|
||||
read -rt 120 -p "Type the Number or Flag: " current_selection || { echo -e "\nFailed to make a selection in time" ; exit; }
|
||||
case $current_selection in
|
||||
0 | [Ee][Xx][Ii][Tt])
|
||||
echo "Exiting.."
|
||||
exit
|
||||
;;
|
||||
1 | -U)
|
||||
while true
|
||||
do
|
||||
echo -e "\nHow many applications do you want updating at the same time?"
|
||||
read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; }
|
||||
if [[ $up_async == 0 ]]; then
|
||||
echo "Error: \"$up_async\" is less than 1"
|
||||
echo "NOT adding it to the list"
|
||||
sleep 3
|
||||
continue
|
||||
elif ! [[ $up_async =~ ^[0-9]+$ ]]; then
|
||||
echo "Error: \"$up_async\" is invalid, it needs to be an integer"
|
||||
echo "NOT adding it to the list"
|
||||
sleep 3
|
||||
continue
|
||||
else
|
||||
update_selection+=("-U" "$up_async")
|
||||
break
|
||||
fi
|
||||
done
|
||||
break
|
||||
;;
|
||||
2 | -u)
|
||||
while true
|
||||
do
|
||||
echo -e "\nHow many applications do you want updating at the same time?"
|
||||
read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; }
|
||||
if [[ $up_async == 0 ]]; then
|
||||
echo "Error: \"$up_async\" is less than 1"
|
||||
echo "NOT adding it to the list"
|
||||
sleep 3
|
||||
continue
|
||||
elif ! [[ $up_async =~ ^[0-9]+$ ]]; then
|
||||
echo "Error: \"$up_async\" is invalid, it needs to be an integer"
|
||||
echo "NOT adding it to the list"
|
||||
sleep 3
|
||||
continue
|
||||
else
|
||||
update_selection+=("-u" "$up_async")
|
||||
break
|
||||
fi
|
||||
done
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "$current_selection was not an option, try again" && sleep 3
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
done
|
||||
while true
|
||||
do
|
||||
@ -129,9 +134,9 @@ case $selection in
|
||||
echo "---------------"
|
||||
echo "bash heavy_script.sh ${update_selection[*]}"
|
||||
echo
|
||||
read -rt 120 -p "Type the Number OR Flag: " current_selection
|
||||
read -rt 600 -p "Type the Number or Flag: " current_selection || { echo -e "\nFailed to make a selection in time" ; exit; }
|
||||
case $current_selection in
|
||||
0)
|
||||
0 | [Ee][Xx][Ii][Tt])
|
||||
echo "Exiting.."
|
||||
exit
|
||||
;;
|
||||
@ -145,13 +150,13 @@ case $selection in
|
||||
1 | -b)
|
||||
printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "\"-b\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it
|
||||
echo "Up to how many backups should we keep?"
|
||||
read -rt 120 -p "Please type an integer: " up_backups
|
||||
read -rt 120 -p "Please type an integer: " up_backups || { echo -e "\nFailed to make a selection in time" ; exit; }
|
||||
! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue
|
||||
[[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 3 && continue
|
||||
update_selection+=("-b" "$up_backups")
|
||||
;;
|
||||
2 | -i)
|
||||
read -rt 120 -p "What is the name of the application we should ignore?: " up_ignore
|
||||
read -rt 120 -p "What is the name of the application we should ignore?: " up_ignore || { echo -e "\nFailed to make a selection in time" ; exit; }
|
||||
! [[ $up_ignore =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is not a possible option for an application name" && sleep 3 && continue
|
||||
update_selection+=("-i" "$up_ignore")
|
||||
;;
|
||||
@ -171,7 +176,7 @@ case $selection in
|
||||
6 | -t)
|
||||
printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-t" && echo -e "\"-t\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it
|
||||
echo "What do you want your timeout to be?"
|
||||
read -rt 120 -p "Please type an integer: " up_timeout
|
||||
read -rt 120 -p "Please type an integer: " up_timeout || { echo -e "\nFailed to make a selection in time" ; exit; }
|
||||
! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue
|
||||
update_selection+=("-t" "$up_timeout")
|
||||
;;
|
||||
|
@ -9,7 +9,7 @@ do
|
||||
echo "2) Unmount All"
|
||||
echo
|
||||
echo "0) Exit"
|
||||
read -rt 120 -p "Unmount All Please type a number: " selection
|
||||
read -rt 120 -p "Unmount All Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; }
|
||||
case $selection in
|
||||
0)
|
||||
echo "Exiting.."
|
||||
@ -27,7 +27,7 @@ do
|
||||
echo "$list"
|
||||
echo
|
||||
echo "0) Exit"
|
||||
read -rt 120 -p "Please type a number: " selection
|
||||
read -rt 120 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; }
|
||||
[[ $selection == 0 ]] && echo "Exiting.." && exit
|
||||
app=$(echo -e "$list" | grep ^"$selection)" | awk '{print $2}' | cut -c 4- )
|
||||
[[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 3 && continue #Check for valid selection. If none, contiue
|
||||
@ -59,16 +59,16 @@ do
|
||||
while true
|
||||
do
|
||||
echo -e "\nWould you like to mount anything else?"
|
||||
echo "1) Yes"
|
||||
echo "2) No"
|
||||
read -rt 120 -p "Please type a number: " yesno
|
||||
echo "Y) Yes"
|
||||
echo "N) No"
|
||||
read -rt 120 -p "Please type a number: " yesno || { echo -e "\nFailed to make a selection in time" ; exit; }
|
||||
case $yesno in
|
||||
1)
|
||||
[Yy])
|
||||
clear -x
|
||||
title
|
||||
break
|
||||
;;
|
||||
2)
|
||||
[Nn])
|
||||
exit
|
||||
;;
|
||||
*)
|
||||
|
Loading…
Reference in New Issue
Block a user