Created
August 22, 2017 16:03
-
-
Save stevenwaskey/5573a7a3b24ec6606e4ad1aa8cb10187 to your computer and use it in GitHub Desktop.
Clears out port collisions for VMWare guests in Vagrant env.
This file contains 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 | |
## | |
# Show the user what we're looking to remove from the network configs. | |
## | |
printf "\nWe've located the following entries matching the associated port argument. \n" | |
grep "add_nat_portfwd" /Library/Preferences/VMware\ Fusion/networking | grep $1 | |
grep $1 /Library/Preferences/VMware\ Fusion/vmnet8/nat.conf | |
## | |
# Prompt the user for confirmation. | |
## | |
printf "\n" | |
read -p "Are you sure you would like to remove the entries listed above?" -n 1 -r | |
printf "\n" | |
## | |
# Get jiggy wit it. | |
## | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
printf "Deleting ... \n" | |
# MAX OSX sed commands | |
# sed -i '' '/$1/d' /Library/Preferences/VMware\ Fusion/vmnet8/nat.conf | |
# sed -i '' '/$1/d' /Library/Preferences/VMware\ Fusion/networking | |
# Linux sed commands | |
sed -i.bak '/$1/d' /Library/Preferences/VMware\ Fusion/vmnet8/nat.conf | |
sed -i.bak '/$1/d' /Library/Preferences/VMware\ Fusion/networking | |
else | |
printf "No files we hurt in the making of this script.\n" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
grep is hanging for me...i just get a usage: grep command just after
We've located the following entries matching the associated port argument.