开机自启动脚本:
[root@localhost:/vmfs/volumes/585cecce-2aa05335-5c8b-1866da85eba1] cat /etc/rc.local.d/local.sh
#!/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.
#时间时区配置
#6.0适用
#cp /vmfs/volumes/datastore1/localtime /etc/localtime
cp /vmfs/volumes/datastore1/localtime /vmfs/volumes/datastore1/localtimebak && mv /vmfs/volumes/datastore1/localtimebak /etc/localtime
#自定义虚拟服开机
status=`vim-cmd /hostsvc/hostsummary | grep inMaintenanceMode|cut -c 27`
[ $status == “t” ] && vim-cmd hostsvc/maintenance_mode_exit 1&> /dev/null
vim-cmd vmsvc/power.on 2
#管理口安全配置
mv /usr/lib/vmware/hostd/docroot/index.html /usr/lib/vmware/hostd/docroot/index.html.bak
mv /usr/lib/vmware/hostd/docroot/ui /usr/lib/vmware/hostd/docroot/xxx
exit 0
登陆加载脚本:
[root@localhost:/vmfs/volumes/585cecce-2aa05335-5c8b-1866da85eba1] cat /etc/profile.local
# profile.local
#
export PS1=”[$(echo ${VI_USERNAME//”/’\’})@h:w] ”
#登陆安全检测
ip=`who |tail -1|awk ‘{print $7}’`
user=`who |tail -1|awk ‘{print $1}’`
logintime=`date +%Y-%m-%d” “%H:%M:%S`
echo “esxi server * .*. *. *:$user $logintime from $ip” >/vmfs/volumes/datastore1/script/login.log
cd /vmfs/volumes/datastore1/script
scp -q -i id_rsa login.log *.*.*.*:/tmp
ssh -i id_rsa ... ‘cd /tmp;mylogs=tail -1 login.log
;echo “$mylogs”|mail -s “esxi login warnning!!” xxx@163.com’
#免认证配置:ansible 及跳板机
[root@localhost:/vmfs/volumes/585cecce-2aa05335-5c8b-1866da85eba1] cat /etc/ssh/keys-root/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAu7ccvs0WQFaGDZB1YcVXY2+58Ci1O2Snq/3Ojet8PNJLhcE8H0jelEw+3dQ1PZHaM
#登陆提示修改: cat /etc/motd