#!/bin/bash
# 过滤出MAC地址
MAC=`ifconfig |awk '{print $5}'|sed -n '1p;1q'`
# 过滤网卡名字
NET_NAME=`ifconfig |awk '{print $1}'|sed -n '1p;1q'`
# 修改MAC地址
MAC_F=/etc/udev/rules.d/70-persistent-net.rules
## 替换MAC
sed -r -i 's/(ATTR{address}==")[^"]*/1'"$MAC"'/' $MAC_F
# 修改网卡参数
#NETWORK_F=/etc/sysconfig/network-scripts/ifcfg-$NET_NAME
NETWORK_F=`ls /etc/sysconfig/network-scripts/ifcfg-eth*`
## ONBOOT
sed -r -i 's/(ONBOOT=)[^$]*/1yes/' $NETWORK_F
## IPADDR
ip=`ifconfig | awk -F':' '{print $2}'|awk '{print $1}'| sed -n '2p;2q'`
sed -r -i 's/(IPADDR=)[^$]*/1'"$ip"'/' $NETWORK_F
## GATEWAY
gate=192.168.232.1
sed -r -i 's/(GATEWAY=)[^$]*/1'"$gate"'/' $NETWORK_F
## HWADDR
sed -r -i 's/(HWADDR=)[^$]*/1'"$MAC"'/' $NETWORK_F
# 修改selinux
SELINUX_F=/etc/selinux/config
sed -r -i 's/(SELINUX=)[^$]*/1disabled/' $SELINUX_F
# 增加用户密码
useradd -u 1506 XXXX
useradd -u 2001 XXX
useradd -u 1499 XXX
groupadd -g 1003 XXXX
echo XXXXX | passwd --stdin XXXXX
usermod -G XXX XXXX
chkconfig iptables off
# 增加时间同步
yum install -y ntpdate-4.2.6p5-1.el6.centos.x86_64
echo "*/5 * * * * /usr/sbin/ntpdate 192.168.232.254 >/dev/null" >> /etc/crontab
reboot