设为首页 收藏本站
查看: 1116|回复: 0

[经验分享] install_server

[复制链接]

尚未签到

发表于 2018-10-24 09:48:03 | 显示全部楼层 |阅读模式
  #!/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"


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-625767-1-1.html 上篇帖子: Win 2008 R2安装SQL Server 2008“性能计数器注册表配置单元一致性”失败的解决办法 下篇帖子: SQL Server2008附加数据库之后显示为只读时解决方法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表