2009-05-12 20:30:41 +00:00
|
|
|
# esx setup
|
|
|
|
# example on how to set up ESX. We setup ssh and also add a basic
|
|
|
|
# VLAN configuration
|
2014-06-13 16:06:12 +00:00
|
|
|
|
|
|
|
|
2014-07-23 06:16:48 +00:00
|
|
|
if [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then
|
|
|
|
str_dir_name=`dirname $0`
|
|
|
|
. $str_dir_name/xcatlib.sh
|
|
|
|
fi
|
2014-06-13 16:06:12 +00:00
|
|
|
|
2012-05-15 07:51:12 +00:00
|
|
|
logger -t xcat -p local4.info setupesx
|
2009-05-21 20:17:11 +00:00
|
|
|
# Enable SSH access to root and exchange keys
|
2009-05-12 20:30:41 +00:00
|
|
|
|
|
|
|
sed -e 's/PermitRootLogin no/PermitRootLogin yes/' /etc/ssh/sshd_config > /etc/ssh/sshd_config.new
|
|
|
|
mv -f /etc/ssh/sshd_config.new /etc/ssh/sshd_config
|
2014-06-13 16:06:12 +00:00
|
|
|
#/etc/init.d/sshd restart
|
|
|
|
restartservice ssh
|
2009-05-12 20:30:41 +00:00
|
|
|
|
2009-05-21 20:17:11 +00:00
|
|
|
if [ -r /etc/ssh/sshd_config ]
|
|
|
|
then
|
2012-05-15 07:51:12 +00:00
|
|
|
logger -t xcat -p local4.info "Install: setup /etc/ssh/sshd_config"
|
2009-05-21 20:17:11 +00:00
|
|
|
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.ORIG
|
|
|
|
sed -i 's/^X11Forwarding .*$/X11Forwarding yes/' /etc/ssh/sshd_config
|
|
|
|
sed -i 's/^KeyRegenerationInterval .*$/KeyRegenerationInterval 0/' /etc/ssh/sshd_config
|
|
|
|
sed -i 's/\(.*MaxStartups.*\)/#\1/' /etc/ssh/sshd_config
|
|
|
|
echo "MaxStartups 1024" >>/etc/ssh/sshd_config
|
|
|
|
echo "PasswordAuthentication no" >>/etc/ssh/sshd_config
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -r /etc/ssh/sshd_config ]
|
|
|
|
then
|
|
|
|
echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d /xcatpost/_ssh ]
|
|
|
|
then
|
2012-05-15 07:51:12 +00:00
|
|
|
logger -t xcat -p local4.info "Install: setup root .ssh"
|
2009-05-21 20:17:11 +00:00
|
|
|
cd /xcatpost/_ssh
|
|
|
|
mkdir -p /root/.ssh
|
|
|
|
cp -f * /root/.ssh
|
|
|
|
cd - >/dev/null
|
|
|
|
chmod 700 /root/.ssh
|
|
|
|
chmod 600 /root/.ssh/*
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2009-05-12 20:30:41 +00:00
|
|
|
# create a script that will launch the first time ESX does and configure
|
|
|
|
# the network
|
|
|
|
cat >/tmp/esxcfg.sh <<EOF1
|
2014-11-19 14:42:19 +00:00
|
|
|
#!/bin/bash
|
2009-05-12 20:30:41 +00:00
|
|
|
# Configure ESX Server. You'll need to put your own IP address
|
|
|
|
# in here. We assume eth0 is your nic. Change if needed.
|
|
|
|
NIC=eth0
|
2014-06-13 16:06:12 +00:00
|
|
|
#IPADDR=`ifconfig $NIC |grep "inet addr"|awk '{print $2}' |awk -F: '{print $2}' | head -1`
|
|
|
|
IPADDR=`ip -4 -oneline addr show $NIC|grep inet|awk -F ' ' '{print $4}'|awk -F '/' '{print $1}'`
|
|
|
|
#NETMASK=`ifconfig $NIC |grep "inet addr"|awk '{print $4}' |awk -F: '{print $2}'`
|
|
|
|
NETMASK=`ip -4 -oneline addr show $NIC|grep inet|awk -F ' ' '{print $4}'|awk -F '/' '{print $2}'`
|
|
|
|
NETMASK=`v4prefix2mask $NETMASK`
|
2009-05-12 20:30:41 +00:00
|
|
|
|
2009-05-21 20:17:11 +00:00
|
|
|
#esxcfg-vswitch -U vmnic0 vSwitch0
|
|
|
|
esxcfg-vswitch -L vmnic0 vSwitch0
|
|
|
|
esxcfg-vswif -i \$IPADDR -n \$NETMASK vswif0
|
2009-05-12 20:30:41 +00:00
|
|
|
esxcfg-firewall -e sshClient
|
|
|
|
|
|
|
|
esxcfg-firewall -e ntpClient
|
|
|
|
esxcfg-firewall -o 123,udp,out,ntpServer
|
|
|
|
esxcfg-firewall -o 514,udp,out,syslog
|
|
|
|
esxcfg-firewall -l
|
2012-05-15 07:51:12 +00:00
|
|
|
logger -t xcat -p local4.info "Install: restart syslog"
|
2014-06-13 16:06:12 +00:00
|
|
|
#service syslog restart
|
|
|
|
restartservice syslog
|
2009-05-12 20:30:41 +00:00
|
|
|
|
|
|
|
EOF1
|
|
|
|
|
2009-05-21 20:17:11 +00:00
|
|
|
chmod 755 /tmp/esxcfg.sh
|
2009-05-12 20:30:41 +00:00
|
|
|
cp /etc/rc.d/rc.local /etc/rc.d/rc.local.bak
|
|
|
|
|
|
|
|
cat >>/etc/rc.d/rc.local <<EOF
|
|
|
|
/tmp/esxcfg.sh
|
|
|
|
mv -f /etc/rc.d/rc.local.bak /etc/rc.d/rc.local
|
|
|
|
EOF
|