-
Notifications
You must be signed in to change notification settings - Fork 1
/
change-iso
35 lines (23 loc) · 988 Bytes
/
change-iso
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
VM_GUID="{d0f3631f-9f95-4907-a950-77c674bfcd84}"
if VBoxManage list runningvms | grep "$VM_GUID" ; then
echo VM is running
exit 1
fi
CD=$( VBoxManage showvminfo "$VM_GUID" --machinereadable | grep '^"IDE-1-0"' )
# Example: "IDE-1-0"="/home/alsetupvb/Downloads/archlinux-2021.01.01-x86_64.iso"
CURRENTISO=$( ls -1r Downloads/archlinux-20??.??.??-x86_64.iso | head -n 1 )
# Example: Downloads/archlinux-2021.02.01-x86_64.iso
#echo "$CD"
#echo "$CURRENTISO"
if echo "$CD" | grep -F "$CURRENTISO" ; then
echo Current ISO already mounted
exit 1
fi
VBoxManage snapshot "$VM_GUID" restorecurrent
VBoxManage snapshot "$VM_GUID" delete "Sicherungspunkt 1"
VBoxManage storageattach "$VM_GUID" --storagectl IDE --port 1 --device 0 --type dvddrive --medium "$HOME/$CURRENTISO"
VBoxManage snapshot "$VM_GUID" take "Sicherungspunkt 1"
echo === Changes done ===
VBoxManage snapshot "$VM_GUID" list
VBoxManage showvminfo "$VM_GUID" --machinereadable | grep '^"IDE-1-0"'