Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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

This comment has been minimized.

Copy link
Owner Author

@NeMO84 NeMO84 commented Mar 10, 2019

@mluis7

This comment has been minimized.

Copy link

@mluis7 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

This comment has been minimized.

Copy link

@proseLA 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