Updating VirtualBox boxes using bash script

 Forgot where i got this script to update Virtualboxes. Worth sharing though


#!/bin/bash 

# Find all boxes which have updates

AVAILABLE_UPDATES=`vagrant box outdated --global | grep outdated | tr -d "*'" | cut -d ' ' -f 2`

if [ ! ${#AVAILABLE_UPDATES[@]} -eq 0 ]; then

  for box in $AVAILABLE_UPDATES ; do

    echo "Found an update for $box"

   # Find all current versions

    VERSIONS=`vagrant box list | grep $box | cut -d ',' -f 2 | tr -d ' )'`

    # Add latest version

    vagrant box add --clean $box

    BOX_UPDATED="TRUE"

    # Remove all old versions

    for version in $VERSIONS ; do

      vagrant box remove $box -f --box-version=$version

    done

  done

  echo "All boxes are now up to date!"

else

  echo "All boxes are already up to date!"

fi

vagrant box outdated --global



Sample run:

─cperez@mctoffer-2.local ~

╰─➤  vagrant-box-update-all.sh

Found an update for ubuntu/focal64

==> box: Loading metadata for box 'ubuntu/focal64'

    box: URL: https://vagrantcloud.com/ubuntu/focal64

==> box: Adding box 'ubuntu/focal64' (v20220208.0.0) for provider: virtualbox

    box: Downloading: https://vagrantcloud.com/ubuntu/boxes/focal64/versions/20220208.0.0/providers/virtualbox.box

Download redirected to host: cloud-images.ubuntu.com

==> box: Successfully added box 'ubuntu/focal64' (v20220208.0.0) for 'virtualbox'!


By penoi on Monday, February 14, 2022 | | A comment?

Bridged wifi Vmware fusion in MacOs Monterey

 Finally a working bridged network via wifi after MacOS Monterey 12.2.1 in VMware Fusion


By penoi on Sunday, February 13, 2022 | A comment?