Chinaunix首页 | 论坛 | 博客
  • 博客访问: 244198
  • 博文数量: 49
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1334
  • 用 户 组: 普通用户
  • 注册时间: 2014-03-14 08:53
个人简介

勤于思考,默默学习。

文章分类

全部博文(49)

文章存档

2017年(1)

2016年(2)

2015年(1)

2014年(45)

我的朋友

分类: 服务器与存储

2014-03-17 23:22:07

#!/bin/bash

#NAME:pxeinstall.as6u4.sh

#DESCRIPTION:AS6U4

#VERSION:0.0.1

#DATATIME:2013-06-18 

#USAGE:pxeinstall.as6u4.sh

pxeip="192.168.1.10"

vsftpip="192.168.1.10"

dhcpip="192.168.1.10"

subnetip="192.168.1"

rangeip="192.168.1.100 192.168.1.200"

#准备工作需将rhel6的安装光盘放进光驱

mount /dev/cdrom /media

cat > /etc/yum.repos.d/localcdrom.repo << EOF

[base]

name=base

baseurl=file:///media/Server

gpgcheck=0

enabled=1

EOF

chkconfig iptables off; service iptables stop

setenforce 0

yum clean all && yum repolist

yum -y install dhcp tftp-server syslinux vsftpd system-config-kickstart.noarch

func_tftp() {

sed -i "s@disable.*@disable                 = no@" /etc/xinetd.d/tftp

cp -a /media/isolinux/* /var/lib/tftpboot

mkdir /var/lib/tftpboot/pxelinux.cfg

cp -a /var/lib/tftpboot/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default

chmod u+w /var/tftpboot/pxelinux.cfg/default

#vi /var/lib/tftpboot/pxelinux.cfg/default

cat > /var/lib/tftpboot/pxelinux.cfg/default << EOF

default vesamenu.c32

#prompt 1

timeout 5

display boot.msg

menu background splash.jpg

menu title Welcome to Red Hat Enterprise Linux 6.4!

menu color border 0 #ffffffff #00000000

menu color sel 7 #ffffffff #ff000000

menu color title 0 #ffffffff #00000000

menu color tabmsg 0 #ffffffff #00000000

menu color unsel 0 #ffffffff #00000000

menu color hotsel 0 #ff000000 #ffffffff

menu color hotkey 7 #ffffffff #ff000000

menu color scrollbar 0 #ffffffff #00000000

label linux

  menu label ^Install or upgrade an existing system

  menu default

  kernel vmlinuz

  append initrd=initrd.img ks=ftp://$pxeip/ks.cfg

label vesa

  menu label Install system with ^basic video driver

  kernel vmlinuz

  append initrd=initrd.img xdriver=vesa nomodeset

label rescue

  menu label ^Rescue installed system

  kernel vmlinuz

  append initrd=initrd.img rescue

label local

  menu label Boot from ^local drive

  localboot 0xffff

label memtest86

  menu label ^Memory test

  kernel memtest

  append -

EOF

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

service xinetd restart

}

func_dhcp() {

mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak

cat > /etc/dhcp/dhcpd.conf <

ddns-update-style interim;

ignore client-updates;

next-server $pxeip;

filename "pxelinux.0";

subnet $subnetip.0 netmask 255.255.255.0 {

        option routers  $pxeip;

        option subnet-mask  255.255.255.0;

        option nis-domain   "abc.com";

        option domain-name  "abc.com";

        option domain-name-servers  $pxeip;

        option ntp-servers  $pxeip;

                option time-offset  -18000; # Eastern Standard Time

        allow bootp;

        allow booting;

                range dynamic-bootp $rangeip;

                default-lease-time 21600;

                max-lease-time 43200;

}

EOF

service dhcpd restart

}

func_vsftp() {

service vsftp restart

umount /media

mkdir /var/ftp/rhel6

mount /dev/cdrom /var/ftp/rhel6

cat > /var/ftp/ks.cfg <

#platform=x86, AMD64, or Intel EM64T

#version=DEVEL

# Firewall configuration

firewall --enabled --ssh

# Install OS instead of upgrade

install

# Use network installation

url --url="ftp://$pxeip/rhel6"

# Root password

rootpw --iscrypted $6$bgA6iounYImIucBq$8xtCdixNgcLPBsLOrFmtmrfPezUd.DAgDPBJDYzKYCegvj2oxUF3UGRWWXPaEitnPyckBInZ.RJXG4Vj.uTZd1

# System authorization information

auth  --useshadow  --passalgo=sha512

# System keyboard

keyboard us

# System language

lang en_US

# SELinux configuration

selinux --disabled

# Do not configure the X Window System

skipx

# Installation logging level

logging --level=info

# Reboot after installation

reboot

# System timezone

timezone --isUtc Asia/Shanghai

# Network information

network  --bootproto=dhcp --device=eth0 --onboot=on

# System bootloader configuration

bootloader --location=mbr

# Clear the Master Boot Record

zerombr

# Partition clearing information

clearpart --all --initlabel

# Disk partitioning information

part /boot  --fstype="ext4" --size=200

part swap  --fstype="swap" --size=4096

part /  --fstype="ext4" --size=10000

part /home  --fstype="ext4" --size=1 --grow

                             

%packages

@base

@chinese-support

                             

%end

EOF

}

func_tftp

func_vsftp

func_dhcp

阅读(2181) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~