Skip to content

Instantly share code, notes, and snippets.

@johnvilsack
Last active December 17, 2015 20:59
Show Gist options
  • Save johnvilsack/5671845 to your computer and use it in GitHub Desktop.
Save johnvilsack/5671845 to your computer and use it in GitHub Desktop.
A stupid simple way to grab a Vagrantfile, customize it, and bring it all online with a consistent folder and hostname
#!/bin/bash
echo "What do you want to call this Vagrant? "
read vmhostname
echo "What port number do you want for web access (:80)? "
read vmport
if [ ! -d $vmhostname ]; then
mkdir $vmhostname
cd $vmhostname
fi
if [ ! -f "./Vagrantfile" ]; then
cp ~/.profile/configs/Vagrant/Vagrantfile ./
fi
# Argument Parsing for creating a Vagrant Instance
sed -i.sed "s/config.vm.hostname =.*/config.vm.hostname = \"$vmhostname\"/g" ./Vagrantfile
sed -i.sed "s/config.vm.network :forwarded_port.*/config.vm.network :forwarded_port, guest: 80, host: $vmport/g" ./Vagrantfile
sed -i.sed "s@config.vm.synced_folder.*@config.vm.synced_folder \"$PWD\",\"/ext\"@g" ./Vagrantfile
rm ./Vagrantfile.sed
if [ ! -d "./ext" ]; then
mkdir ./ext
fi
vagrant up
echo "Vagrant Instance $vmhostname created"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment