189 8069 5689

pxe自动值守脚本

是基于VMware虚拟机上安装实验的!

江都ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:13518219792(备注:SSL证书合作)期待与您的合作!

#!/bin/bash
#修改IP地址            
#sed -i 's/dhcp/static/' /etc/sysconfig/network-scripts/ifcfg-ens32
#echo "
#IPADDR=192.168.100.100
#NETMASK=255.255.255.0" >> /etc/sysconfig/network-scripts/ifcfg-ens32
#systemctl restart network

#配置本地yum
#mount /dev/cdrom /mnt
#mkdir /etc/yum.repos.d/bak && mv /etc/yum.repos.d/C* /etc/yum.repos.d/bak
#echo "
#[base]
#name=base
#baseurl=file:///mnt
#gpgcheck=0
#enabled=1" >> /etc/yum.repos.d/base.repo
#yum clean all && yum list

#安装dhcp,配置dhcp配置文件
[ ! -e /etc/dhcp/dhcpd.conf ] && echo "没有安装DHCP服务,现在安装!"; yum -y install dhcp  
echo  " subnet 192.168.220.0 netmask 255.255.255.0 {
        range 192.168.220.10 192.168.220.20;
        option routers 192.168.220.115;
#        option domain-name-servers 114.114.114.114;
        next-server 192.168.220.115;
        filename \"pxelinux.0\" ;
        }" > /etc/dhcp/dhcpd.conf

#安装tftp和修改配置文件
[ ! -e /etc/xinetd.d/tftp ] && echo "没有安装TFTP,现在安装!";yum -y install tftp-server
sed -i '/disable/s/yes/no/' /etc/xinetd.d/tftp

#安装syslinux
[ ! -e /usr/share/syslinux/pxelinux.0 ] && yum -y install syslinux
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

#安装ftp
[ ! -e /etc/vsftpd/vsftpd.conf ] && yum -y install vsftpd
mkdir /var/ftp/centos7
#umount /mnt && mount /dev/cdrom /var/ftp/centos7/
mount /dev/cdrom /var/ftp/centos7/
cp /var/ftp/centos7/images/pxeboot/vmlinuz /var/lib/tftpboot/
cp /var/ftp/centos7/images/pxeboot/initrd.img /var/lib/tftpboot/

echo "
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --plaintext 123
# System language
lang zh_CN
# Firewall configuration
firewall --disabled
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use CDROM installation media
cdrom
# Use graphical install
graphical
firstboot --disable
# SELinux configuration
selinux --disabled

# Network information
network  --bootproto=dhcp --device=ens32
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all
# Disk partitioning information
part /boot --fstype="xfs" --size=500
part /home --fstype="xfs" --size=2048
part swap --fstype="swap" --size=2048
part / --fstype="xfs" --grow --size=1

%packages
@^gnome-desktop-environment
@base
@core
@desktop-debugging
@dial-up
@directory-client
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@input-methods
@internet-browser
@java-platform
@multimedia
@network-file-system-client
@networkmanager-submodules
@print-client
@x11
chrony
kexec-tools

%end " > /var/ftp/ks.cfg

#配置编辑default启动菜单
mkdir /var/lib/tftpboot/pxelinux.cfg
echo "
default auto
prompt 1

label auto
        kernel vmlinuz
        append initrd=initrd.img method=ftp://192.168.220.115/centos7 ks=ftp://192.168.220.115/ks.cfg

label linux text
        kernel vmlinuz
        append text initrd=initrd.img method=ftp://192.168.220.115/centos7

label linux rescue
        kernel vmlinuz
        append rescue initrd=initrd.img method=ftp://192.168.220.115/centos7
" > /var/lib/tftpboot/pxelinux.cfg/default

setenforce 0
systemctl stop firewalld
systemctl start tftp
systemctl start dhcpd
systemctl start vsftpd


文章标题:pxe自动值守脚本
当前地址:http://jkwzsj.com/article/igghie.html

其他资讯