mirror of
				https://github.com/oSoWoSo/DistroHopper.git
				synced 2024-08-14 22:46:53 +00:00 
			
		
		
		
	Add --delete-disk and --delete-vm options. Close #227
This commit is contained in:
		
							parent
							
								
									2af2b9c34d
								
							
						
					
					
						commit
						4f0bbfc667
					
				
					 1 changed files with 35 additions and 11 deletions
				
			
		
							
								
								
									
										46
									
								
								quickemu
									
										
									
									
									
								
							
							
						
						
									
										46
									
								
								quickemu
									
										
									
									
									
								
							|  | @ -37,7 +37,15 @@ function ignore_msrs_alert() { | ||||||
|   fi |   fi | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function disk_delete() { | function delete_shortcut() { | ||||||
|  |   local SHORTCUT_DIR="${HOME}/.local/share/applications/" | ||||||
|  |   if [ -e "${SHORTCUT_DIR}/${VMNAME}.desktop" ]; then | ||||||
|  |     rm "${SHORTCUT_DIR}/${VMNAME}.desktop" | ||||||
|  |     echo "Deleted ${VM} desktop shortcut" | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function delete_disk() { | ||||||
|   if [ -e "${disk_img}" ]; then |   if [ -e "${disk_img}" ]; then | ||||||
|     rm "${disk_img}" |     rm "${disk_img}" | ||||||
|     # Remove any EFI vars, but not for macOS |     # Remove any EFI vars, but not for macOS | ||||||
|  | @ -46,14 +54,20 @@ function disk_delete() { | ||||||
|     rm "${VMDIR}/${VMNAME}-vars.fd" >/dev/null 2>&1 |     rm "${VMDIR}/${VMNAME}-vars.fd" >/dev/null 2>&1 | ||||||
|     rm "${VMPATH}/${VMDIR}/${VMNAME}-vars.fd" > /dev/null 2>&1 |     rm "${VMPATH}/${VMDIR}/${VMNAME}-vars.fd" > /dev/null 2>&1 | ||||||
|     echo "SUCCESS! Deleted ${disk_img}" |     echo "SUCCESS! Deleted ${disk_img}" | ||||||
|  |     delete_shortcut | ||||||
|   else |   else | ||||||
|     echo "NOTE! ${disk_img} not found. Doing nothing." |     echo "NOTE! ${disk_img} not found. Doing nothing." | ||||||
|   fi |   fi | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
|   local SHORTCUT_DIR="${HOME}/.local/share/applications/" | function delete_vm() { | ||||||
|   if [ -e "${SHORTCUT_DIR}/${VMNAME}.desktop" ]; then |   if [ -d "${VMDIR}" ]; then | ||||||
|     rm "${SHORTCUT_DIR}/${VMNAME}.desktop" |     rm -rf "${VMDIR}" | ||||||
|     echo "Deleted ${VM} desktop shortcut" |     rm "${VM}" | ||||||
|  |     echo "SUCCESS! Deleted ${VM} and ${VMDIR}" | ||||||
|  |     delete_shortcut | ||||||
|  |   else | ||||||
|  |     echo "NOTE! ${VMDIR} not found. Doing nothing." | ||||||
|   fi |   fi | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -1002,7 +1016,8 @@ function usage() { | ||||||
|   echo "  ${LAUNCHER} --vm ubuntu.conf" |   echo "  ${LAUNCHER} --vm ubuntu.conf" | ||||||
|   echo |   echo | ||||||
|   echo "You can also pass optional parameters" |   echo "You can also pass optional parameters" | ||||||
|   echo "  --delete                : Delete the disk image." |   echo "  --delete-disk           : Delete the disk image and EFI variables" | ||||||
|  |   echo "  --delete-vm             : Delete the entire VM and it's configuration" | ||||||
|   echo "  --display               : Select display backend. 'sdl' (default), 'gtk', 'none', or 'spice'" |   echo "  --display               : Select display backend. 'sdl' (default), 'gtk', 'none', or 'spice'" | ||||||
|   echo "  --fullscreen            : Starts VM in full screen mode (Ctl+Alt+f to exit)" |   echo "  --fullscreen            : Starts VM in full screen mode (Ctl+Alt+f to exit)" | ||||||
|   echo "  --ignore-msrs-always    : Configure KVM to always ignore unhandled machine-specific registers" |   echo "  --ignore-msrs-always    : Configure KVM to always ignore unhandled machine-specific registers" | ||||||
|  | @ -1036,7 +1051,8 @@ secureboot="off" | ||||||
| tpm="off" | tpm="off" | ||||||
| usb_devices=() | usb_devices=() | ||||||
| 
 | 
 | ||||||
| DELETE=0 | DELETE_DISK=0 | ||||||
|  | DELETE_VM=0 | ||||||
| FULLSCREEN="" | FULLSCREEN="" | ||||||
| FULLSPICY="" | FULLSPICY="" | ||||||
| OUTPUT="sdl" | OUTPUT="sdl" | ||||||
|  | @ -1096,8 +1112,11 @@ if [ $# -lt 1 ]; then | ||||||
| else | else | ||||||
|     while [ $# -gt 0 ]; do |     while [ $# -gt 0 ]; do | ||||||
|         case "${1}" in |         case "${1}" in | ||||||
|           -delete|--delete) |           -delete|--delete|-delete-disk|--delete-disk) | ||||||
|             DELETE=1 |             DELETE_DISK=1 | ||||||
|  |             shift;; | ||||||
|  |           -delete-vm|--delete-vm) | ||||||
|  |             DELETE_VM=1 | ||||||
|             shift;; |             shift;; | ||||||
|           -display|--display) |           -display|--display) | ||||||
|             OUTPUT="${2}" |             OUTPUT="${2}" | ||||||
|  | @ -1191,8 +1210,13 @@ else | ||||||
|   usage |   usage | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| if [ ${DELETE} -eq 1 ]; then | if [ ${DELETE_DISK} -eq 1 ]; then | ||||||
|   disk_delete |   delete_disk | ||||||
|  |   exit | ||||||
|  | fi | ||||||
|  | 
 | ||||||
|  | if [ ${DELETE_VM} -eq 1 ]; then | ||||||
|  |   delete_vm | ||||||
|   exit |   exit | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue