#! /bin/bash
echo 关闭防火墙 安全linux
service iptables stop &> /dev/null
/usr/sbin/setenforce 0 &> /dev/null
sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/gp’ /etc/selinux/config &> /dev/null
[ $? -ne 0 ] && echo “失败”
echo “配置初始化信息”
cat >/etc/sysconfig/network-scripts/ifcfg-eth0 << EOT DEVICE=eth0 TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=no BOOTPROTO=none IPADDR=192.168.1.254 NETMASK=255.255.255.0 GATEWAY=192.168.1.2 EOT echo “NETWORKING=yes” > /etc/sysconfig/network
echo “HOSTNAME=STAR” >>/etc/sysconfig/network
nisdomainname STAR &> /dev/null
service network restart &> /dev/null
echo “192.168.1.254 STAR” >>/etc/hosts
echo “192.168.1.100 STARCL” >>/etc/hosts
echo “安装相关软件包”
yum install -y rpcbind nfs-utils autofs ypserv &> /dev/null
service rpcbind start &> /dev/null
chkconfig rpcbind on
echo “挂载相关目录”
mkdir /nfs/share -p
echo “/nfs/share/ *(rw,sync)” >> /etc/exports
chmod 777 /nfs/share/
service nfs restart &> /dev/null
chkconfig nfs on
mount -t nfs 192.168.1.254:/nfs/share /mnt/ &> /dev/null
echo “nfs -rw,soft,intr 172.25.1.101:/nfs/share” >>/etc/auto.misc
service autofs restart &> /dev/null
cat >>/etc/ypserv.conf <<ENN
127.0.0.0/255.0.0.0 : * : * : none
192.168.1.0/255.255.255.0 : * : * : none
- : * : * : deny
ENN
echo “启动并生成数据库 “
/etc/init.d/ypserv start &> /dev/null
chkconfig ypserv on
for i in {01..10}
do
useradd u$i
echo “u$i” | passwd –stdin u$i
done &> /dev/null
echo “control D
y ” | /usr/lib64/yp/ypinit -m &> /dev/null