-
Notifications
You must be signed in to change notification settings - Fork 3
/
local.sh
51 lines (41 loc) · 1.39 KB
/
local.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
# local configuration options
# Note: modify at your own risk! If you do/use anything in this
# script that is not part of a stable API (relying on files to be in
# specific places, specific tools, specific output, etc) there is a
# possibility you will end up with a broken system after patching or
# upgrading. Changes are not supported unless under direction of
# VMware support.
# configuration
firewallConfigFile="/etc/vmware/firewall/service.xml"
# enable guest ip hack
esxcli system settings advanced set -o /Net/GuestIPHack -i 1
# change permissions on firewall config file
chmod 644 "$firewallConfigFile"
chmod +t "$firewallConfigFile"
# remove config root end tag from firewall config file
sed -i -e 's|</ConfigRoot>||g' "$firewallConfigFile"
# add xml block for vnc ports to the end of the firewall config file
cat <<EOT >> "$firewallConfigFile"
<!-- Ports opened for Packer VNC commands -->
<service id="1000">
<id>packer-vnc</id>
<rule id="0000">
<direction>inbound</direction>
<protocol>tcp</protocol>
<porttype>dst</porttype>
<port>
<begin>5900</begin>
<end>6000</end>
</port>
</rule>
<enabled>true</enabled>
<required>true</required>
</service>
</ConfigRoot>
EOT
# restore permissions on firewall config file
chmod 444 "$firewallConfigFile"
# restart firewall service
esxcli network firewall refresh
exit 0