当前位置:网站首页>Shell: one click deployment PXE
Shell: one click deployment PXE
2022-07-28 03:26:00 【IT.cat】
shell Scripts can bring us a lot of convenience , Here I write a one click deployment pex Of shell Script
One 、 Front operation

Add a network card and change it to net1 Pattern
Two 、 Modify some parameters of the script
Check the name of your new network card , I am here ens36
And change the ip It's worth it and dhcp In the configuration file IP Value and /var/lib/tftpboot/pxelinux.0/default Direction in ftp The address is OK , All changed to the same
If you really don't understand it, you can see that my other blog has detailed instructions :
PXE&&kickstart Principle and configuration _IT.cat The blog of -CSDN Blog
#!/bin/bash
#==========================================================================
# User yz
# PEX One key deployment
# date 2022.7.26
#==========================================================================
################### Turn off firewall #############################
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
##################### Configure network card #############################
cp /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens36
sed -i '/GATEWAY/s/^/#/' /etc/sysconfig/network-scripts/ifcfg-ens36 # You need to modify the network card name
sed -i 's/ens33/ens36/' /etc/sysconfig/network-scripts/ifcfg-ens36
sed -i '/UUID/s/^/#/' /etc/sysconfig/network-scripts/ifcfg-ens36
sed -i '/DNS/s/^/#/' /etc/sysconfig/network-scripts/ifcfg-ens36
sed -i 's/192.168.130.152/192.168.59.100/' /etc/sysconfig/network-scripts/ifcfg-ens36
# ^^ Need modification IP Address
systemctl restart network
################### Install the software ###############################
# Detection network
ping -c 1 -i 0.1 www.baidu.com > /dev/null
if [ $? -eq 0 ]
then
yum -y install vsftpd tftp xinetd dhcpd syslinux tftp-server > /dev/null
################# To configure dhcp service ##########################
cp -f /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf
echo "ddns-update-style none;
subnet 192.168.59.0 netmask 255.255.255.0 { # It also needs to be modified to the same network segment as the new network card
range 192.168.59.110 192.168.59.200;
option routers 192.168.59.100;
option domain-name-servers 114.114.114.114;
next-server 192.168.59.100;
filename\"pxelinux.0\";
} " >> /etc/dhcp/dhcpd.conf
################## To configure tftp service ##########################
sed -i '/disable/s/yes/no/' /etc/xinetd.d/tftp
################## To configure tftp Required shared files ########################
mount /dev/cdrom /mnt
cp /mnt/images/pxeboot/initrd.img /var/lib/tftpboot
cp /mnt/images/pxeboot/vmlinuz /var/lib/tftpboot
################# Get ready pxe Boot image file #######################
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot
################# Manual configuration dafault Menu file ##################
mkdir /var/lib/tftpboot/pxelinux.cfg
touch /var/lib/tftpboot/pxelinux.cfg/default
echo " default auto
prompt 0 #ftp The direction of IP Need to change to a new network card IP
label auto
kernel vmlinuz
append initrd=initrd.img method=ftp://192.168.59.100/centos7 ks=ftp://192.168.59.100/ks.cfg
label linux text
kernel vmlinuz
append text initrd=initrd.img method=ftp://192.168.59.100/centos7 ks=ftp://192.168.59.100/ks.cfg
label linux rescue
kernel vmlinuz
append rescue initrd=initrd.img method=ftp://192.168.59.100/centos7 ks=ftp://192.168.59.100/ks.cfg " >> /var/lib/tftpboot/pxelinux.cfg/default
################## To configure ftp, Get ready centos Install source ##############
mkdir /var/ftp/centos7
cp -rf /mnt/* /var/ftp/centos7
################# Configure unattended ######################
# First configure unattended , Then execute the script
yum -y install system-config-kickstart > /dev/null # install system-config-kickstart Tools
################# Opening service ############################# vsftpd tftp xinetd dhcpd
systemctl start vsftpd tftp xinetd dhcpd
else
echo " There is a problem with the network and cannot be installed , Can't go on to the next step "
fi
After configuration, you need to configure unattended , The previous blog here also explains in detail how to configure , You can directly follow kickstart That section starts to configure
PXE&&kickstart Principle and configuration _IT.cat The blog of -CSDN Blog
After configuring unattended, we can ks.cfg Keep the file , In the future, you don't need to configure the unattended operation alone again, just pull the file directly

verification
The verification method is also detailed in my last blog It is mainly to create virtual machines and unattended file storage locations
Here is a direct demonstration of the process after execution


Just wait here , It will take a long time , Be patient
边栏推荐
- 光年(Light Year Admin)后台管理系统模板
- Win11黑色桌面背景如何解决?
- 20 soul chicken soup beautiful sentences, sentence by sentence warm heart!
- Talk about the speech synthesis function of Baidu University of science and technology news Feiyun Zhisheng
- ThreadLocal使用场景
- Four methods of closing forms in C #
- 基于OpenCV的轮廓检测(3)
- max_ pool2d(): argument ‘input‘ (position 1) must be Tensor, not NoneType
- What is a virtual function?
- [R language] environment specifies to delete RM function
猜你喜欢

Redis内存回收

Leaf recognition, color feature extraction, defect detection, etc

My approval of OA project (meeting inquiry & meeting signature)

Web server

IronOCR for .NET 2022.8

4天Excel实战训练营,0.01元特惠仅三天,赠200套学习资料包

Industry insight | is speech recognition really beyond human ears?

MySQL事务的ACID特性及并发问题实例分析

Uniapp——拨打电话、发送短信

“讳疾忌医”的开源走不远
随机推荐
Random forest and integration method learning notes
MySQL的碎片有哪些
[acwing 1064 little king] shaped pressure DP
Brush questions every day to consolidate knowledge
关于湖北文理学院平衡信标组的疑问回应
Win11黑色桌面背景如何解决?
Win11输入法的选字框不见了怎么办?
RBD块存储设备的扩容以及缩容操作(六)
[2022 Niuke Game 2 J question link with arithmetic progress] three part set three part / three part extreme value / linear equation fitting least square method
golang gorm查询任意字段的组装方法
自定义注解的使用
数据湖(十七):Flink与Iceberg整合DataStream API操作
Exness: Japanese prices rose and incomes fell, with the pound / yen breaking 165
Leetcode 208. implement trie (prefix tree) (2022.07.27)
Color recognition method and exploration based on MATLAB
STM32之IO模拟串口篇
上位机与MES对接的几种方式
傅里叶级数
Shell编写规范和变量
超好看的Nteam官网PHP程序源码