linux之虚拟机脚本安装

1.配置本地yum源
2.下载httpd 和 system-config-kickstart

yum install httpd system-config-kickstart -y

3.system-config-kickstart打开,选择配置内容

这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述

4.将选好的内容保存到/var/www/html/ks.cfg

这里写图片描述

5.编辑ks.cfg

[root@foundation16 html]# vim ks.cfg
改时间
%packages
@base
lftp
%end

%post
cat >>/etc/yum.repos.d/yum.repo <<
[rhel7.2]
name=rhel7.2
baseurl=http://172.25.254.16/rhel7.2/
gpgcheck=0
EOF
%end

6.开启服务,关火墙

[root@foundation16 html]# ksvalidator ks.cfg

[root@foundation16 html]# systemctl start httpd
[root@foundation16 html]# systemctl stop firewalld
[root@foundation16 html]# systemctl disable firewalld
[root@foundation16 html]# systemctl enable httpd

7.编写自动安装脚本

vim /mnt/vm.sh
chmod 755 vm.sh
这里写图片描述

7.运行脚本

sh /mnt/vm.sh a ##运行
这里写图片描述

猜你喜欢

转载自blog.csdn.net/qq_37048504/article/details/81334214