Fully automated deployment of the shell scripts PXE

Source: Internet
Author: User

#!/bin/bash

#2017 -07-21 by Max

#config PXE


#config Yum

if [!-D ~/yum.bak];

Then

mv/etc/yum.repos.d/* ~/yum.bak

Else

mkdir ~/yum.bak

mv/etc/yum.repos.d/* ~/yum.bak

Fi

Cat >/etc/yum.repos.d/server.repo<< EOF

[Base]

Name=server

Baseurl=file:///mnt

Gnabled=1

Gpgcheck=0

Eof

Mount/dev/cdrom/mnt

Yum Clean All

Yum-y Update


#config FTP

Yum-y Install VSFTPD

Systemctl restart vsftpd; Systemctl Enable VSFTPD


#config TFTP

Yum-y Install TFTP tftp-server xinetd

Sed ' 13s/\/var\/lib//'/etc/xinetd.d/tftp-i

Sed ' 14s/yes/no/'/etc/xinetd.d/tftp-i


#config Network

Cat >/etc/sysconfig/network-scripts/ifcfg-eno16777736<<eof

Type=ethernet

Bootproto=static

name=eno16777736

device=eno16777736

Onboot=yes

netmask=255.255.255.0

ipaddr=192.168.25.1

Eof

Systemctl Restart Network


#config DHCP

Yum-y Install DHCP

if [-f/etc/dhcp/dhcpd.conf.bak];

Then

Rm-rf/etc/dhcp/dhcpd.conf.bak

Fi

Cp/etc/dhcp/dhcpd.conf/etc/dhcp/dhcpd.conf.bak

Rm-rf/etc/dhcp/dhcpd.conf

Cp/usr/share/doc/dhcp*/dhcpd.conf.example/etc/dhcp/dhcpd.conf

Cat >>/etc/dhcp/dhcpd.conf<<eof

Subnet 192.168.25.0 netmask 255.255.255.0 {

Range 192.168.25.100 192.168.25.200;

Next-server 192.168.25.1;

FileName "pxelinux.0";

}

Eof

Systemctl restart dhcpd; Systemctl Enable DHCPD


#config Kickstart

if [!-d/tftpboot/];

Then

mkdir/tftpboot/

Else

rm-rf/tftpboot/*

Fi

Mkdir/tftpboot/pxelinux.cfg-p

Yum-y Install Syslinux

cp/usr/share/syslinux/pxelinux.0/tftpboot/

Cp/mnt/isolinux/isolinux.cfg/tftpboot/pxelinux.cfg/default

cp/mnt/images/pxeboot/initrd.img/tftpboot/

cp/mnt/images/pxeboot/vmlinuz/tftpboot/

chmod 644/tftpboot/pxelinux.cfg/default


#config Boot ' default '

Sed ' 1s/.*/default linux/'/tftpboot/pxelinux.cfg/default-i

Sed ' 64s/.*/append initrd=initrd.img ks=ftp:\/\/192.168.25.1\/ks.cfg/'/tftpboot/pxelinux.cfg/default-i

Sed ' 68d '/tftpboot/pxelinux.cfg/default-i

Sed ' imenu default '/tftpboot/pxelinux.cfg/default-i


Cat >/var/ftp/ks.cfg<<eof

#platform =x86, AMD64, or Intel EM64T

#version =devel

# Install OS instead of upgrade

Install

# Keyboard Layouts

Keyboard ' US '

# Root Password

ROOTPW--iscrypted $1$syci/oct$khzs273jzfitzcp92egxj0

# System TimeZone

TimeZone Africa/abidjan

# Use Network Installation

URL--url= "Ftp://192.168.25.1/pub"

# System Language

Lang en_US

# Firewall Configuration

Firewall--disabled

# System Authorization Information

Auth--useshadow--passalgo=sha512

# Use graphical Install

Graphical

Firstboot--disable

# SELinux Configuration

SELinux--enforcing


# Network Information

Network--bootproto=dhcp--device=eno16777736--onboot=yes

# Reboot after installation

Reboot

# System Bootloader Configuration

Bootloader--location=mbr--md5pass= "$1$wlui.azb$so8s4dcmyhz7rrdihrc95."

# Clear the Master Boot Record

Zerombr

# Partition Clearing Information

Clearpart--all--initlabel

# Disk Partitioning Information

Part/--fstype= "XFS"--size=20480

Part swap--fstype= "swap"--size=2048


%packages

@base

@core

@desktop-debugging

@dial-up

@fonts

@gnome-desktop

@guest-agents

@guest-desktop-agents

@input-methods

@internet-browser

@multimedia

@print-client

@x11


%end

Eof


#config Srouce and server

Umount/dev/cdrom

Mount/dev/cdrom/var/ftp/pub

Iptables-f

Setenforce 0

Systemctl Stop Firewalld

Systemctl Restart DHCPD

Systemctl Restart VSFTPD

Systemctl Restart xinetd


Fully automated deployment of the shell scripts PXE

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.