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 |
for MAC OSX i have success with this:
used ex instead sed, and add support for resetting VMware networking
https://gist.github.com/catalinbostan/58940f61851c6493d8f71f3bbc55fbbc
Thx @catalinbostan !
I'll give that a shot. I'm usually working in OSX myself when I experience the issue.
@catalinbostan
Your script for OSX worked beautifully... Thx!
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
NOTE
This script is not yet 100% complete.
The sed commands do not parse command line arguments.
Further, it would be nice to be able to use multiple port arguments at the command line.