Skip to content

Instantly share code, notes, and snippets.

@NeMO84
Last active June 18, 2021 15:10
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save NeMO84/95e93346e81dbb2b75dd677922addbda to your computer and use it in GitHub Desktop.
Save NeMO84/95e93346e81dbb2b75dd677922addbda to your computer and use it in GitHub Desktop.
#!/bin/bash
# Usage: vb-reset-host-version-guestproperty.sh myvmname
VMNAME=$1
VBOXMANAGE="$(which vboxmanage)"
if [ -z "$VMNAME" ]; then
echo "Must provide name of VM."
exit 1
fi
# Find UUID
UUID="$($VBOXMANAGE list vms | grep -w $VMNAME | cut -d' ' -f2 | tr -d '{}')"
if [ -z "$UUID" ]; then
echo "No VM found with the name '$VMNAME'."
exit 1
fi
echo "Found UUID:$UUID"
# Set latest version
CURRENT_VERSION="$($VBOXMANAGE --version)"
GUESTPROPERTY_VERSION="$($VBOXMANAGE guestproperty get $UUID /VirtualBox/GuestAdd/Version | sed s/Value\:\ //g)"
if [ "$CURRENT_VERSION" != "$GUESTPROPERTY_VERSION" ]; then
$VBOXMANAGE guestproperty set $UUID /VirtualBox/GuestAdd/Version "$CURRENT_VERSION"
echo "GuestProperty(/VirtualBox/GuestAdd/Version) updated to '$CURRENT_VERSION' from '$GUESTPROPERTY_VERSION'"
else
echo "Versions match: $CURRENT_VERSION"
fi
@NeMO84
Copy link
Author

NeMO84 commented Mar 10, 2019

@mluis7
Copy link

mluis7 commented Jul 14, 2020

Cool script! just fails on some distros due to vboxmanage name spelled VBoxManage.
Once that's fixed, works as expected.
For some reason it does not fix Vagrant version mismatch message
[default] GuestAdditions seems to be installed (6.0.22) correctly, but not running.

@proseLA
Copy link

proseLA commented Jun 18, 2021

sorry, this does not work for me. sample output for 1 machine (i renamed your script to vbr):

# VBoxManage list vms | grep ycast3
"ycast3_default_1622908794541_20972" {4467a641-fa5b-4dc7-9cc7-6fea666ddbf5}
 # VBoxManage guestproperty get ycast3_default_1622908794541_20972 /VirtualBox/GuestAdd/Version
Value: 6.1.22r144080
 # vbr ycast3_default_1622908794541_20972
Found UUID:4467a641-fa5b-4dc7-9cc7-6fea666ddbf5
Versions match: 6.1.22r144080
 # vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'debian/buster64' version '10.20210409.1' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Fixed port collision for 22 => 2222. Now on port 2201.
....
==> default: Machine booted and ready!
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   5.2.0
VBoxService inside the vm claims: 6.1.22
Going on, assuming VBoxService is correct...
[default] GuestAdditions seems to be installed (6.1.22) correctly, but not running.
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   5.2.0
VBoxService inside the vm claims: 6.1.22
Going on, assuming VBoxService is correct...
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   5.2.0
VBoxService inside the vm claims: 6.1.22
Going on, assuming VBoxService is correct...
VirtualBox Guest Additions: Starting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment