zoukankan      html  css  js  c++  java
  • pxe装机脚本

    #!/bin/bash

    read -p "请输入IP地址:" name


    iptables -F
    systemctl stop firewalld
    setenforce 0

    yum -y install vsftpd &> /dev/null
    [ -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
    [ -d /var/lib/tftpboot/pxelinux.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 192.168.200.0 netmask 255.255.255.0 {
    range 192.168.200.10 192.168.200.20;
    option routers 192.168.200.2;
    next-server ${name};
    filename "pxelinux.0";
    }
    EOF

    systemctl start tftp.socket
    systemctl enable tftp.socket &> /dev/null
    systemctl start dhcpd
    systemctl enable dhcpd &> /dev/null
    systemctl start vsftpd
    systemctl enable vsftpd &> /dev/null
    echo $? "OK"

  • 相关阅读:
    【AtCoder】ARC075
    【BZOJ】3022: [Balkan2012]The Best Teams
    【Codeforces】Gym100633 D. LWDB
    MIME协议在邮件中的应用详解
    struts返回json数据
    mysql-存储过程(转载)
    安卓OKhttp请求封装
    安卓动态添加碎片
    通过163smtp服务器向各大邮箱发送邮件(SOCKET编程)
    安卓原生与hml交互(WebView基础)
  • 原文地址:https://www.cnblogs.com/liu1584712/p/11425989.html
Copyright © 2011-2022 走看看