-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathks1.cfg
61 lines (50 loc) · 1.74 KB
/
ks1.cfg
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
52
53
54
55
56
57
58
59
60
61
# Version 0.1 Last updated 06/2016
#
# Installs ESXi and sets the IP & Hostname based on the MAC address
#
# For info on how to build the boot CD, see http://www.virtuallyghetto.com/2012/03/how-to-create-bootable-esxi-5-iso.html
accepteula
install --firstdisk --overwritevmfs
rootpw VMware1!
# network --bootproto=dhcp --device=vmnic0
reboot
%pre --interpreter=busybox
%firstboot --interpreter=busybox
sleep 60;
####################################
# Setup Networking based on MAC Address
# Get MAC Address
MACADDR=$(esxcli network ip interface list |grep MAC | awk '{print $3}')
# IPADDR= $(esxcli network ip interface ipv4 get |grep vmk0 | awk '{print $2}')
# Find MAC Address to set
case `echo "${MACADDR}"` in
"00:0c:29:c2:25:8d"*)
HOSTNAME="SiteAA"
IPADDR="192.168.10.240"
;;
"00:0c:29:58:5d:d7"*)
HOSTNAME="SiteB"
IPADDR="192.168.10.250"
;;
*)
HOSTNAME="DHCP"
;;
esac
# Set IP if MAC is listed above. Otherwise use DHCP
if [`echo "${HOSTNAME}"` == "DHCP" ]; then
esxcli network ip interface ipv4 set --interface-name=vmk0 --type=dhcp
HOSTNAME= $(esxcli network ip interface ipv4 get |grep vmk0 | awk '{print $2}') # Get IP if using DHCP
else
esxcli network ip interface ipv4 set --interface-name=vmk0 --ipv4=${IPADDR} --netmask=255.255.255.0 --type=static
fi
# Set hostname
esxcli system hostname set --fqdn=${HOSTNAME}
# rename local datastore to something more meaningful
vim-cmd hostsvc/datastore/rename datastore1 "$(hostname -s)-local-storage-1"
########################################################################################################################
# For troubleshooting only
# Enable SSH and the ESXi Shell
vim-cmd hostsvc/enable_ssh
vim-cmd hostsvc/start_ssh
vim-cmd hostsvc/enable_esx_shell
vim-cmd hostsvc/start_esx_shell