#!/bin/bash
iptables -F
iptables -X
/etc/init.d/iptables save
chkconfig tftp on
chkconfig xinetd on
a=$(ifconfig eth0 |sed "s/.*addr://g" |sed "s/Bcast.*//g" |sed -n "2p" |awk -F. '{print $1"."$2"."$3}')
b=$(ifconfig eth0 |sed "s/.*addr://g" |sed "s/Bcast.*//g" |sed -n "2p" |awk -F. '{print $3"."$2"."$1}')
c=$(hostname |awk -F. '{print $2"."$3}')
d=$(ifconfig eth0 |sed "s/.*addr://g" |sed "s/Bcast.*//g" |sed -n "2p" |sed 's/ //g')
e=$(ifconfig eth0 |sed "s/.*addr://g" |sed "s/Bcast.*//g" |sed -n "2p" |awk -F. '{print $4}')
f=$(ifconfig eth0 |sed 's/.*Mask://g' |sed -n '2p')
sed -i 's/id:.:initdefault:/id:3:initdefault:/g' /etc/inittab
sed -i 's/^SELINUX\=.*$/SELINUX\=disabled/g' /etc/sysconfig/selinux
yum install -y bind bind-chroot &> /dev/null
cp /usr/share/doc/bind-9.3.6/sample/etc/named.conf /var/named/chroot/etc/
cat << END > /var/named/chroot/etc/named.conf
options {
directory "/var/named";
};
zone "$c" IN {
type master;
file "$c.zone";
allow-update { none; };
};
zone "$b.in-addr.arpa" IN {
type master;
file "$a.local";
allow-update { none; };
};
END
cat << END > /var/named/chroot/var/named/$c.zone
\$TTL 86400
@ IN SOA dns.$c. root.$c. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS dns.$c.
dns IN A $d
www IN A $d
\$GENERATE 152-158 www$ IN A $a.$
END
cat << END > /var/named/chroot/var/named/$a.local
\$TTL 86400
@ IN SOA dns.$c. root.$c. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS dns.$c.
$e IN PTR dns.$c.
$e IN PTR
\$GENERATE 152-158 $ IN PTR www$.$c.
END
cp /tftpboot/linux-install/pxelinux.0 /tftpboot/ &> /dev/null
mkdir -pv /tftpboot/pxelinux.cfg &> /dev/null
cp /mnt/cdrom/isolinux/vmlinuz /tftpboot/
cp /mnt/cdrom/isolinux/initrd.img /tftpboot/
cp /mnt/cdrom/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
yum install -y httpd &> /dev/null
mkdir -pv /var/www/html/iso &> /dev/null
mount /dev/hdc /var/www/html/iso &> /dev/null
yum install -y dhcp &> /dev/null
cat << END > /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
subnet $a.0 netmask $f {
option domain-name-servers $d;
option time-offset -18000;
range dynamic-bootp $a.152 $a.158;
default-lease-time 21600;
max-lease-time 43200;
next-server $d;
filename "pxelinux.0";
}
END
cat << END > /var/www/html/ks.cfg
auth --useshadow --enablemd5
bootloader --location=mbr
zerombr
clearpart --all --initlabel
text
key --skip
firewall --disabled
firstboot --disable
keyboard us
lang en_US
logging --level=info
url --url=
network --bootproto=dhcp --device=eth0 --onboot=on
reboot
rootpw --iscrypted \$1\$hxf0CEJw\$gRHbtDIsZpdqbhxYMz9Jz.
selinux --disabled
timezone Asia/Shanghai
install
part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100
part / --bytes-per-inode=4096 --fstype="ext3" --size=20480
part swap --bytes-per-inode=4096 --fstype="swap" --size=1024
%post
wget -O /etc/yum.repos.d/local.repo
yum install httpd -y
chkconfig httpd on
%packages
@chinese-support
END
cat << END > /var/www/html/local.repo
[base]
name=base
baseurl=/Server
enabled=1
gpgcheck=0
END
cat << END > /tftpboot/pxelinux.cfg/default
default ks
prompt 1
timeout 1
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
kernel vmlinuz
append initrd=initrd.img
label text
kernel vmlinuz
append initrd=initrd.img text
label ks
kernel vmlinuz
append ks= initrd=initrd.img
label local
localboot 1
label memtest86
kernel memtest
append -
END
/etc/init.d/httpd restart
/etc/init.d/named restart
/etc/init.d/xinetd restart
/etc/init.d/dhcpd restart
阅读(1749) | 评论(0) | 转发(0) |