#安装前配置好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. CSUST 集训队选拔赛题解

    选拔赛的题解,~~~ 题目链接:请点击 A题 素数筛 + 线段树(树状数组) 先用素数筛打表,然后线段树更新,遍历求出值,O(1)查询即可 AC代码: /*num数组 是把记录 数是否存在 存在即为1 ...

  2. 解决码云未配置公钥问题——fatal: Could not read from remote repository.

    使用码云,键入“git push -u origin master” ,遇到如下问题: fatal: Could not read from remote repository.(致命:不能读远端仓库 ...

  3. Linux 登录、注销与关机

    Linux 登录.注销与关机 这里主要学习的是命令行环境下的相关操作. 一.登录 Linux 默认的情况下会提供六个终端来让用户登录,切换的方式为使用:[Ctrl + Alt + F1 ~ F6]的组 ...

  4. 服务注册与发现---spring cloud

    Eureka基本架构 Register Service :服务注册中心,它是一个 Eureka Server ,提供服务注册和发现的功能. Provider Service :服务提供者,它是 Eur ...

  5. 08-03-re-模块

    一组特殊符号组成的表达式,用于描述某种规则.该应用场景生活中随处可见. ​ 例如:让有志青年过上体面的生活,这里面就由规则,即有志青年. 正则表达式的作用,以及使用场景 ​ 1.用于从字符串中匹配满足 ...

  6. vue 运行项目时,Uncaught (in promise) DOMException: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL

    npm  run dev 运行项目后 验证码显示不出来 并报错 Uncaught (in promise) DOMException: Failed to execute 'open' on 'XML ...

  7. Vuex 常规用法

    背景 很多时候我们已经熟悉了框架的运用,但是有时候就是忘了怎么用 所以这里想记下大部分的框架使用方法,方便使用的时候拷贝 一.安装 npm 方式 npm install vuex --save yar ...

  8. Mac版本navicat premium彻底卸载的终端命令

    Mac版本navicat premium彻底卸载的终端命令: sudo rm -Rf /Applications/Navicat\ Premium.app sudo rm -Rf /private/v ...

  9. 三:robotframework框架配合selenium之jquery定位

    RF框架我用的比较多,限于自己的代码水平,目前工作中一直是用RF框架.unittest框架,我也练习了很久,还差一点封装的技巧与设计模式的学习.所以不敢在项目中实践. 等明年我的代码水平再上升一个台阶 ...

  10. ()centos7 安装mysql8.0

    一.下载mysql 1 .下载 https://dev.mysql.com/downloads/repo/yum/ wget http://repo.mysql.com/mysql80-communi ...