#!/bin/bash
ens33_ip=192.168.1.3
ens33_gateway=192.168.1.1
ens37_ip=192.168.207.2
dhcp_wd=192.168.207.0
dhcp_range1=192.168.207.10
dhcp_range2=192.168.207.15
GZLJ=/root/ni
/usr/bin/echo -e "TYPE=Ethernet\nBOOTPROTO=static\nDEVICE=ens33\nONBOOT=yes\nIPADDR="$ens33_ip"\nGATEWAY="$ens33_gateway"\nNETMASK=255.255.255.0\nDNS2=8.8.8.8\nDNS2=114.114.114.114" > /etc/sysconfig/network-scripts/ifcfg-ens33
/usr/bin/cp -a /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens37
/usr/bin/echo -e "TYPE=Ethernet\nBOOTPROTO=static\nDEVICE=ens37\nONBOOT=yes\nIPADDR="$ens37_ip"\nNETMASK=255.255.255.0" > /etc/sysconfig/network-scripts/ifcfg-ens37
/usr/bin/systemctl restart network
if [ $? -eq ] ;then
echo "重启网络成功"
else
echo "重启失败"
fi
#/usr/bin/sed -i '3a nameserver 114.114.114.114' /etc/resolv.conf && /usr/bin/ping -c -w baidu.com &> /dev/null
if [ $? -eq ];then
echo "可以使用网络了"
else
echo "网络还不能使用"
fi
/usr/bin/echo -e "[epel]\nname=epel\nenable=1\ngpgcheck=0\nbaseurl=https://mirrors.aliyun.com/epel/7/x86_64/\n[centos]\nname=centos base\nenabled=1\ngpgcheck=0\nbaseurl=http://mirrors.163.com/centos/7/os/x86_64/" >> /etc/yum.repos.d/nmb.repo
/usr/bin/yum clean all &> /dev/null
/usr/bin/yum makecache &> /dev/null
/usr/bin/yum install cobbler dhcp tftp-server xinetd syslinux httpd pykickstart -y &> /dev/null
installed1=`yum list installed | grep "httpd" | awk -F " +" 'NR==1 {print $1}'`
installed2=`yum list installed | grep "dhcp" | awk -F " +" 'NR==1 {print $1}'`
installed3=`yum list installed | grep "cobbler" | awk -F " +" 'NR==1 {print $1}'`
installed4=`yum list installed | grep "xinetd" | awk -F " +" 'NR==1 {print $1}'`
installed5=`yum list installed | grep "syslinux" | awk -F " +" 'NR==1 {print $1}'`
installed6=`yum list installed | grep "tftp-server" | awk -F " +" 'NR==1 {print $1}'`
installed7=`yum list installed | grep "pykickstart" | awk -F " +" 'NR==1 {print $1}'`
if [ "$installed3" == "cobbler.x86_64" ];then
echo "cobbler is ok"
else
echo "cobbler is lose"
fi
if [ "$installed2" == "dhcp.x86_64" ];then
echo "dhcp is ok"
else
echo "dhcp is lose"
fi
if [ "$installed1" == "httpd.x86_64" ];then
echo "httpd is ok"
else
echo "httpd is lose"
fi
if [ "$installed7" == "pykickstart.noarch" ];then
echo "pykickstart is ok"
else
echo "pykickstart is lose"
fi
if [ "$installed5" == "syslinux.x86_64" ];then
echo "syslinux is ok"
else
echo "syslinux is lose"
fi
if [ "$installed6" == "tftp-server.x86_64" ];then
echo "tftp is ok"
else
echo "tftp is lose"
fi
if [ "$installed4" == "xinetd.x86_64" ];then
echo "xinetd is ok"
else
echo "xinetd is lose"
fi
/usr/bin/echo -e "subnet $dhcp_wd netmask 255.255.255.0 {\nrange $dhcp_range1 $dhcp_range2;\ndefault-lease-time 600;\nmax-lease-time 7200;\n}" > /etc/dhcp/dhcpd.conf
/usr/bin/systemctl restart dhcpd
if [ $? -eq ];then
echo "dhcpd重启成功"
else
echo "dhcpd重启失败"
fi
/usr/bin/sed -i '14c disable = no' /etc/xinetd.d/tftp
/usr/bin/systemctl restart xinetd && /usr/bin/systemctl enable xinetd
if [ $? -eq ];then
echo "xinetd重启成功并设置开机自启ok"
else
echo "xinetd重启失败设置开机自启失败"
fi
/usr/bin/sed -i "272c next_server: $ens37_ip" /etc/cobbler/settings
/usr/bin/sed -i "384c server: $ens37_ip" /etc/cobbler/settings
/usr/bin/systemctl restart rsyncd && /usr/bin/systemctl restart rsyncd.service
if [ $? -eq ];then
echo "rsyncdc重启成功"
else
echo "rsyncd重启失败"
fi
/usr/bin/systemctl enable rsyncd
if [ $? -eq ];then
echo "rsyncd已成功设置开机自启"
else
echo "rsyncd设置开机自启失败"
fi
/usr/bin/sed -i '101c default_password_crypted: "$1$123$7mft0jKnzzvAdU4t0unTG1"' /etc/cobbler/settings
/usr/bin/systemctl restart cobblerd
if [ $? -eq ];then
echo "cobbler重启成功"
else
echo "cobbler重启失败"
fi
/usr/bin/systemctl restart httpd.service &> /dev/null
/usr/bin/cobbler sync &> /dev/null
check=`cobbler check | wc -l`
if [ $check -eq ];then
echo "检查没有问题"
else
echo "警报!请检查settings文本"
fi
/usr/bin/cobbler import --path=$GZLJ --name="centos7.5" &> /dev/null
jiance1=`cobbler distro list | awk 'NR==1{print $1}'`
jiance2=`cobbler profile list | awk 'NR==1{print $1}'`
if [ "$jiance1" == "centos7.5-x86_64" ];then
echo "创建centos7.5发行版本成功"
else
echo "创建centos7.5发行版本失败"
fi
if [ "$jiance2" == "centos7.5-x86_64" ];then
echo "创建centos7.5ok"
else
echo "创建centos7.5lose"
fi
/usr/bin/cp -a /root/anaconda-ks.cfg /var/lib/cobbler/kickstarts/ks.cfg
/usr/bin/sed -i '4a filename "pxelinux.0";' /etc/dhcp/dhcpd.conf
/usr/bin/sed -i "5c url --url=http://$ens37_ip/cobbler/ks_mirror/centos7.5/" /var/lib/cobbler/kickstarts/ks.cfg
/usr/bin/cobbler profile add --distro=centos7.-x86_64 --name=centos7.5_ken --kickstart=/var/lib/cobbler/kickstarts/ks.cfg
fengzhuang=`cobbler profile list | wc -l`
if [ "$fengzhuang" -eq ];then
echo "封装成功"
else
echo "封装失败"
fi
/usr/bin/cobbler profile remove --name=centos7.-x86_64 &> /dev/null
/usr/bin/cobbler sync &> /dev/null
/usr/bin/systemctl restart dhcpd
/usr/sbin/service httpd restart &> /dev/null
/usr/sbin/service cobblerd restart &> /dev/null
/usr/sbin/service dhcpd restart &> /dev/null
/usr/sbin/service xinetd restart &> /dev/null

