#安装前配置好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. CF1158C

    题意:有排列p, 令\(nxt_i\)为\(p_i\)右侧第一个大于\(p_i\)的数的位置,若不存在则\(nxt_i=n+1\) 现在整个p和nxt的一部分丢失了,请根据剩余的nxt,构造出一个符合 ...

  2. Failed! Error: Unknown error 1130

    如有需要可以加我Q群[308742428]大家一起讨论技术,有偿服务. 后面会不定时为大家更新文章,敬请期待. 喜欢的朋友可以关注下. 在使用navicat远程连接mysql报了一个错误信息 Fail ...

  3. Lock中使用Condition实现等待通知

    Condition类有很好的灵活性,可以实现多路通知功能,一个Lock对象中可以创建多个Condition对象实例,线程对象可以注册在指定的Condition中,进而有选择的进行线程通知,在调度线程上 ...

  4. 2018-2-13-win10-uwp-hashcash

    title author date CreateTime categories win10 uwp hashcash lindexi 2018-2-13 17:23:3 +0800 2018-2-13 ...

  5. es的日期格式

    https://www.elastic.co/guide/en/elasticsearch/reference/2.3/mapping-date-format.html 在es中,默认的时间类型为da ...

  6. c# 通过地址下载流然后保存文件到本地

    1.下载文件并保存文件到本地 private void GetFileFromNetUrl(string url) { try { System.Net.WebRequest req = System ...

  7. leetcood学习笔记-26-删除排序数组中的重复项

    题目描述: 第一次提交: class Solution: def removeDuplicates(self, nums) -> int: for i in range(len(nums)-1, ...

  8. OpenSearch最新功能介绍

    摘要:阿里云开放搜索(OpenSearch)是一款结构化数据搜索托管服务,其能够提供简单.高效.稳定.低成本和可扩展的搜索解决方案.OpenSearch以平台服务化的形式,将专业搜索技术简单化.低门槛 ...

  9. 强制位(set uid和set gid)与冒险位(sticky)的作用都有什么

    1.set uid(强制位) 只能对文件进行设置 通过对文件设置uid可以使非文件拥有者或文件所属群组的用户具有执行该文件的权限. 例如ping,默认情况下所有用户都可以使用此命令,但当我们查看pin ...

  10. BZOJ 2005: [Noi2010]能量采集(容斥+数论)

    传送门 解题思路 首先题目要求的其实就是\(\sum\limits_{i=1}^n \sum\limits_{j=1}^m [(gcd(i,j)-1)*2+1)]\),然后变形可得\(-n*m+2\s ...