KICKSTART无人值守安装系统shell

bash -n   test.bash   #查看bash是否存在语法错误
bash -x   test.bash   #查看bash详细的执行过程

vi test.sh
chmod 777 test.sh

#!/bin/bash
#系统环境准备
ip link set dev ens37 up
ip addr add 10.100.10.1/24 dev ens37
systemctl restart network

#安装DHCP
dhcp_conf="/etc/dhcp/dhcpd.conf" #dhcp配置文件
yum -y install dhcp
mv ${dhcp_conf} d h c p c o n f b a c k u p c a t &gt; {dhcp_conf}_backup cat&gt; dhcpconfbackupcat>{dhcp_conf}<<EOF
subnet 10.100.10.0 netmask 255.255.255.0 {
range 10.100.10.10 10.100.10.254; #可分配的起始IP-结束IP
option subnet-mask 255.255.255.0; #设定netmask
default-lease-time 21600; #设置默认的IP租用期限
max-lease-time 43200; #设置最大的IP租用期限
next-server 10.100.10.1; #告知客户端TFTP服务器的ip
filename “/pxelinux.0”; #告知客户端从TFTP根目录下载pxelinux.0文件
#option domain-name-servers www.baidu.com;
#option domain-name “10.100.10.1”;
#option routers 10.100.10.1;
#option broadcast-address 10.100.10.255;
}
EOF

#DHCP指定监听网卡
dhcpd_service_old="/usr/lib/systemd/system/dhcpd.service" #原dhcp服务文件
dhcpd_service="/etc/systemd/system/dhcpd.service" #dhcp服务文件
cp ${dhcpd_service_old} ${dhcpd_service}
sed -i ‘s/dhcpd --no-pid/dhcpd --no-pid ens37/g’ ${dhcpd_service} #指定监听网卡
#sed -i ‘/dhcpd --no-pid/a\ens37’ #在下一行添加
systemctl --system daemon-reload
systemctl restart dhcpd.service

#安装TFTP服务
tftp_conf="/etc/xinetd.d/tftp" #tftp配置文件
yum -y install xinetd tftp-server
cp ${tftp_conf} ${tftp_conf}_backup
sed -i ‘s/disable = yes/disable = no/g’ ${tftp_conf} #将disable改为no
systemctl restart xinetd
systemctl restart tftp.socket
systemctl restart tftp.service

#配置HTTP服务
http_default_dir="/var/www/html" #http默认发布目录
http_dir="${http_default_dir}/centos-7" #http发布目录
yum -y install httpd
cd /etc/httpd/conf.d/
mv welcome.conf welcome.conf_backup

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值