PXE自动装机脚本原创代码(适合脚本新人)
#!/bin/bash
#===========================================================================
FileName: PXEauto.sh
Auother : WangXinKun
Created : 13:31,31/07/2019
#===========================================================================
echo “=Oo欢迎使用阿坤脚本,祝您使用愉快oO=”
a=!
yum -y install httpd &>/dev/null
rpm -q httpd &>/dev/null &&
mkdir /var/www/html/centos
mount /dev/cdrom /var/www/html/centos &>/dev/null && echo -e “* I.Web服务------------------------\033[33m[ready$a]\033[0m *”
#yum -y install system-config-kickstart &>/dev/null
#rpm -q system-config-kickstart &>/dev/null &&
echo "#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
Install OS instead of upgrade
install
Keyboard layouts
keyboard ‘us’
Root password
rootpw --iscrypted 1 1 1zjCK.pRB$k38r54VUUMegOfFgK8KND/
Use network installation
url --url=“http://192.168.4.7/centos”
System language
lang en_US
System authorization information
auth --useshadow --passalgo=sha512
Use graphical install
graphical
firstboot --disable
SELinux configuration
selinux --disabled
Firewall configuration
firewall --disabled
Network information
network --bootproto=dhcp --device=eth0
Reboot after installation
reboot
System timezone
timezone Asia/Shanghai
System bootloader configuration
bootloader --location=mbr
Clear the Master Boot Record
zerombr
Partition clearing information
clearpart --all --initlabel
Disk partitioning information
part / --fstype=“xfs” --grow --size=1
%packages
@base
%end" > /var/www/html/ks.cfg && echo -e “* II.Ks应答文件--------------------\033[33m[ready$a]\033[0m *”
yum -y install tftp-server &>/dev/null
rpm -q tftp-server &>/dev/null &&
yum -y install syslinux &>/dev/null
rpm -q syslinux &>/dev/null &&
cd /var/www/html/centos/isolinux
\cp -p /usr/share/syslinux/pxelinux.0 vmlinuz splash.png vesamenu.c32 initrd.img /var/lib/tftpboot/
cd /var/lib/tftpboot/
mkdir pxelinux.cfg
echo "default vesamenu.c32
timeout 600
display boot.msg
Clear the screen when exiting the menu, instead of leaving the menu displayed.
For vesamenu, this means the graphical background is still displayed without
the menu itself for as long as the screen remains in graphics mode.
menu clear
menu background splash.png
menu title WangXinKun1.0
menu vshift 8
menu rows 18
menu margin 8
#menu hidden
menu helpmsgrow 15
menu tabmsgrow 13
Border Area
menu color border * #00000000 #00000000 none
Selected item
menu color sel 0 #ffffffff #00000000 none
Title bar
menu color title 0 #ff7ba3d0 #00000000 none
Press [Tab] message
menu color tabmsg 0 #ff3a6496 #00000000 none
Unselected menu item
menu color unsel 0 #84b8ffff #00000000 none
Selected hotkey
menu color hotsel 0 #84b8ffff #00000000 none
Unselected hotkey
menu color hotkey 0 #ffffffff #00000000 none
Help text
menu color help 0 #ffffffff #00000000 none
A scrollbar of some type? Not sure.
menu color scrollbar 0 #ffffffff #ff355594 none
Timeout msg
menu color timeout 0 #ffffffff #00000000 none
menu color timeout_msg 0 #ffffffff #00000000 none
Command prompt text
menu color cmdmark 0 #84b8ffff #00000000 none
menu color cmdline 0 #ffffffff #00000000 none
Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message.
menu tabmsg Press Tab for full configuration options on menu items.
menu separator # insert an empty line
menu separator # insert an empty line
label linux
menu label ^Install CentOS 7
menu default
kernel vmlinuz
append initrd=initrd.img ks=http://192.168.4.7/ks.cfg" > pxelinux.cfg/default && echo -e “* III.TFTP服务---------------------\033[33m[ready$a]\033[0m *”
yum -y install dhcp &>/dev/null
rpm -q dhcp &>/dev/null &&
echo '#
DHCP Server Configuration file.
see /usr/share/doc/dhcp*/dhcpd.conf.example
see dhcpd.conf(5) man page
subnet 192.168.4.0 netmask 255.255.255.0 {
range 192.168.4.100 192.168.4.200;
option domain-name-servers 192.168.4.7;
option routers 192.168.4.254;
default-lease-time 600;
max-lease-time 7200;
next-server 192.168.4.7;
filename “pxelinux.0”;
}’ > /etc/dhcp/dhcpd.conf && echo -e “* IV.DHCP服务----------------------\033[33m[ready$a]\033[0m *”
if [ KaTeX parse error: Expected 'EOF', got '\0' at position 56: …d || echo -e "\̲0̲33[31mNo\033[0m…a\033[0m "
systemctl enable httpd &>/dev/null
systemctl restart tftp || echo -e “\033[31mNo\033[0m” && echo -e " \033[35mTftp.service up SuccessfullyKaTeX parse error: Expected 'EOF', got '\0' at position 2: a\̲0̲33[0m …a\033[0m *"
systemctl enable dhcpd &>/dev/null
echo -e "* \033[33mAll Service up Successfully$a$a\033[0m *"
else
echo -e “\033[31mError 604:Failed.Service a a aa$a\033[0m” >&2
exit 1
fi
echo “* --------配置部署完成 !-------- *”
echo "==期待您的再次使用!!= "
运行结果如下图:
PXE自动装机脚本原创代码(适合脚本新人)相关推荐
- yum仓库与pxe自动装机
YUM仓库服务与PXE网络装机 前言: 1.前面我们安装软件主要使用rpm和源码编译安装,尤其在rpm安装软件的时候有些软件需要依赖关系,安装起来非常麻烦,今天讲的YUM仓库安装,可以自动解决依赖关系 ...
- YUM和PXE自动装机
PXE(预启动执行环境)是由inter公司开发的技术,可以让计算机通过网络来启动操作系统(前提是网卡支持pxe技术),主要用于在无人值守安装系统中引导客户端主机安装linux操作系统,kickstar ...
- Linux网络项目实验------网络架构(DNS域名解析、NFS共享服务、LAMP服务、搭建论坛、PXE自动装机)
实验 环境描述: 客户端:无任何系统的裸金属机器 DNS:192.168.10.10/24 提供DNS域名解析 PXE:192.168.10.20/24 提供DHCP,TFTP,FTP功能,DHCP地 ...
- xshell脚本简单代码_Xshell脚本
Xshell 常见脚本编译细节问题 #! /bin/bash 指令下 1.关于 test命令后面空格 2.if语句后面 then前的分号 调试有时不可省略 3.参数分隔的空格问题不可忽略!不可缺少! ...
- PXE自动化装机(4)
一.PXE概述 PXE(preboot execute environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持工作站通过网络从远端服 ...
- 用shell写了一个自动编译代码的脚本
点击打开链接 为了充分利用晚上的时间进行编译,用shell写了一个自动编译代码的脚本,这样保证第二天的调试工作不会受大版本编译的影响,同时也能监测服务器端的代码是否出错.我习惯是在每天下班离开之前运行 ...
- 点下按钮后自动跳转html代码,js实现网页跳转脚本
为什么要写这个脚本 生活中很多时候会经常登录一个论坛或者网页 但是每次打开浏览器都要输一遍网址,或者点开收藏的书签 这样远远不如在桌面上打开文件点两下快,还能装X,多好 前提条件 需要会一些基础的ht ...
- AI写文章软件盘点,一键生成代码、脚本、论文、作文
AI写文章软件盘点,一键生成代码.脚本.论文.作文!这些现代化的内容创作工具必将给你个性化.高质量和高效率的内容创作带来前所未有的便利和快捷体验. AI写文章软件盘点,一键生成代码.脚本.论文.作文: ...
- bat自动输入密码登录_如何制作自动设置计算机管理员密码的脚本
如何制作自动设置计算机管理员密码的脚本 首先新建一个txt文档,输入以下代码 @echo offecho 更改管理员administrator密码net user administrator /act ...
最新文章
- Bit-Z图解“推荐返佣”那些事儿
- 深度学习笔记:卷积神经网络的Tensorflow实现
- JS----Ajax中XMLHttpRequest常用方法及属性
- 301. Remove Invalid Parentheses
- 前端那些事之Nuxt.js
- 《算法导论》读书笔记之第10章 基本数据结构之二叉树
- SPSS 协方差分析(图文+数据集)【SPSS 020期】
- 数据结构与算法C语言版—— 数据结构的详细介绍
- 编写一个python程序输出如下图形_第二章:Python程序实例解析
- 【转帖】四种BI 开源工具介绍-SpagoBI,openI,JasperSoft,Pentaho
- 黑苹果声卡id注入对照表_声卡,给苦苦做AppleALC的新人一个提示,试着先原版AppleALC.kext,注入ID驱动试试...
- 最新服务器处理器天梯,服务器cpu天梯图2020 至强处理器天梯排名
- 快手、携程等公司转战到 ClickHouse,ES 难道不行了?
- 如何固定输出每行打印的个数
- 什么是过拟合?过拟合的10个解决办法都有哪些?
- Ubuntu 15.10 搜狗搜狗输入法崩溃解决方法
- 数据驱动到底是什么?如何驱动,又能驱动什么?
- 2021上海大学计算机科学与技术考研科目,2021上海大学计算机科学与技术考研真题经验参考书...
- 工作十年以后,你们悟出了什么职场道理?
- SNMPV1, V2, V3 Agent 配置 + NMS测试