Skip to content

Instantly share code, notes, and snippets.

@djfdyuruiry
Created March 6, 2020 16:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djfdyuruiry/7ce70342fbd18e5d6313bd90a72ea65f to your computer and use it in GitHub Desktop.
Save djfdyuruiry/7ce70342fbd18e5d6313bd90a72ea65f to your computer and use it in GitHub Desktop.
Bash script that automatically downloads the latest Vagrant Ubuntu package
#! /usr/bin/env bash
set -e
vagrantBaseUrl="https://releases.hashicorp.com"
latestRelease=$(\
wget -q -O - "${vagrantBaseUrl}/vagrant/" \
| grep 'a href="' \
| grep -v '<a href="../">../</a>' \
| head -n 1 \
| grep -oP '(?<=<a href="/vagrant/)(.+)(?=/")' \
)
debianPackage=$(
wget -q -O - "${vagrantBaseUrl}/vagrant/${latestRelease}/" \
| grep -oP '(?<=href=").+_x86_64.deb(?=")'
)
downloadUrl="${vagrantBaseUrl}${debianPackage}"
wget -q --trust-server-names "${downloadUrl}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment