Created
August 4, 2015 12:19
-
-
Save mdarse/5be2f9b1e89a4992bd83 to your computer and use it in GitHub Desktop.
Revisions
-
mdarse created this gist
Aug 4, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ #/bin/bash set -o errexit # Find whether the Vagrant machine was already created or not. # It parses that kind of output: # # 1438619288,default,provider-name,vmware_fusion # 1438619288,default,state,not_created # 1438619288,default,state-human-short,not created found=0 # Poor guy CSV parsing while IFS=, read _ _ key value; do if [ "$key" = "state" ]; then found=1 if [ "$value" == "not_created" ]; then printf "no" else printf "yes" fi exit 0 fi done <<< "$(vagrant status --machine-readable)" if [ "$found" -eq "0" ]; then echo "Invalid output received from Vagrant" exit 1 fi