• Linux 脚本----PXE脚本


    #!/bin/bash
    #zxs

    read -p "请输入IP地址:" name
    read -p "请输入网段:" a
    read -p "请输入地址池:" b
    read -p "请输入网关:" c

    iptables -F &> /dev/null
    systemctl stop firewalld &> /dev/null
    setenforce 0 &> /dev/null

    yum -y install vsftpd &> /dev/null
    echo $? " ok"
    [ -d /var/ftp/asd ] || mkdir /var/ftp/asd
    yum -y install tftp-server syslinux dhcp &> /dev/null
    rpm -q tftp-server
    rpm -q dhcp

    umount /dev/sr0
    mount /dev/sr0 /var/ftp/asd
    sed -i "s/yes/no/g" /etc/xinetd.d/tftp
    cd /var/ftp/asd/isolinux
    cp vmlinuz initrd.img /var/lib/tftpboot/
    cp /root/anaconda-ks.cfg /var/ftp/ks.cfg

    chmod 777 /var/ftp/ks.cfg
    sed -i "s/cdrom/#cdrom/" /var/ftp/ks.cfg
    sed -i "s/url/#url/" /var/ftp/ks.cfg
    sed -i "5a url --url=ftp://${name}/asd" /var/ftp/ks.cfg
    cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
    cp /var/ftp/asd/isolinux/isolinux.cfg /var/lib/tftpboot/
    chmod 644 /var/lib/tftpboot/isolinux.cfg
    mkdir /var/lib/tftpboot/pxelinux.cfg
    mv /var/lib/tftpboot/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
    sed -i "s/default vesamenu.c32/default linux/" /var/lib/tftpboot/pxelinux.cfg/default
    sed -i '2a prompt 0' /var/lib/tftpboot/pxelinux.cfg/default
    sed -i "65a append initrd=initrd.img inst.repo=ftp://${name}/asd inst.ks=ftp://${name}/ks.cfg" /var/lib/tftpboot/pxelinux.cfg/default

    rm -rf /etc/dhcp/dhcpd.conf
    cat>/etc/dhcp/dhcpd.conf<<EOF
    option domain-name "example.org";
    option domain-name-servers ${name};
    default-lease-time 600;

    max-lease-time 7200;
    subnet ${a} netmask 255.255.255.0 {
    range ${b};
    option routers ${c};
    next-server ${name};
    filename "pxelinux.0";
    }
    EOF

    systemctl start tftp
    systemctl enable tftp &> /dev/null
    systemctl start dhcpd
    systemctl enable dhcpd &> /dev/null
    systemctl start vsftpd
    systemctl enable vsftpd &> /dev/null

  • 相关阅读:
    flash编程实例源代码下载
    js4:with,for in语句,windows,location对象的使用
    js3:数据类型,数组,String各个属性,以及字符串表达式用eval计算
    挺喜欢这个网站的
    C#Url传递中文参数时解决方法
    .NET设计模式系列文章《转》
    maven surefire plugin介绍
    spring-boot-maven-plugin 插件的作用
    github提交表情包
    接口管理工具
  • 原文地址:https://www.cnblogs.com/wangjia120/p/11426216.html
Copyright © 2020-2023  润新知