Skip to content

Instantly share code, notes, and snippets.

@roktas
Created August 31, 2017 21:33
Show Gist options
  • Save roktas/ec34960d2e5d74c3cc4f35bc78bc676d to your computer and use it in GitHub Desktop.
Save roktas/ec34960d2e5d74c3cc4f35bc78bc676d to your computer and use it in GitHub Desktop.
#!/bin/bash
set -eo pipefail
TARGETFMT='/opt/vagrant/embedded/gems/gems/vagrant-%s/plugins/providers/virtualbox/driver/meta.rb'
die() { echo >&2 "$@"; exit 1; }
[[ $EUID -eq 0 ]] || die "sudo required"
command -v vagrant >/dev/null || die "no vagrant installed"
version=$(vagrant version | awk '{ print $NF; exit }')
[[ -n $version ]] || die "no version found"
# shellcheck disable=SC2059
target=$(printf "$TARGETFMT" "$version")
[[ -f $target ]] || die "$target not found"
cp "$target" "$target.orig"
sed -i 's/"4.0" => Version_4_0,/"5.2" => Version_5_1,/' "$target"
@maxkaplan
Copy link

I would like to use vagrant with virtualbox 5.2 - but I'm not sure how to implement this code. Any help would be much appreciated. Thank you

@danieladarve
Copy link

@maxkaplan This is a shell script. Download and save as vagrant-patch-for-virtualbox-5.2.sh, then google how to execute a shell script from your OS

@xarem
Copy link

xarem commented Oct 20, 2017

thanks! great!

@maarten-v
Copy link

If you're using Windows, edit the file "C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-2.0.0\plugins\providers\virtualbox\driver" and after the line
"5.1" => Version_5_1,
add:
"5.2" => Version_5_1,

@bjonesy
Copy link

bjonesy commented Oct 20, 2017

This works!! I was getting this issue sed: 1: "/opt/vagrant/embedded/g ...": invalid command code v when first trying to run the shell script. On the last line of the file I add a '' after the i and it fixed this error. Fixed line sed -i '' 's/"4.0" => Version_4_0,/"5.2" => Version_5_1,/' "$target"

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