码迷,mamicode.com
首页 > 其他好文 > 详细

install_server

时间:2014-06-17 17:06:12      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:nowserver     rh5.9 or rh6.4   

#!/bin/bash

read -p "请输入你ISO镜像位置:" file

read -p "请输入你PXELINUX位置:" pxe

read -p "请输入你想安装服务器版本{server5.9|server6.4|servercentos6.4}:" vers 

echo ${file:?"this not exis"} 

echo ${vers:?"this not exis"} 

echo ${pxe:?"this not exis"} 

date=`date +"%Y-%m_%H:%M"`

NOWIP=`ifconfig | grep 192.168.0.254 | awk ‘{print $2}‘ | awk -F ":" ‘{print $2}‘`

IP=192.168.0.254

nowserver=`cat /etc/redhat-release | awk -F " " ‘{print $7}‘`

vers1=`find $file -name *5.9*`

vers2=`find $file -name *6.4*`

pxelinux=`find $pxe -name pxelinux.0`

if [ "$NOWIP" == "$IP" ];then

   echo IP....OK

   else

   echo "请把你的IP设置为:192.168.0.254"

   exit 1

fi

case $vers in

server5.9)

      echo 2;;

server6.4)

      echo 1;;

servercentos6.4)

      echo 3;;

*)

echo $"Usage: $0 {server5.9|server6.4|servercentos6.4}"

esac

###################DHCP##################################

if [ "$nowserver" == "5.9" ];then

    yum -y install dhcp &> /dev/null

 \cp -rf /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf &> /dev/null

 sed -i -e ‘2 anext-server 192.168.0.254;‘ -e ‘3 afilename pxelinux.0;‘ /etc/dhcpd.conf &> /dev/null

 sed -i ‘s/pxelinux.0/"pxelinux.0"/‘ /etc/dhcpd.conf &> /dev/null

sed -i ‘s/192.168.1.1/192.168.0.254/‘ /etc/dhcpd.conf

 sed -i ‘/option router/s/192.168.0.1/192.168.0.254/‘ /etc/dhcpd.conf

  /etc/init.d/dhcpd restart &> /dev/null

fi

####################HTTP##################################

  rpm -qa | grep -i httpd  &> /dev/null

  if [ $? -ne 0 ];then

    yum -y install httpd &> /dev/null

  else

    echo 

  fi


echo "#platform=x86, AMD64, 或 Intel EM64T

# System authorization information

auth  --useshadow  --enablemd5 

# System bootloader configuration

bootloader --location=mbr

# Clear the Master Boot Record

zerombr

# Partition clearing information

clearpart --all --initlabel 

# Use text mode install

text

# Firewall configuration

firewall --disabled

# Run the Setup Agent on first boot

firstboot --disable

# System keyboard

key --skip

keyboard us

# System language

lang zh_CN

# Installation logging level

logging --level=info

# Use NFS installation media

nfs --server=192.168.0.254 --dir="$file"

# Network information

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

# Reboot after installation

reboot

#Root password

rootpw --iscrypted $1$8WHLg8mV$L3Reze9dE9jFFADsp8Yfl0


# SELinux configuration

selinux --disabled

# System timezone

timezone  America/New_York

# Install OS instead of upgrade

install

# X Window System configuration information

xconfig  --defaultdesktop=GNOME --depth=8 --resolution=640x480 --startxonboot

# Disk partitioning information

part swap --bytes-per-inode=4096 --fstype="swap" --size=1000

part /boot --bytes-per-inode=4096 --fstype="ext3" --size=200

part / --bytes-per-inode=4096 --fstype="ext3" --size=9000


%packages

@chinese-support

@base

@gnome-desktop

@base-x

@text-internet

@graphics

@graphical-internet

@editors " > /var/www/html/rh5_ks.cfg

 /etc/init.d/httpd restart &> /dev/null

#############################



echo "#platform=x86, AMD64, 或 Intel EM64T

#version=DEVEL

# Firewall configuration

firewall --disabled

# Install OS instead of upgrade

install

# Use NFS installation media

nfs --server=192.168.0.254 --dir=/iso

