Created
October 1, 2019 02:21
-
-
Save elleryq/7ef0113558b262239c637a1f4753cf56 to your computer and use it in GitHub Desktop.
Upgrade vagrant to latest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set +o pipefail | |
| #if [ -z "${1}" ]; then | |
| # echo "Which version?" | |
| # exit -1 | |
| #fi | |
| # version=$1 | |
| # Get current installed version | |
| current_version=$(dpkg-query -W vagrant | awk -F: '{print $2}') | |
| version=$(curl -s https://www.vagrantup.com/downloads.html | grep "CHANGELOG" downloads.html | grep -o 'v[0-9]\.[0-9]\.[0-9]' | head -n 1| cut -c2-) | |
| if [ "${current_version}" == "${version}" ]; then | |
| echo "Already latest version: ${version}" | |
| exit -1 | |
| fi | |
| arch=$(uname -m) | |
| url=https://releases.hashicorp.com/vagrant/${version}/vagrant_${version}_${arch}.deb | |
| # extract the path (if any) | |
| path="$(echo \"${url}\" | grep / | cut -d/ -f2-)" | |
| #echo "${path}" | |
| filename="$(basename \"${path}\")" | |
| #echo ${path} | |
| #echo ${filename} | |
| # download | |
| wget -O "${filename}" "${url}" | |
| # Install/Upgrade | |
| sudo dpkg -i "${filename}" | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment