menu
This commit is contained in:
		
							
								
								
									
										56
									
								
								functions/menu.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								functions/menu.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,56 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
menu(){
 | 
			
		||||
  echo "0  Help"
 | 
			
		||||
  echo "1  List DNS Names"
 | 
			
		||||
  echo "2  Mount and Unmount PVC storage"
 | 
			
		||||
  echo "3  Create a Backup"
 | 
			
		||||
  echo "4  Restore a Backup"
 | 
			
		||||
  echo "5  Delete a Backup"
 | 
			
		||||
  echo "6  Update All Apps"
 | 
			
		||||
  read -rt 600 -p "Please select an option by number: " selection
 | 
			
		||||
 | 
			
		||||
  case $selection in
 | 
			
		||||
    0)
 | 
			
		||||
        help="true"
 | 
			
		||||
        ;;
 | 
			
		||||
    1)
 | 
			
		||||
        dns="true"
 | 
			
		||||
        ;;
 | 
			
		||||
    2)
 | 
			
		||||
        mount="true"
 | 
			
		||||
        ;;
 | 
			
		||||
    4)
 | 
			
		||||
        read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups
 | 
			
		||||
        re='^[0-9]+$'
 | 
			
		||||
        number_of_backups=$number_of_backups
 | 
			
		||||
        ! [[ $number_of_backups =~ $re  ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit
 | 
			
		||||
        [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit
 | 
			
		||||
        backup "$number_of_backups"
 | 
			
		||||
      ;;
 | 
			
		||||
    5)
 | 
			
		||||
        restore="true"
 | 
			
		||||
        ;;
 | 
			
		||||
    6)
 | 
			
		||||
        deleteBackup="true"
 | 
			
		||||
        ;;
 | 
			
		||||
    9)
 | 
			
		||||
        echo ""
 | 
			
		||||
        echo "1  Update Apps Excluding likely breaking major changes"
 | 
			
		||||
        echo "2  Update Apps Including likely breaking major changes"
 | 
			
		||||
        read -rt 600 -p "Please select an option by number: " updateType
 | 
			
		||||
        if [[ "$updateType" == "1" ]]; then
 | 
			
		||||
            update_apps="true"
 | 
			
		||||
        elif [[ "$updateType" == "2" ]]; then
 | 
			
		||||
            update_all_apps="true"
 | 
			
		||||
        else
 | 
			
		||||
            echo "INVALID ENTRY" && exit 1
 | 
			
		||||
        fi
 | 
			
		||||
        ;;
 | 
			
		||||
    *)
 | 
			
		||||
        echo "Unknown option" && exit 1
 | 
			
		||||
        ;;
 | 
			
		||||
  esac
 | 
			
		||||
  echo ""
 | 
			
		||||
}
 | 
			
		||||
export -f menu
 | 
			
		||||
@@ -1,13 +1,15 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
#If no argument is passed, kill the script.
 | 
			
		||||
[[ -z "$*" || "-" == "$*" || "--" == "$*"  ]] && echo "This script requires an argument, use --help for help" && exit
 | 
			
		||||
[[ -z "$*" || "-" == "$*" || "--" == "$*"  ]] && menu
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# shellcheck source=functions/backup.sh
 | 
			
		||||
source functions/backup.sh
 | 
			
		||||
# shellcheck source=functions/dns.sh
 | 
			
		||||
source functions/dns.sh
 | 
			
		||||
# shellcheck source=functions/menu.sh
 | 
			
		||||
source functions/menu.sh
 | 
			
		||||
# shellcheck source=functions/misc.sh
 | 
			
		||||
source functions/misc.sh
 | 
			
		||||
# shellcheck source=functions/mount.sh
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user