#安装前配置好centos和epel yum源
#网卡ip和localip一致
localip="192.168.88.200"
eth_name='eth0' dnsmasq_install() {
yum -y install dnsmasq
mv /etc/dnsmasq.conf /etc/dnsmasq.conf.backup
prefix_ip=`echo $localip|awk -F\. '{print $1"."$2"."$3}'`
dnsmasq_conf='interface='$eth_name'
#bind-interfaces
domain=centos7.lan
# DHCP range-leases
dhcp-range= '$eth_name','$prefix_ip'.,'$prefix_ip'.,255.255.255.0,1h
# PXE
dhcp-boot=pxelinux.,pxeserver,'$localip'
# Gateway
dhcp-option=,'$localip'
# DNS
dhcp-option=,'$localip',114.114.114.114
server=114.114.114.114
# Broadcast Address
dhcp-option=,'$prefix_ip'.
# NTP Server
dhcp-option=,0.0.0.0 pxe-prompt="Press F8 for menu.",
pxe-service=x86PC,"Install CentOS 7 from network server '$localip'", pxelinux
enable-tftp
tftp-root=/var/lib/tftpboot'
echo "$dnsmasq_conf" > /etc/dnsmasq.conf
}
tftp_pxe_install() {
yum -y install syslinux
yum -y install tftp-server
cp -r /usr/share/syslinux/* /var/lib/tftpboot/
if [[ ! -d /var/lib/tftpboot/pxelinux.cfg ]]
then
mkdir /var/lib/tftpboot/pxelinux.cfg
touch /var/lib/tftpboot/pxelinux.cfg/default
default_conf='default menu.c32
prompt 0
timeout 300
ONTIMEOUT local menu title ########## PXE Boot Menu ########## label 1
menu label ^1)InstallCentOS7 x64 withLocalRepo
kernel centos7/vmlinuz
append initrd=centos7/initrd.img method=ftp://'$localip'/pub devfs=nomount label 2
menu label ^2)InstallCentOS7 x64 with http://mirror.centos.org Repo
kernel centos7/vmlinuz
append initrd=centos7/initrd.img method=http://mirror.centos.org/centos/7/os/x86_64/ devfs=nomount ip=dhcp label 3
menu label ^3)InstallCentOS7 x64 withLocalRepousing VNC
kernel centos7/vmlinuz
append initrd=centos7/initrd.img method=ftp://'$localip'/pub devfs=nomount inst.vnc inst.vncpassword=password label 4
menu label ^4)Bootfromlocal drive'
echo "$default_conf" > /var/lib/tftpboot/pxelinux.cfg/default
fi
}
mount_cd() {
mount|grep '^/mnt'
if [[ $? -eq 0 ]]
then
echo '光盘已挂载。'
else
mount /dev/sr0 /mnt/ &> /dev/null
if [[ $? -ne 0 ]]
then
count=$(( $count + 1 ))
if [[ $count -eq 20 ]];then
echo '超时退出';
exit 8;
fi
echo "sr0没有光盘,挂载失败,将在5秒后重试"
sleep 5
mount_cd
else
echo '光盘挂载成功。';
fi
fi
}
confing_pxeserver() {
if [[ ! -d /var/lib/tftpboot/centos7 ]];then
mkdir /var/lib/tftpboot/centos7
cp /mnt/images/pxeboot/vmlinuz /var/lib/tftpboot/centos7/
cp /mnt/images/pxeboot/initrd.img /var/lib/tftpboot/centos7/
fi
yum -y install vsftpd
if [[ `ls -A /var/ftp/pub/` == "" ]];then
echo 'copy光盘文件到/var/ftp/pub/ ...';
cp -r /mnt/* /var/ftp/pub/
chmod -R 755 /var/ftp/pub
fi
}
start_service() {
systemctl start dnsmasq
systemctl status dnsmasq
systemctl start vsftpd
systemctl status vsftpd
systemctl enable dnsmasq
systemctl enable vsftpd
} dnsmasq_install
tftp_pxe_install
mount_cd
confing_pxeserver
start_service

Centos7 PXE Server Install Script的更多相关文章

  1. centos7 pxe minimal install

    # 01-78-2b-cb-69-10-f3 default menu.c32 prompt 0 timeout 50 label CentOS 7 MENU DEFAULT MENU LABEL C ...

  2. CentOS7 PXE安装批量安装操作系统

    1.安装相关软件 yum -y install tftp-server httpd dhcp syslinux 2.配置DHCP cp /usr/share/doc/dhcp-4.2.5/dhcpd. ...

  3. Tiny PXE Server简介

    Tiny PXE Server简介Tiny PXE Server是一款小巧而功能强大的网启软件.支持DHCP TFTP HTTP BINL DNS等多个协议,支持grub4dos,pxelinux,i ...

  4. 当你碰到一个网络中有多个PXE Server 肿么办?

    今天在用PXE 安装Openstack Compute节点时,郁闷得发现同一网段中还有一个PXE Server,而我的Compute 启动起来总会先找到它,但那个设置不受我控制,子网也不归我管,那个s ...

  5. Cloudinsight Agent install script

    #!/bin/bash # Cloudinsight Agent install script. set -e logfile="ci-agent-install.log" gis ...

  6. webpacke install vue application 报错 Failed at the phantomjs-prebuilt@2.1.14 install script

    刚刚在网上下了个开源的项目: https://github.com/ing670/webappkiller 执行npm install 报错:npm ERR! Failed at the phanto ...

  7. 自动化安装操作系统(Centos7+PXE+Cobbler+kickstart)

    一.简介 PXE称作是一种引导方式而不是安装方式似乎更加准确,PXE(Pre-boot Execution Environment)是由Intel设计的协议,它可以使计算机通过网络启动,但是有一个前提 ...

  8. Centos7 pxe

    yum install dnsmasq mv /etc/dnsmasq.conf /etc/dnsmasq.conf.backup # vim /etc/dnsmasq.conf interface= ...

  9. samba server install

    要求: create vnc service for win7 access it via vnc viewer. 1TB disk for this Centos PC is used as Sam ...

随机推荐

  1. 如何安装python运行环境Anaconda

    参考视频:https://v.qq.com/x/page/u05499rig9s.html

  2. nuxt项目在windows环境下安装部署

    1.nodejs安装,地址 https://nodejs.org/en/ 2.在本地项目中运行npm  run build  命令将开发好的项目打包生成.nuxt文件夹,然后把.nuxt文件夹.nux ...

  3. 代理-jdk动态代理

    1.基于接口的实现,要jdk动态代理的类必须要实现一个接口: 2.中介类:实现了InvocationHandler,并重写这个接口的 方法(public Object invoke(Object pr ...

  4. logging自定义模板

    import logging logger=logging.getLogger('这是一个日志')#先生成一个日志 formatter=logging.Formatter('%(asctime)s % ...

  5. 【Jquery对象】jquery与dom对象的区别

    最近工作有很多判断的代码,用到了jquery与dom对象的地方比较多,写在这里加强下基本概念: 1.判断是否存在时候,要用dom对象,因为jQuery在获得对象的时候,无论要获得的对象是否存在,都会返 ...

  6. Android蓝牙自动配对Demo,亲测好使!!!(转)

    蓝牙自动配对,即搜索到其它蓝牙设备之后直接进行配对,不需要弹出配对确认框或者密钥输入框. 转载请注明出处http://blog.csdn.net/qq_25827845/article/details ...

  7. 【LeetCode】Heap

    [215] Kth Largest Element in an Array [Medium] 给个无序数组,返回第K大的数字. 方法1. 直接使用优先队列 priority_queue class S ...

  8. 微信小程序分享功能的path路径

    表示被微信小程序坑惨了 糟心的开始写,老板说先不上太复杂,就先显示了两个页面,然后开开心心的发布,测试了几遍,没啥问题呀.结果,一上上去,就被老板批了! 啥呀! 这分享怎么这个鬼样子!明明我看文档都是 ...

  9. Django之template操作

    一.模板渲染的原理 (一)使用 模板渲染首先有一个模板对象Template,然后有一个上下文对象Context,通过render方法进行渲染,最后返回字符串,render方法的本质还是调用了HttpR ...

  10. MySQL中可能遇到的问题及解决方法

    一.在创建存储函数时,出现错误: ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQLDA ...