Skip to content

Instantly share code, notes, and snippets.

@cobusbernard
Created December 1, 2016 06:26
Show Gist options
  • Save cobusbernard/2e14e0362a639139a1a0693bbba34600 to your computer and use it in GitHub Desktop.
Save cobusbernard/2e14e0362a639139a1a0693bbba34600 to your computer and use it in GitHub Desktop.
packer-update
function packer-version() {
if [ -z $1 ]; then
echo "You must specify the version!"
return
fi
echo "Switching to packer version $1"
if [ ! -f /usr/local/Cellar/packer/$1/packer ]; then
echo "New version of packer, downloading..."
curl -S https://releases.hashicorp.com/packer/$1/packer_$1_darwin_amd64.zip > /tmp/packer_$1.zip \
&& cd /tmp \
&& unzip /tmp/packer_$1.zip \
&& mkdir -p /usr/local/Cellar/packer/$1/ \
&& mv packer /usr/local/Cellar/packer/$1/ \
&& rm /tmp/packer_$1.zip \
&& cd -
fi
rm /usr/local/bin/packer
ln -s /usr/local/Cellar/packer/$1/packer /usr/local/bin/packer
echo "Confirming packer version from binary:"
packer --version
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment