Last active
August 29, 2015 14:03
-
-
Save clavery/501ec902ee99b3870437 to your computer and use it in GitHub Desktop.
Revisions
-
clavery revised this gist
Jul 9, 2014 . 1 changed file with 24 additions and 6 deletions.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 @@ -8,6 +8,11 @@ VMRUN="/Applications/VMware Fusion.app/Contents/Library/vmrun" VMS=$("${VMRUN}" list | tail -n +2) if [ "$VMS" == "" ]; then echo "Need to running the VM" exit fi PS3='Which VM? ' select vm in "${VMS[@]}" do @@ -17,6 +22,12 @@ done MAC_ADDRESS=$("${VMRUN}" readVariable "$vm" runtimeConfig ethernet0.generatedAddress) NETWORK=$(grep -oE '192\.168\.\d{1,3}' /Library/Preferences/VMware\ Fusion/vmnet8/dhcpd.conf | head -n 1) grep ${MAC_ADDRESS} "/Library/Preferences/VMware Fusion/vmnet8/dhcpd.conf" > /dev/null if [ $? == "0" ]; then echo "VM Already Configured" exit; fi echo "Changing settings for mac ${MAC_ADDRESS} on ${NETWORK}" @@ -26,18 +37,25 @@ read SOURCE echo "Port on guest machine? " read GUEST HOST=50 grep "${NETWORK}.${HOST}" "/Library/Preferences/VMware Fusion/vmnet8/dhcpd.conf" > /dev/null while [ $? == "0" ] do HOST=$(($HOST + 1)) done sed -i .bak "/\[incomingtcp\]/ a\ $SOURCE = ${NETWORK}.${HOST}:$GUEST\ " /Library/Preferences/VMware\ Fusion/vmnet8/nat.conf cat <<DHCPOUTPUT >> "/Library/Preferences/VMware Fusion/vmnet8/dhcpd.conf" host myvm_$HOST { hardware ethernet $MAC_ADDRESS; fixed-address ${NETWORK}.${HOST}; } DHCPOUTPUT echo "Fixed address assigned: ${NETWORK}.${HOST}" -
clavery created this gist
Jul 8, 2014 .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,43 @@ #!/usr/bin/env sh ## Port map and set static address for Natted VM Fusion box ## Box must be running and this script needs to be run as sudo ## Restart VMware after ## ## sudo sh fusionportmap.sh VMRUN="/Applications/VMware Fusion.app/Contents/Library/vmrun" VMS=$("${VMRUN}" list | tail -n +2) PS3='Which VM? ' select vm in "${VMS[@]}" do break done MAC_ADDRESS=$("${VMRUN}" readVariable "$vm" runtimeConfig ethernet0.generatedAddress) NETWORK=$(grep -oE '192\.168\.\d{1,3}' /Library/Preferences/VMware\ Fusion/vmnet8/dhcpd.conf | head -n 1) echo "Changing settings for mac ${MAC_ADDRESS} on ${NETWORK}" echo "Port on host machine? " read SOURCE echo "Port on guest machine? " read GUEST sed -i .bak "/\[incomingtcp\]/ a\ $SOURCE = ${NETWORK}.50:$GUEST\ " /Library/Preferences/VMware\ Fusion/vmnet8/nat.conf grep myvm "/Library/Preferences/VMware Fusion/vmnet8/dhcpd.conf" > /dev/null if [ $? != "0" ]; then cat <<DHCPOUTPUT >> "/Library/Preferences/VMware Fusion/vmnet8/dhcpd.conf" host myvm { hardware ethernet $MAC_ADDRESS; fixed-address ${NETWORK}.50; } DHCPOUTPUT fi