2,设置初始化域名 [root@wgq-web-1-50 ~]# more /etc/sysconfig/network NETWORKING=yes HOSTNAME=localhost.localdomain [root@wgq-web-1-50 ~]#
3,编写初始化安装脚本 [root@wgq_idc_web_1_50 ~]# vim init_app_shell.sh #!/bin/bash #IP GATEWAY parameters if [ $# != 3 ] then echo "USAGE: $0 IPADDR GATEWAY HostName" echo "eg: $0 1xx.2xx.1.12 1xx.2xx.1.1 wgq_idc_mon_1_12" exit 1 fi
#hostname configuration,注意sed后面带变量的话,不能用‘符号,因为会解析不了$3变量值。 hostname $3 sed -i "s/HOSTNAME=localhost.localdomain/HOSTNAME=$3/g" /etc/sysconfig/network
#chkconfig yum install -y chkconfig
#stop services chkconfig --list |grep ":on" |awk ‘{print $1}‘ > /tmp/allonservice.txt for i in `cat /tmp/allonservice.txt` do chkconfig $i off done
for k in NetworkManager crond messagebus network rsyslog sshd do chkconfig $k on done
#network configuration grep "DNS1" /etc/sysconfig/network-scripts/ifcfg-eth0 if [ $? != 0 ] then cat <<EOF>> /etc/sysconfig/network-scripts/ifcfg-eth0 IPADDR=$1 NETMASK=255.255.255.0 GATEWAY=$2 DNS1=2xx.1xx.136.10 EOF fi
sed -i ‘s/ONBOOT=no/ONBOOT=yes/g‘ /etc/sysconfig/network-scripts/ifcfg-eth0 sed -i ‘s/BOOTPROTO=dhcp/BOOTPROTO=static/g‘ /etc/sysconfig/network-scripts/ifcfg-eth0 service network restart