diff options
author | Jonathan Bauer | 2018-04-18 11:33:31 +0200 |
---|---|---|
committer | Jonathan Bauer | 2018-04-18 11:33:31 +0200 |
commit | 9504d2653999e7811a3f22e41f87aa30ef4e0dad (patch) | |
tree | 44c48692aa61e729efb015a54f76de1fdcf82621 /core | |
parent | [vbox-src] reload udev rules on vbox.service start (diff) | |
download | mltk-9504d2653999e7811a3f22e41f87aa30ef4e0dad.tar.gz mltk-9504d2653999e7811a3f22e41f87aa30ef4e0dad.tar.xz mltk-9504d2653999e7811a3f22e41f87aa30ef4e0dad.zip |
[vbox-src] cleanup snapshot file upon cleanexit
While VDI's "Immutable" type cleans up the snapshot file automatically,
it doesn't do so until a restart of the VM. In our case, it will
never happen and slowly fill up /tmp. Thus we remove it manually on
cleanexit.
Diffstat (limited to 'core')
-rwxr-xr-x | core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/prepare_snapshot.inc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/prepare_snapshot.inc b/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/prepare_snapshot.inc index 296f55ae..48924458 100755 --- a/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/prepare_snapshot.inc +++ b/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/prepare_snapshot.inc @@ -1,5 +1,9 @@ +delete_snapshot() { + rm -f "${VBOX_SNAPSHOT_DIR}/{${SNAPSHOT_UUID}}.vdi" || \ + writelog "Could not cleanup snapshot file: ${VBOX_SNAPSHOT_DIR}/{${SNAPSHOT_UUID}}.vdi" +} prepare_snapshot() { - SNAPSHOT_UUID="34f617be-192a-46b3-a8ae-bce1029e093f" # snapshot UUID is static + declare -rg SNAPSHOT_UUID="34f617be-192a-46b3-a8ae-bce1029e093f" # snapshot UUID is static # get UUID of VBox image HDD_UUID=$(${VBOX_BASE_DIR}/VBoxManage -q showvdiinfo ${VBOX_HDD_LINK} \ @@ -23,6 +27,7 @@ prepare_snapshot() { dd if=${VBOX_HDD_LINK} of="${VBOX_SNAPSHOT_DIR}/{${SNAPSHOT_UUID}}.vdi" seek=424 \ skip=392 bs=1 count=16 conv=notrunc || \ writelog "Could not patch snapshot file" + add_cleanup delete_snapshot elif isset VM_DISKFILE_RW; then # Image is already RW - easy VBOX_HDD_TYPE="Normal" |