#!/bin/bash # -*- coding: utf-8 -*- # # dfkp5.sh # # Copyright 2012 wanghui <hwang@runner> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. # # #声明全局变量 #网络网段 NET=`ifconfig eth0 | grep 'inet addr' | awk '{print $2}' | awk -F: '{print$2}' |cut -d. -f1,2,3` #pxe服务器主机ip SER_IP=`ifconfig eth0 | grep 'inet addr' | awk '{print $2}' | awk -F: '{print$2}'` #dhcp服务分配的起始ip STA_IP="$NET.10" #dhcp服务分配的结束ip END_IP="$NET.100" #子网掩码 NETMASK=`ifconfig eth0 | grep Mask |awk -F: '{print $4}'` ROUTE=`route | grep default | awk '{print $2}'` # #配置本地yum服务 # #判断yum服务是否安装 rpm -qa | grep yum >& /dev/null if [ $? -eq 1 ] then echo "yum is not installed! please install yum." else echo "yum is installed!" fi #判断使用光盘还是iso文件做安装镜像 echo "-----------------------------------" echo "1) use cdrom " echo "2) use iso file" echo "q) exit" echo echo -n "Please Enter a Installation method:" read MET case $MET in 1)echo "you slect cdrom install operationg system!" echo -e "\033[31m Please insert your cdrom.... \033[0m" sleep 20 mount -r /dev/cdrom /mnt >& /dev/null mount -r /dev/cdrom /var/ftp/pub >& /dev/null ;; 2)echo "you slect iso file install operationg system!" echo -n "Please input you file path:" read ISOF mount -o loop $ISOF /mnt >& /dev/null mount -o loop $ISOF /var/ftp/pub >& /dev/null ;; q)echo "quit!" exit 0 ;; *)echo "Please slect 1|2|q" exit 1 ;; esac #配置yum服务的本地yum源 cat <<EOF >/etc/yum.repos.d/server.repo [base] name=base baseurl=file:///mnt/Server/ enabled=1 gpgcheck=0 EOF #清除yum源的缓存 yum clean all yum list >& /dev/null if [ $? -eq 0 ] then echo "YUM 服务配置成功!" fi # #判断是否安装了相关软件 # for RPM in vsftpd tftp tftp-server system-config-kickstart do rpm -qa | grep $RPM >& /dev/null if [ $? -eq 1 ] then echo "$RPM is not installed!" yum install -y $RPM #>& /dev/null if [ $? -eq 0 ] then echo -e "\033[32m$RPM 已安装成功!\033[0m" else echo -e "\033[31m$RPM 安装失败!\033[0m" fi else echo -e "\033[34m$RPM is installed!\033[0m" fi done # #配置vsftp服务 # #配置ks.cfg文件 system-config-kickstart KSCFG=/var/ftp/ks.cfg cp -rf ks.cfg $KSCFG cat postshell >>$KSCFG sed -i '/^# System language/i key --skip' $KSCFG sed -i "s/serverip/${SER_IP}/g" $KSCFG /etc/init.d/vsftpd restart # #配置tftp服务 # TFTP='/etc/xinetd.d/tftp' TMP_TFTP="/tmp/tmp.$$" sed -i '/disable/s/yes/no/' $TFTP #mv -f $TMP_TFTP $TFTP PXE='/usr/lib/syslinux/pxelinux.0' ISO='/mnt/isolinux/isolinux.cfg' IMG='/mnt/p_w_picpaths/pxeboot/initrd.img' VML='/mnt/p_w_picpaths/pxeboot/vmlinuz' DEFT='/tftpboot/pxelinux.cfg/default' mkdir /tftpboot/pxelinux.cfg cp $PXE /tftpboot/ cp $ISO $DEFT cp $IMG /tftpboot/ cp $VML /tftpboot/ chmod 644 $DEFT sed -i "3s/600/1/;12d;11 a\ append initrd=initrd.img ks=ftp://$SER_IP/ks.cfg" $DEFT /etc/init.d/xinetd restart # #配置dhcp服务 # yum install -y dhcp DHCP='/etc/dhcpd.conf' TMP_DHCP="/tmp/tmp.$$" cat <<EOF >$DHCP ddns-update-style interim; ignore client-updates; subnet $NET.0 netmask $NETMASK { option routers $ROUTE; option subnet-mask $NETMASK; filename="pxelinux.0"; next-server $SER_IP; range dynamic-bootp $STA_IP $END_IP; default-lease-time 21600; max-lease-time 43200; } EOF #mv -f $TMP_DHCP $DHCP /etc/init.d/dhcpd restart # #系统安全设置 # iptables -F service iptables save service iptables stop setenforce 0 # #配置NFS # mkdir /sharedata echo "/sharedata *(sync,rw)">/etc/exports service nfs restart
rhel5+dhcp+vsftp+pxe+tftp+kickstart环境配置脚本
原创
©著作权归作者所有:来自51CTO博客作者kitsnail的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
PXE+TFTP+VSFTP+DHCP+Kickstart无人职守自动安装RHEL5
PXE+TFTP+VSFTP+DHCP+Kickstart无人职守自动安装RHEL5。
DHCP 休闲 PXE TFTP Kickstart无人职守自动安装RHE -
PXE+NFS+DHCP+TFTP+KICKSTART自动安装
1需要的软件tftp-server NFS DHCP 三个文件均可yum -y install xxx*安装即可
linux 系统安装 dhcp 休闲 pxe -
Kickstart+PXE+DHCP+TFTP+NFS自动安装Centos5
Kickstart+PXE+DHCP+TFTP+NFS自动安装Centos5
职场 休闲 centos kickstart centos