Skip to content

Instantly share code, notes, and snippets.

@thomasmerz
Created July 19, 2023 08:50
Show Gist options
  • Save thomasmerz/5a387a2a5ee182e61a8816b5fb81bbec to your computer and use it in GitHub Desktop.
Save thomasmerz/5a387a2a5ee182e61a8816b5fb81bbec to your computer and use it in GitHub Desktop.
Update/Download VirtualBox Guest Additions automatically (grep -qE "$(date +\%Y-\%m-\%d).*virtualbox" /var/log/zypp/history)
#!/bin/bash
# https://www.virtualbox.org/manual/ch08.html
cd "$HOME/VirtualBox VMs/" || exit 1
# URL siehe: https://www.virtualbox.org/wiki/Downloads
# --> "Oracle VM VirtualBox Extension Pack All supported platforms "
VERSION=$(VBoxManage -v|cut -d '_' -f1|cut -d "r" -f1)
CURRENT=$(VBoxManage list extpacks|grep "Version:"|awk {'print $2'})
# MUST BE RUN BEFORE 'get_vbox-extpack.sh' !!!
[ "${VERSION}" == "${CURRENT}" ] && exit 1
URL=http://download.virtualbox.org/virtualbox/${VERSION}/VBoxGuestAdditions_${VERSION}.iso
wget $URL --no-clobber --quiet && \
ln -sf VBoxGuestAdditions_${VERSION}.iso VBoxGuestAdditions_latest.iso
# can only be run while VM is powered on:
#VBoxManage startvm <hash>
#VBoxManage guestcontrol <hash> updateguestadditions --source VBoxGuestAdditions_latest.iso
##########################################################################
# ERROR:
#VBoxManage: error: Could not open guest session: VERR_NOT_FOUND
#VBoxManage: error: Details: code VBOX_E_IPRT_ERROR (0x80bb0005), component GuestWrap, interface IGuest, callee nsISupports
#VBoxManage: error: Context: "UpdateGuestAdditions(Bstr(strSource).raw(), ComSafeArrayAsInParam(aArgs), ComSafeArrayAsInParam(aUpdateFlags), pProgress.asOutParam())" at line 3667 of file VBoxManageGuestCtrl.cpp
##########################################################################
#VBoxManage controlvm <hash> acpipowerbutton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment