Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save chauncey-garrett/923e9ecc0aa90419cedec55793c9d88e to your computer and use it in GitHub Desktop.

Select an option

Save chauncey-garrett/923e9ecc0aa90419cedec55793c9d88e to your computer and use it in GitHub Desktop.

Revisions

  1. @sc250024 sc250024 revised this gist Dec 17, 2016. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions vagrant-update-all-boxes.sh
    Original file line number Diff line number Diff line change
    @@ -24,14 +24,14 @@ if [[ ${#AVAILABLE_UPDATES[@]} -ne 0 ]]; then
    vagrant box add --clean ${box} --provider ${provider}
    BOX_UPDATED="TRUE"

    # Remove all old versions
    vagrant box remove ${box} -f --box-version ${version} --provider ${provider}

    done

    done

    echo "All boxes are now up to date!"
    echo "All boxes are now up to date! Pruning..."

    # Remove all old versions
    vagrant box prune -f

    else
    echo "All boxes are already up to date!"
  2. @sc250024 sc250024 revised this gist Dec 17, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion vagrant-update-all-boxes.sh
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ OLDIFS=$IFS
    export IFS=$'\n'

    # Find all boxes which have updates
    AVAILABLE_UPDATES=$(vagrant box outdated --global | grep outdated | tr -d "*'" | cut -d ' ' -f 2)
    AVAILABLE_UPDATES=$(vagrant box outdated --global | grep outdated | tr -d "*'" | cut -d ' ' -f 2 2>/dev/null)

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

  3. @sc250024 sc250024 created this gist Dec 17, 2016.
    42 changes: 42 additions & 0 deletions vagrant-update-all-boxes.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    #!/bin/bash

    OLDIFS=$IFS
    export IFS=$'\n'

    # Find all boxes which have updates
    AVAILABLE_UPDATES=$(vagrant box outdated --global | grep outdated | tr -d "*'" | cut -d ' ' -f 2)

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

    for box in ${AVAILABLE_UPDATES}; do

    echo "Found an update for ${box}"

    # Find all current versions
    boxinfo=$(vagrant box list | grep ${box})

    for boxtype in ${boxinfo}; do

    provider=$(echo ${boxtype} | awk -F\( '{print $2}' | awk -F\, '{print $1}')
    version=$(echo ${boxtype} | cut -d ',' -f 2 | tr -d ' )')

    # Add latest version
    vagrant box add --clean ${box} --provider ${provider}
    BOX_UPDATED="TRUE"

    # Remove all old versions
    vagrant box remove ${box} -f --box-version ${version} --provider ${provider}

    done

    done

    echo "All boxes are now up to date!"

    else
    echo "All boxes are already up to date!"
    fi

    vagrant box outdated --global

    export IFS=$OLDIFS