这个 OS 初始化脚本是我用于初始化实验主机用的,适用操作系统为 CentOS 8 2004 版本。
脚本内容:
1 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.original
2 dnf --version
3 dnf -y install wget && wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
4 dnf clean all && dnf makecache
5 dnf -y upgrade && dnf repolist
6 systemctl stop firewalld && systemctl disable firewalld
7 sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config && setenforce 0
8 wget https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
9 dnf -y install https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
10 dnf clean all && dnf makecache
11 dnf -y upgrade
12 dnf list installed | grep chrony
13 if [ $?=0 ];then
14 echo "Package $(dnf list installed | grep chrony) has been installed "
15 else
16 echo "There is no package $(dnf list installed | grep chrony) and it will be installing"
17 dnf -y install chrony
18 fi
19 wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
20 dnf -y localinstall google-chrome-stable_current_x86_64.rpm
21 chronyc add server cn.ntp.org.cn
22 chronyc sourcestats -v
23 chronyc sources -v
24 chronyc tracking
25 dnf -y install tree
26 dnf list installed
27 who | grep googlebigtable | sed -n '1p' | cut -d' ' -f 1 | sort | uniq
28 DescriptionUser=$(who | grep googlebigtable | sed -n '1p' | cut -d' ' -f 1 | sort | uniq)
29 echo $DescriptionUser
30 echo "$DescriptionUser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
31 init 6
脚本执行过程请参见 本人的 51CTO博客:https://blog.51cto.com/6286393/2518215
CSDN博客限制篇幅字数呀!