#安装前配置好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. sleep()方法和wait()方法的区别? sleep()方法和yield()方法的区别?

    sleep()方法和wait()方法的区别? sleep方法是Thread的静态方法,wait方法是Object类的普通方法 sleep方法不释放同步锁,wait方法释放同步锁(执行notify方法唤 ...

  2. 小程序图片在安卓上拉伸的问题&导航&返回首页

      今天提了一个bug,有几张图片在安卓上面加载会先变大拉伸再恢复正常 出现这样的问题应该是用widthFix造成的 具体原因还不是很清楚,因为都是本地图片,所以我就直接把高也设置好就暂时没有这个问题 ...

  3. Zabbix搭建部署与概述(一)

    搭建部署与概述(一) 链接:https://pan.baidu.com/s/1q5YwJMTcZLcS5OQ0iOu44A 提取码:8gdi 复制这段内容后打开百度网盘手机App,操作更方便哦 1. ...

  4. vue 数字输入组件

    index.html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> &l ...

  5. SCP-bzoj-1078

    项目编号:bzoj-1078 项目等级:Safe 项目描述: 戳这里 特殊收容措施: 斜堆有一个著名的性质:如果一个节点没有左子树,则它一定没有右子树,这也是它“斜堆”名称的由来. 此题通过给出斜堆来 ...

  6. java EE学习流程(第二版更新)

    这周有点堕落了,这两天啥都没写,就顾上刷<庆余年>了

  7. Educational Codeforces Round 64 (Rated for Div. 2) (线段树二分)

    题目:http://codeforces.com/contest/1156/problem/E 题意:给你1-n  n个数,然后求有多少个区间[l,r] 满足    a[l]+a[r]=max([l, ...

  8. SQL语句常用优化技巧

    提高SQL语句的执行效率,最常见的方法就是建立索引,以及尽量避免全表扫描. ①.避免在where子句中使用 is null 或 is not null 对字段进行判断. 如:select id fro ...

  9. 2019 wannafly winter camp day5-8代码库

    目录 day5 5H div2 Nested Tree (树形dp) 5F div2 Kropki (状压dp) 5J div1 Special Judge (计算几何) 5I div1 Sortin ...

  10. 动态栈-------C语言

    使用带头结点的单链表实现 主要使用链表中的头插来实现栈的先进后出的特点 /***************************************************** Author:Si ...