Cobbler自动化装机脚本的更多相关文章

  1. Cobbler自动化装机

    Cobbler自动化装机 一个可以实现批量安装系统的Linxu应用程序,他可以实现同个服务器安装不同操作系统版本. 准备环境 开启两个网卡.一个仅主机模式,一个桥接模式,仅主机模式对内提供cobble ...

  2. 【Linux】【Services】【Project】Cobbler自动化装机

    1. 概念 1.1. Cobbler 1.2. PXE 1.3. 2. 版本信息 2.1. OS:Red Hat Enterprise Linux Server release 7.3 (Maipo) ...

  3. pxe+kickstart cobbler无人值守装机

    环境准备: 一台服务器 [root@admin tftpboot]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) [roo ...

  4. Cobbler自动化批量安装Linux操作系统 - 运维总结

    一.Cobbler简述 Cobbler是一个自动化和简化系统安装的工具,通过使用网络引导来控制和启动安装.Cobbler的特性包括存储库镜像.Kickstart模板和连接电源管理系统.Cobbler通 ...

  5. cobbler网络装机

    cobbler网络装机 原理分析 cobbler简介 Cobbler通过将设置和管理一个安装服务器所涉及的任务集中在一起,从而简化了系统配置.相当于Cobbler封装了DHCP.TFTP.XINTED ...

  6. Cobbler自动化部署最佳实践

    第1章 Cobbler自动化部署最佳实践 运维自动化在生产环境中占据着举足轻重的地位,尤其是面对几百台,几千台甚至几万台的服务器时,仅仅是安装操作系统,如果不通过自动化来完成,根本是不可想象的. 面对 ...

  7. python+paramiko库+svn写的自动化部署脚本

    第一篇博文 直接开门见山的说了. 这是件什么事?:每次部署都是复制本地的文件粘贴到服务器端,因为路径复杂,所以费时且手工容易出漏洞. 一直在想有什么办法可以解决这种,因为以前在微软的一个牛人同事做过一 ...

  8. CentOS 下运维自动化 Shell 脚本之 expect

    CentOS 下运维自动化 Shell脚本之expect 一.预备知识: 1.在 Terminal 中反斜杠,即 "" 代表转义符,或称逃脱符.("echo -e与pri ...

  9. linux软件管理之------编译安装nginx服务器并手动编写自动化运行脚本

    红帽系列的 linux软件管理分为三类:1. rpm 安装软件.2. yum 安装软件.3. 源码包编译安装.前面两种会在相关专题给出详细讲解.源码包的编译安装是非常关键的,我们知道linux的相关版 ...

随机推荐

  1. Product - 产品经理 - 内容

    特别说明 本文是已读书籍的学习笔记和内容摘要,原文内容有少部分改动,并添加一些相关信息,但总体不影响原文表达. - ISBN: 9787568041591 - https://book.douban. ...

  2. 树莓派上安装Samba实现树莓派与Windows间的文件共享

    我是参考这篇文章的: https://www.jianshu.com/p/ead92b06318e 安装samba和common-bin库(具有smbpasswd效用) sudo apt-get in ...

  3. 转:获取windows凭证管理器明文密码

    1.运行cmdkey /list查看windows保存凭证 方法1.mimikaz mimikatz vault::cred 2.利用powershell尝试获取 windows 普通凭据类型中的明文 ...

  4. Tensorflow 用训练好的模型预测

    本节涉及点: 从命令行参数读取需要预测的数据 从文件中读取数据进行预测 从任意字符串中读取数据进行预测 一.从命令行参数读取需要预测的数据 训练神经网络是让神经网络具备可用性,真正使用神经网络时,需要 ...

  5. 上传本地文件到SVN

    前言:今天按照自己的记忆上传本地文件夹到SVN,出现了点问题,重温了简单操作. https://blog.csdn.net/qq_35150366/article/details/81129847 参 ...

  6. jQuery之克隆事件--clone()与clone(true)区别

    clone()与clone(true)同为克隆 clone()表示复制标签本身, clone(true)会将标签绑定的事件一起复制 来看案例: <!DOCTYPE html> <ht ...

  7. Scala 内部类及外部类

    转自:https://blog.csdn.net/yyywyr/article/details/50193767 Scala内部类是从属于外部类对象的. 1.代码如下 package com.yy.o ...

  8. kali linux eth0网卡不见了上不了网

    不知道什么原因,我的虚拟机上的kali linux 下载了vsftpd重启后,就连不上网了 ifconfig后 发现eth0网卡不见了此时可以使用 ifconfig eth0 up 就可以使网卡重现但 ...

  9. Java实现AES对称加密算法

    Java代码实现 import java.security.SecureRandom; import javax.crypto.Cipher; import javax.crypto.KeyGener ...

  10. windows环境下安装selenium+python

    selenium 是一个web的自动化测试工具,不少学习功能自动化的同学开始首选selenium ,相因为它相比QTP有诸多有点: *  免费,也不用再为破解QTP而大伤脑筋 *  小巧,对于不同的语 ...