# Root password

rootpw --iscrypted $1$1l4DFP35$D7aZMQv7nK4nbmqsSXc6E1

# System authorization information

auth  --useshadow  --passalgo=sha512

# Use text mode install

text

firstboot --disable

# System keyboard

keyboard us

# System language

key --skip

lang en_US

# SELinux configuration

selinux --disabled

# Installation logging level

logging --level=info

# Reboot after installation

reboot

# System timezone

timezone  Africa/Abidjan

# 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  

# Disk partitioning information

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

part swap --fstype="swap" --size=1000

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


%packages

@base

@basic-desktop

@chinese-support

@console-internet

@desktop-platform

@fonts

@general-desktop

@graphical-admin-tools

@graphics

@internet-browser

@kde-desktop

@remote-desktop-clients

@server-platform

@system-admin-tools

@x11


%end " > /var/www/html/rh6_ks.cfg



#####################################################

 



#######################NFS###########################

  rpm -qa | grep -i nfs-utils &> /dev/null

  if [ $? -ne 0 ];then

    yum -y install utils &> /dev/null

  else

    echo 

  fi

  rpm -qa | grep -i portmap &> /dev/null

  if [ $? -ne 0 ];then

    yum -y install portmap &> /dev/null

  else

    echo 

  fi

  rm -rf /etc/exports &> /dev/null

  echo "$file/ 192.168.0.0/24(ro)" > /etc/exports

 /etc/init.d/portmap restart &> /dev/null

  /etc/init.d/nfs restart &> /dev/null

#####################################################




#####################TFTP###############################


rpm -qa | grep -i tftp &> /dev/null

  if [ $? -ne 0 ];then

    yum -y install tftp &> /dev/null

  fi

rpm -qa | grep -i xinetd &> /dev/null

  if [ $? -ne 0 ];then

    yum -y install xinetd &> /dev/null

  fi

  [ -e /tftpboot ]

  if [ $? -ne 0 ];then

   mkdir /tftpboot 

  fi

  [ -e /wgl ]

  if [ $? -ne 0 ];then

   mkdir /wgl 

  fi

  [ -e /tftpboot/pxelinux.cfg ]

  if [ $? -ne 0 ];then

   mkdir /tftpboot/pxelinux.cfg 

  fi

 sed -i ‘/disable/s/yes/no/‘ /etc/xinetd.d/tftp 

  if [ "$vers" == "server5.9" ];then

 mount  -o loop $vers1  /wgl &> /dev/null

 sed -i ‘s/initrd/ks=http:\/\/192.168.0.254\/rh5_ks.cfg initrd/‘ /tftpboot/pxelinux.cfg/default &> /dev/null

  fi

  if [ "$vers" == "server6.4" ];then

 mount  -o loop $vers2  /wgl &> /dev/null

 sed -i ‘s/initrd/ks=http:\/\/192.168.0.254\/rh6_ks.cfg initrd/‘ /tftpboot/pxelinux.cfg/default &> /dev/null

  fi

 \cp -rf /wgl/isolinux/* /tftpboot

  \cp -rf /tftpboot/isolinux.cfg /tftpboot/pxelinux.cfg/default

  \cp -rf $pxelinux /tftpboot

  service xinetd restart &> /dev/null

#########################################################

netstat -anput | grep :80 &> /dev/null

if [ $? -eq 0 ];then

    echo "HTTP.........OK"

 else

    echo "HTTP.........NO"

 fi

netstat -anput | grep dhcpd &> /dev/null

if [ $? -eq 0 ];then

    echo "dhcp.........OK"

 else

    echo "dhcp.........NO"

fi

netstat -anput | grep 69 &> /dev/null

if [ $? -eq 0 ];then

    echo "TFTP.........OK"

 else

    echo "TFTP.........NO"

fi

echo "初始用户root,密码123456"


本文出自 “linux网络服务搭建” 博客,谢绝转载!

install_server,布布扣,bubuko.com

install_server

标签:nowserver     rh5.9 or rh6.4   

原文地址:http://8824130.blog.51cto.com/8814130/1427103

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!