PXE自動マウントスクリプトの概要

5104 ワード

PXEスクリプトは4つのモジュールに分けて書きます.一、DHCP内容

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”; } 二、ks.cfg無人応答ファイル構成#platform=x 86,AMD 64,or Intel EM 64 T#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
三、インタフェースコード
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
四、コアコード#!/bin/bash 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 m[readyKaTeX parse error:Expected'EOF',got'0'at position 3:a]̲0̲33[0 m"#yum-y...a]033[0 m]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/usr/share/sshare/syslinux/pxelinux.0vmlinuz splash.png vesamenu.c 32 initrd.img/var/lib/tftpboot/cd/var/lib/tftpboot/mkdir pxelinux.cfg echo「インタフェースコンテンツ」 > pxelinux.cfg/default&&echo-e"III.TFT Pサービス---------033[readyKaTeX parse error:Expected'EOF',got'0'at position 3:a]̲0̲33[0m"yum -y i…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[35mSuccessfullyKaTeX parse error: Expected 'EOF', got '\0' at position 2: a\̲0̲33[0m"…a\033[0m” systemctl enable dhcpd &>/dev/null
                                        echo -e "\033[37mSuccessfully$a"

else echo -e “\033[31mError 604:Failed.Service a a aa$a\033[0m” >&2 exit 1 fi