chrony介绍和安装
chrony介绍和安装
1.chrony(时间同步服务)
1.1 chrony介绍
Chrony 是一个用于时间同步的软件,它旨在提供高精度的系统时钟同步。Chrony 软件包括一个 NTP(Network Time Protocol,网络时间协议)服务器和客户端,可以帮助计算机系统与网络时间服务器同步,以确保系统时钟的准确性。
以下是 Chrony 的一些关键特点和功能:
1. 高精度时钟同步:Chrony 旨在提供比传统的 NTP 实现更高精度的时钟同步。它采用一些先进的算法和技术,例如平滑过渡和时钟漂移补偿,以确保系统时钟能够尽可能准确地与参考时间源同步。
2. 网络时间协议支持:Chrony 支持 NTP 协议,可以与外部的 NTP 服务器进行通信,从而获取准确的时间信息。这使得计算机系统可以通过网络与可靠的时间源进行同步,以消除时钟漂移和误差。
3. 灵活的配置选项:Chrony 提供了丰富的配置选项,允许管理员根据特定的需求和环境对时钟同步进行定制。管理员可以设置不同的 NTP 服务器、调整同步频率和优先级等参数。
4. 容错和稳健性:Chrony 具有一定的容错机制,可以处理网络中断、临时不可用的时间服务器或其他异常情况。它可以自动调整同步策略,以确保系统时钟的稳定性和准确性。
5. 系统时钟管理:除了作为 NTP 客户端,Chrony 还可以作为系统时钟管理工具,监视和调整系统时钟,以确保其精度和稳定性。
总之,Chrony 是一个功能强大的时间同步工具,适用于需要高精度时钟同步的计算机系统,尤其是对时间同步精度要求较高的服务器和网络设备。通过使用 Chrony,用户可以确保其系统时钟与外部时间源同步,从而提高计算机系统的时间准确性和稳定性。
chrony官网:https://chrony-project.org
chrony官方文档:https://chrony-project.org/documentation.html
1.2 chrony 文件组成
包:chrony
两个主要程序:chronyd和chronyc
• chronyd:后台运行的守护进程,用于调整内核中运行的系统时钟和时钟服务器同步。它确定计算机增减时间的比率,并对此进行补偿
• chronyc:命令行用户工具,用于监控性能并进行多样化的配置。它可以在chronyd实例控制的计算机上工作,也可在一台不同的远程计算机上工作
服务unit 文件: /usr/lib/systemd/system/chronyd.service
监听端口: 服务端: 123/udp,客户端: 323/udp
配置文件: /etc/chrony.conf
1.3 配置文件chrony.conf
server - 可用于时钟服务器,iburst 选项当服务器可达时,发送一个八个数据包而不是通常的一个数据包。 包间隔通常为2秒,可加快初始同步速度
driftfile - 根据实际时间计算出计算机增减时间的比率,将它记录到一个文件中,会在重启后为系统时钟作出补偿
rtcsync - 启用内核模式,系统时间每11分钟会拷贝到实时时钟(RTC)
allow / deny - 指定一台主机、子网,或者网络以允许或拒绝访问本服务器
cmdallow / cmddeny - 可以指定哪台主机可以通过chronyd使用控制命令
bindcmdaddress - 允许chronyd监听哪个接口来接收由chronyc执行的命令
makestep - 通常chronyd将根据需求通过减慢或加速时钟,使得系统逐步纠正所有时间偏差。在某些特定情况下,系统时钟可能会漂移过快,导致该调整过程消耗很长的时间来纠正系统时钟。该指令强制chronyd在调整期大于某个阀值时调整系统时钟
local stratum 10 - 即使server指令中时间服务器不可用,也允许将本地时间作为标准时间授时给其它客户端
2.chrony安装
2.1 主机初始化
2.1.1 设置网卡名
• Rocky Linux 9/10、Almalinux 9/10、CentOS Stream 9/10、AnolisOS 23、OpenCloudOS 9:
o 创建 systemd 链接文件: 创建 /etc/systemd/network/70-eth0.link 文件。
[root@rocky10 ~]# mkdir -p /etc/systemd/network/
[root@rocky10 ~]# touch /etc/systemd/network/70-eth0.link
[root@rocky10 ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:0c:29:f8:60:8f brd ff:ff:ff:ff:ff:ff
altname enp3s0
inet 172.31.7.16/21 brd 172.31.7.255 scope global dynamic noprefixroute ens160
valid_lft 1791sec preferred_lft 1791sec
inet6 fe80::20c:29ff:fef8:608f/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@rocky10 ~]# cat > /etc/systemd/network/70-eth0.link << EOF
[Match]
MACAddress=00:0c:29:f8:60:8f
[Link]
Name=eth0
EOF
# 也可以执行下面命令
ETHNAME=`ip addr | awk -F"[ :]" '/^2/{print $3}'`
ETHMAC=`ip addr show ${ETHNANME} | awk -F' ' '/ether/{print $2}'`
mkdir /etc/systemd/network/
touch /etc/systemd/network/70-eth0.link
cat > /etc/systemd/network/70-eth0.link << EOF
[Match]
MACAddress=${ETHMAC}
[Link]
Name=eth0
EOF
o 修改 NetworkManager 配置文件: 如果使用 NetworkManager 管理网络,需要修改 /etc/NetworkManager/system-connections 下的配置文件。
[root@rocky10 ~]# mv /etc/NetworkManager/system-connections/ens160.nmconnection /etc/NetworkManager/system-connections/eth0.nmconnection
[root@rocky10 ~]# sed -i.bak 's/'ens160'/eth0/' /etc/NetworkManager/system-connections/eth0.nmconnection
# 也可以执行下面命令
mv /etc/NetworkManager/system-connections/${ETHNAME}.nmconnection /etc/NetworkManager/system-connections/eth0.nmconnection
sed -i.bak 's/'${ETHNAME}'/eth0/' /etc/NetworkManager/system-connections/eth0.nmconnection
• Rocky Linux 8、Almalinux 8、CentOS 7、CentOS Stream 8、openEuler 22.03和24.03 LTS、AnolisOS 8、OpenCloudOS 8、Kylin Server v10、UOS Server v20:
o 修改 GRUB 配置文件: 打开 /etc/default/grub 文件,添加以下内容到 GRUB_CMDLINE_LINUX 行
net.ifnames=0 biosdevname=0
执行以下命令:
sed -ri.bak '/^GRUB_CMDLINE_LINUX=/s@"$@ net.ifnames=0 biosdevname=0"@' /etc/default/grub
然后更新 GRUB 配置:
grub2-mkconfig -o /boot/grub2/grub.cfg
如果是 UEFI 引导系统,更新命令为:
# Rocky
grub2-mkconfig -o /boot/efi/EFI/rocky/grub.cfg
# Almalinux
grub2-mkconfig -o /boot/efi/EFI/almalinux/grub.cfg
# CentOS
grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
# openEuler
grub2-mkconfig -o /boot/efi/EFI/openEuler/grub.cfg
# AnolisOS
grub2-mkconfig -o /boot/efi/EFI/anolis/grub.cfg
# OpenCloudOS
grub2-mkconfig -o /boot/efi/EFI/opencloudos/grub.cfg
# Kylin Server
grub2-mkconfig -o /boot/efi/EFI/kylin/grub.cfg
# Uos Server
grub2-mkconfig -o /boot/efi/EFI/uos/grub.cfg
# UEFI 引导系统可以直接执行下面命令:
EFI_DIR=`find /boot/efi/ -name "grub.cfg" | awk -F"/" '{print $5}'`
grub2-mkconfig -o /boot/efi/EFI/${EFI_DIR}/grub.cfg
o 创建 Udev 规则文件: 创建 /etc/udev/rules.d/10-network.rules 文件,并添加以下内容:
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="<网卡MAC地址>", NAME="eth0"
注意:创建Udev这个步骤只在AnolisOS 8上执行。
将 <网卡MAC地址> 替换为实际网卡的 MAC 地址。
[root@anolis8 ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:c5:38:3b brd ff:ff:ff:ff:ff:ff
altname enp2s1
inet 172.31.7.15/21 brd 172.31.7.255 scope global dynamic noprefixroute ens33
valid_lft 1590sec preferred_lft 1590sec
inet6 fe80::20c:29ff:fec5:383b/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@anolis8 ~]# cat >> /etc/udev/rules.d/10-network.rules << EOF
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="00:0c:29:c5:38:3b", NAME="eth0"
EOF
# 也可以执行下面命令
ETHNAME=`ip addr | awk -F"[ :]" '/^2/{print $3}'`
ETHMAC=`ip addr show ${ETHNANME} | awk -F' ' '/ether/{print $2}'`
cat >> /etc/udev/rules.d/10-network.rules << EOF
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="${ETHMAC}", NAME="eth0"
EOF
o 修改网卡配置文件: 创建 /etc/sysconfig/network-scripts/ifcfg-eth0 文件,并配置网卡参数,例如:
ETHNAME=`ip addr | awk -F"[ :]" '/^2/{print $3}'`
mv /etc/sysconfig/network-scripts/ifcfg-${ETHNAME} /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i.bak 's/'${ETHNAME}'/eth0/' /etc/sysconfig/network-scripts/ifcfg-eth0
• Ubuntu和Debian:
# Ubuntu和Debian先启用root用户,并设置密码
raymond@ubuntu2404:~$ cat set_root_login.sh
#!/bin/bash
read -p "请输入密码: " PASSWORD
echo ${PASSWORD} |sudo -S sed -ri 's@#(PermitRootLogin )prohibit-password@\1yes@' /etc/ssh/sshd_config
sudo systemctl restart sshd
sudo -S passwd root <<-EOF
${PASSWORD}
${PASSWORD}
EOF
raymond@ubuntu2404:~$ bash set_root_login.sh
请输入密码: 123456
[sudo] password for raymond: New password: Retype new password: passwd: password updated successfully
o 修改 GRUB 配置文件: 打开 /etc/default/grub 文件,添加以下内容到 GRUB_CMDLINE_LINUX 行
net.ifnames=0 biosdevname=0
执行以下命令:
sed -ri.bak '/^GRUB_CMDLINE_LINUX=/s@"$@net.ifnames=0 biosdevname=0"@' /etc/default/grub
然后更新 GRUB 配置:
grub-mkconfig -o /boot/grub/grub.cfg
如果是 UEFI 引导系统,更新命令为:
# Ubuntu
grub-mkconfig -o /boot/efi/EFI/ubuntu/grub.cfg
# Debian
grub-mkconfig -o /boot/efi/EFI/debian/grub.cfg
# UEFI 引导系统可以直接执行下面命令:
EFI_DIR=`find /boot/efi/ -name "grub.cfg" | awk -F"/" '{print $5}'`
grub-mkconfig -o /boot/efi/EFI/${EFI_DIR}/grub.cfg
o 修改网卡配置文件:
# Ubuntu Server 24.04 LTS
ETHNAME=`ip addr | awk -F"[ :]" '/^2/{print $3}'`
sed -i.bak 's/'${ETHNAME}'/eth0/' /etc/netplan/50-cloud-init.yaml
# Ubuntu Server 22.04 LTS
ETHNAME=`ip addr | awk -F"[ :]" '/^2/{print $3}'`
touch /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
cat > /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg <<-EOF
network: {config: disabled}
EOF
sed -i.bak 's/'${ETHNAME}'/eth0/' /etc/netplan/50-cloud-init.yaml
# Ubuntu Server 20.04 LTS
ETHNAME=`ip addr | awk -F"[ :]" '/^2/{print $3}'`
sed -i.bak 's/'${ETHNAME}'/eth0/' /etc/netplan/00-installer-config.yaml
# Ubuntu Server 18.04 LTS
ETHNAME=`ip addr | awk -F"[ :]" '/^2/{print $3}'`
sed -i.bak 's/'${ETHNAME}'/eth0/' /etc/netplan/01-netcfg.yaml
# Debian
ETHNAME=`ip addr | awk -F"[ :]" '/^2/{print $3}'`
sed -i.bak 's/'${ETHNAME}'/eth0/' /etc/network/interfaces
• 重启系统:
reboot
重启后,网卡名称将变为 eth0。
2.1.2 设置ip地址
ETHNAME=`ip addr | awk -F"[ :]" '/^2/{print $3}'`
# IP变量是ip地址,PREFIX变量是子网掩码位数;GATEWAY变量是网关地址;PRIMARY_DNS变量是主DNS,BACKUP_DNS变量是备用DNS,根据自己的需求修改。
IP=172.31.0.10
PREFIX=21
GATEWAY=172.31.0.2
PRIMARY_DNS=223.5.5.5
BACKUP_DNS=180.76.76.76
Rocky Linux 9/10、Almalinux 9/10、CentOS Stream 9/10、AnolisOS 23、OpenCloudOS 9:
cat > /etc/NetworkManager/system-connections/${ETHNAME}.nmconnection <<-EOF
[connection]
id=${ETHNAME}
type=ethernet
interface-name=${ETHNAME}
[ipv4]
address1=${IP}/${PREFIX},${GATEWAY}
dns=${PRIMARY_DNS};${BACKUP_DNS};
method=manual
EOF
Rocky Linux 8、Almalinux 8、CentOS 7、CentOS Stream 8、openEuler 22.03和24.03 LTS、AnolisOS 8、OpenCloudOS 8、Kylin Server v10、UOS Server v20:
cat > /etc/sysconfig/network-scripts/ifcfg-${ETHNAME} <<-EOF
NAME=${ETHNAME}
DEVICE=${ETHNAME}
ONBOOT=yes
BOOTPROTO=none
TYPE=Ethernet
IPADDR=${IP}
PREFIX=${PREFIX}
GATEWAY=${GATEWAY}
DNS1=${PRIMARY_DNS}
DNS2=${BACKUP_DNS}
EOF
Ubuntu:
# Ubuntu Server 18.04 LTS
cat > /etc/netplan/01-netcfg.yaml <<-EOF
network:
version: 2
renderer: networkd
ethernets:
${ETHNAME}:
dhcp4: no
dhcp6: no
addresses: [${IP}/${PREFIX}]
gateway4: ${GATEWAY}
nameservers:
addresses: [${PRIMARY_DNS}, ${BACKUP_DNS}]
# Ubuntu Server 20.04 LTS
cat > /etc/netplan/00-installer-config.yaml <<-EOF
network:
version: 2
renderer: networkd
ethernets:
${ETHNAME}:
dhcp4: no
dhcp6: no
addresses: [${IP}/${PREFIX}]
gateway4: ${GATEWAY}
nameservers:
addresses: [${PRIMARY_DNS}, ${BACKUP_DNS}]
EOF
# Ubuntu Server 22.04/24.04 LTS
cat > /etc/netplan/50-cloud-init.yaml <<-EOF
network:
version: 2
renderer: networkd
ethernets:
${ETHNAME}:
dhcp4: no
dhcp6: no
addresses: [${IP}/${PREFIX}]
routes:
- to: default
via: ${GATEWAY}
nameservers:
addresses: [${PRIMARY_DNS}, ${BACKUP_DNS}]
EOF
Debian:
sed -ri -e "s/allow-hotplug/auto/g" -e "s/dhcp/static/g" /etc/network/interfaces
sed -i '/static/a\address '${IP}'/'${PREFIX}'\ngateway '${GATEWAY}'\ndns-nameservers '${PRIMARY_DNS}' '${BACKUP_DNS}'\n' /etc/network/interfaces
openSUSE:
cat > /etc/sysconfig/network/ifcfg-${ETHNAME} <<-EOF
STARTMODE='auto'
BOOTPROTO='static'
IPADDR='${IP}/${PREFIX}'
EOF
touch /etc/sysconfig/network/routes
cat > /etc/sysconfig/network/routes <<-EOF
default ${GATEWAY} - -
EOF
sed -ri 's/(NETCONFIG_DNS_STATIC_SERVERS=).*/\1"'${PRIMARY_DNS}' '${BACKUP_DNS}'"/g' /etc/sysconfig/network/config
2.1.3 配置镜像源
Rocky:
# 阿里云镜像站Rocky系统镜像源地址是:mirrors.aliyun.com/rockylinux,火山引擎镜像站Rocky系统镜像源地址是:mirrors.volces.com/rockylinux,后面地址是rockylinux,使用下面命令执行
MIRROR=mirrors.aliyun.com
sed -i.bak -e 's|^mirrorlist=|#mirrorlist=|g' -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://'${MIRROR}'/rockylinux|g' /etc/yum.repos.d/[Rr]ocky*.repo
# 搜狐镜像站Rocky系统镜像源地址是:mirrors.sohu.com/Rocky,后面地址是Rocky,使用下面命令执行
MIRROR=mirrors.sohu.com
sed -i.bak -e 's|^mirrorlist=|#mirrorlist=|g' -e 's|^#baseurl=http://'${OLD_MIRROR}'/$contentdir|baseurl=https://'${MIRROR}'/Rocky|g' /etc/yum.repos.d/[Rr]ocky*.repo
# 其余镜像站Rocky系统镜像源地址后面地址都是rocky,使用下面命令执行
MIRROR=mirrors.tencent.com
sed -i.bak -e 's|^mirrorlist=|#mirrorlist=|g' -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://'${MIRROR}'/rocky|g' /etc/yum.repos.d/[Rr]ocky*.repo
dnf clean all && dnf makecache
Almalinux:
MIRROR=mirrors.tencent.com
OLD_MIRROR=$(sed -rn '/^.*baseurl=/s@.*=http.*://(.*)/(.*)/\$releasever/.*/$@\1@p' /etc/yum.repos.d/almalinux*.repo | head -1)
sed -i.bak -e 's|^mirrorlist=|#mirrorlist=|g' -e 's|^# baseurl=https://'${OLD_MIRROR}'|baseurl=https://'${MIRROR}'|g' /etc/yum.repos.d/almalinux*.repo
CentOS Stream 9和10:
cat update_mirror.pl
#!/usr/bin/perl
use strict;
use warnings;
use autodie;
# 要修改镜像源,请去修改url变量!
my $url = 'mirrors.aliyun.com';
my $mirrors = "https://$url/centos-stream";
if (@ARGV < 1) {
die "Usage: $0 <filename1> <filename2> ...\n";
}
while (my $filename = shift @ARGV) {
my $backup_filename = $filename . '.bak';
rename $filename, $backup_filename;
open my $input, "<", $backup_filename;
open my $output, ">", $filename;
while (<$input>) {
s/^metalink/# metalink/;
if (m/^name/) {
my (undef, $repo, $arch) = split /-/;
$repo =~ s/^\s+|\s+$//g;
($arch = defined $arch ? lc($arch) : '') =~ s/^\s+|\s+$//g;
if ($repo =~ /^Extras/) {
$_ .= "baseurl=${mirrors}/SIGs/\$releasever-stream/extras" . ($arch eq 'source' ? "/${arch}/" : "/\$basearch/") . "extras-common\n";
} else {
$_ .= "baseurl=${mirrors}/\$releasever-stream/$repo" . ($arch eq 'source' ? "/" : "/\$basearch/") . ($arch ne '' ? "${arch}/tree/" : "os") . "\n";
}
}
print $output $_;
}
}
rpm -q perl &> /dev/null || { echo -e "\\033[01;31m "安装perl工具,请稍等..."\033[0m";yum -y install perl ; }
perl ./update_mirror.pl /etc/yum.repos.d/centos*.repo
dnf clean all && dnf makecache
CentOS Stream 8:
MIRROR=mirrors.aliyun.com
sed -i.bak -e 's|^mirrorlist=|#mirrorlist=|g' -e 's|^#baseurl=http://mirror.centos.org/$contentdir|baseurl=https://'${MIRROR}'/centos-vault|g' /etc/yum.repos.d/CentOS-*.repo
dnf clean all && dnf makecache
CentOS 7:
MIRROR=mirrors.aliyun.com
OS_RELEASE_FULL_VERSION=`cat /etc/centos-release | sed -rn 's/^(CentOS Linux release )(.*)( \(Core\))/\2/p'`
sed -i.bak -e 's|^mirrorlist=|#mirrorlist=|g' -e 's|^#baseurl=http://mirror.centos.org/centos|baseurl=https://'${MIRROR}'/centos-vault|g' -e "s/\$releasever/${OS_RELEASE_FULL_VERSION}/g" /etc/yum.repos.d/CentOS-*.repo
yum clean all && yum makecache
Ubuntu Server 24.04 LTS:
MIRROR=mirrors.aliyun.com
sed -ri "s@^(URIs: )(http.*://)(.*)(/ubuntu).?@\1https://${MIRROR}\4@g" /etc/apt/sources.list.d/ubuntu.sources
apt update
Ubuntu Server 18.04/20.04/22.04 LTS:
MIRROR=mirrors.aliyun.com
OLD_MIRROR=`sed -rn "s@^deb http(.*)://(.*)/ubuntu/? $(lsb_release -cs) main.*@\2@p" /etc/apt/sources.list`
SECURITY_MIRROR=`sed -rn "s@^deb http(.*)://(.*)/ubuntu.* $(lsb_release -cs)-security main.*@\2@p" /etc/apt/sources.list`
sed -i.bak -e 's@http.*://'${OLD_MIRROR}'@https://'${MIRROR}'@g' -e 's@http.*://'${SECURITY_MIRROR}'@https://'${MIRROR}'@g' /etc/apt/sources.list
apt update
Debian:
MIRROR=mirrors.aliyun.com
OLD_MIRROR=`sed -rn "s@^deb http(.*)://(.*)/debian/? $(lsb_release -cs) main.*@\2@p" /etc/apt/sources.list`
SECURITY_MIRROR=`sed -rn "s@^deb http(.*)://(.*)/debian-security $(lsb_release -cs)-security main.*@\2@p" /etc/apt/sources.list`
sed -ri.bak -e 's/'${OLD_MIRROR}'/'${MIRROR}'/g' -e 's/'${SECURITY_MIRROR}'/'${MIRROR}'/g' -e 's/^(deb cdrom.*)/#\1/g' /etc/apt/sources.list
apt update
openEuler:
MIRROR=mirrors.aliyun.com
OLD_MIRROR=$(awk -F'/' '/^baseurl=/{print $3}' /etc/yum.repos.d/openEuler.repo | head -1)
sed -i.bak -e 's|^metalink=|#metalink=|g' -e 's|http.*://'${OLD_MIRROR}'|https://'${MIRROR}'/openeuler|g' /etc/yum.repos.d/openEuler.repo
dnf clean all && dnf makecache
AnolisOS:
OLD_MIRROR=$(sed -rn '/^.*baseurl=/s@.*=http.*://(.*)/(.*)/\$releasever/.*/$@\1@p' /etc/yum.repos.d/AnolisOS*.repo | head -1)
# 中国科学院软件研究所镜像站AnolisOS系统镜像源地址是:mirror.iscas.ac.cn/openanolis,后面地址是openanolis,使用下面命令执行
MIRROR=mirror.iscas.ac.cn
sed -i.bak -e 's|http.*://'${OLD_MIRROR}'/anolis|https://'${MIRROR}'/openanolis|g' /etc/yum.repos.d/AnolisOS*.repo
# 其余镜像站AnolisOS系统镜像源地址后面地址都是anolis,使用下面命令执行
MIRROR=mirrors.aliyun.com
sed -i.bak -e 's|http.*://'${OLD_MIRROR}'/anolis|https://'${MIRROR}'/anolis|g' /etc/yum.repos.d/AnolisOS*.repo
dnf clean all && dnf makecache
OpenCloudOS:
MIRROR=mirrors.tencent.com
OLD_MIRROR=$(awk -F'/' '/^baseurl=/{print $3}' /etc/yum.repos.d/OpenCloudOS*.repo | head -1)
sed -i.bak -e 's|http.*://'${OLD_MIRROR}'|https://'${MIRROR}'|g' /etc/yum.repos.d/OpenCloudOS*.repo
dnf clean all && dnf makecache
openSUSE:
MIRROR=mirrors.aliyun.com
OLD_MIRROR=$(awk -F'/' '/^baseurl=/{print $3}' /etc/zypp/repos.d/repo-*.repo | head -1)
sed -i.bak 's|http.*://'${OLD_MIRROR}'|https://'${MIRROR}'/opensuse|g' /etc/zypp/repos.d/repo-*.repo
zypper clean && zypper refresh
2.1.4 关闭防火墙
# Rocky、Almalinux、CentOS、openEuler、AnolisOS、OpenCloudOS、openSUSE、Kylin Server、UOS Server
systemctl disable --now firewalld
# CentOS 7还要执行下面命令
systemctl disable --now NetworkManager
# Ubuntu
systemctl disable --now ufw
# Debian默认没有安装防火墙,不用设置
2.1.5 禁用SELinux
# Rocky、Almalinux、CentOS、openEuler、AnolisOS、OpenCloudOS、Kylin Server、UOS Server
setenforce 0
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
# Ubuntu、Debian和openSUSE默认没有安装SELinux,不用设置
2.1.6 禁用AppArmor
# openSUSE发行版默认不启用SELinux,而是使用AppArmor来提供强制访问控制(MAC)功能,需要禁用AppArmor。
systemctl disable --now apparmor
2.1.7 设置时区
timedatectl set-timezone Asia/Shanghai
echo 'Asia/Shanghai' >/etc/timezone
# Ubuntu还要设置下面内容
cat >> /etc/default/locale <<-EOF
LC_TIME=en_DK.UTF-8
EOF
2.2 实现私有的时间服务器
2.2.1 服务端配置
[root@rocky9 ~]# hostname -I
172.31.0.9
# Rocky、Almalinux、CentOS、openEuler、AnolisOS、OpenCloudOS、Kylin Server、UOS Server
[root@rocky9 ~]# yum install -y chrony
# openSUSE
zypper install -y chrony
# Ubuntu和Debian
apt install -y chrony
[root@rocky9 ~]# vim /etc/chrony.conf
-bash: vim: command not found
# Rocky、Almalinux、CentOS、openEuler、AnolisOS、OpenCloudOS、Kylin Server、Uos Server默认没有安装vim
# 安装vim
[root@rocky9 ~]# yum install -y vim
# Rocky、Almalinux、CentOS、openEuler、AnolisOS、openSUSE、Kylin Server、Uos Server
[root@rocky9 ~]# vim /etc/chrony.conf
# Please consider joining the pool (https://www.pool.ntp.org/join.html). # 在这行下面
# 删除pool行内容
pool 2.rocky.pool.ntp.org iburst
# 添加下面的ntp服务器
server ntp.aliyun.com iburst
server ntp.tencent.com iburst
server ntp.tuna.tsinghua.edu.cn iburst
# 把下面内容
#allow 192.168.0.0/16
# 修改为
allow 0.0.0.0/0 # 指定允许同步的网段
# 把下面内容去掉注释
#local stratum 10
# 修改为
local stratum 10 # 当互联网无法连接,仍然可以为客户端提供时间同步服务
# OpenCloudOS
[root@opencloudos9 ~]# vim /etc/chrony.conf
# Use public servers # 在这行下面
# 删除下面所有的server的行
server ntp1.tencent.com iburst
server ntp2.tencent.com iburst
server cn.pool.ntp.org iburst
server time1.tencentyun.com iburst
server time2.tencentyun.com iburst
server time3.tencentyun.com iburst
# 添加下面的ntp服务器
server ntp.aliyun.com iburst
server ntp.tencent.com iburst
server ntp.tuna.tsinghua.edu.cn iburst
# 把下面内容
#allow 192.168.0.0/16
# 修改为
allow 0.0.0.0/0 # 指定允许同步的网段
# 把下面内容去掉注释
#local stratum 10
# 修改为
local stratum 10 # 当互联网无法连接,仍然可以为客户端提供时间同步服务
# Ubuntu
root@ubuntu2404:~# vim /etc/chrony/chrony.conf
# See http://www.pool.ntp.org/join.html for more information. # 在这行下面
# 删除pool行内容
pool ntp.ubuntu.com iburst maxsources 4
pool 0.ubuntu.pool.ntp.org iburst maxsources 1
pool 1.ubuntu.pool.ntp.org iburst maxsources 1
pool 2.ubuntu.pool.ntp.org iburst maxsources 2
# 添加下面的ntp服务器
server ntp.aliyun.com iburst
server ntp.tencent.com iburst
server ntp.tuna.tsinghua.edu.cn iburst
# 在最后面添加下面内容
allow 0.0.0.0/0
local stratum 10
# Debian
root@debian12:~# vim /etc/chrony/chrony.conf
# Use Debian vendor zone. # 在这行下面
# 删除pool行内容
pool 2.debian.pool.ntp.org iburst
# 添加下面的ntp服务器
server ntp.aliyun.com iburst
server ntp.tencent.com iburst
server ntp.tuna.tsinghua.edu.cn iburst
# 在最后面添加下面内容
allow 0.0.0.0/0
local stratum 10f
# 使用下面命令直接替换
NTP_SERVER1=ntp.aliyun.com
NTP_SERVER2=ntp.tencent.com
NTP_SERVER3=ntp.tuna.tsinghua.edu.cn
# Rocky、Almalinux、CentOS、openEuler、AnolisOS、openSUSE、Kylin Server、UOS Server
sed -i -e '/^pool.*/d' -e '/^server.*/d' -e '/^# Please consider .*/a\server '${NTP_SERVER1}' iburst\nserver '${NTP_SERVER2}' iburst\nserver '${NTP_SERVER2}' iburst' -e 's@^#allow.*@allow 0.0.0.0/0@' -e 's@^#local.*@local stratum 10@' /etc/chrony.conf
# OpenCloudOS
sed -i -e '/^pool.*/d' -e '/^server.*/d' -e '/^# Use public.*/a\server '${NTP_SERVER1}' iburst\nserver '${NTP_SERVER2}' iburst\nserver '${NTP_SERVER3}' iburst' -e 's@^#allow.*@allow 0.0.0.0/0@' -e 's@^#local.*@local stratum 10@' /etc/chrony.conf
# Ubuntu
sed -i -e '/^pool.*/d' -e '/^# See http:.*/a\server '${NTP_SERVER1}' iburst\nserver '${NTP_SERVER2}' iburst\nserver '${NTP_SERVER3}' iburst' /etc/chrony/chrony.conf
echo "allow 0.0.0.0/0" >> /etc/chrony/chrony.conf
echo "local stratum 10" >> /etc/chrony/chrony.conf
# Debian
sed -i -e '/^pool.*/d' -e '/^# Use Debian.*/a\server '${NTP_SERVER1}' iburst\nserver '${NTP_SERVER2}' iburst\nserver '${NTP_SERVER3}' iburst' /etc/chrony/chrony.conf
echo "allow 0.0.0.0/0" >> /etc/chrony/chrony.conf
echo "local stratum 10" >> /etc/chrony/chrony.conf
[root@rocky9 ~]# systemctl restart chronyd
[root@rocky9 ~]# systemctl enable --now chronyd
[root@rocky9 ~]# ss -ntul
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
udp UNCONN 0 0 127.0.0.1:323 0.0.0.0:*
udp UNCONN 0 0 0.0.0.0:123 0.0.0.0:*
udp UNCONN 0 0 [::1]:323 [::]:*
tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
tcp LISTEN 0 128 [::]:22 [::]:*
# 服务启动后会打开端口123/udp
[root@rocky9 ~]# chronyc sources -nv
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 203.107.6.88 2 6 377 34 +1042us[+3109us] +/- 63ms # 带*(星号)表示是从这个时间服务器同步的时间。
^- 106.55.184.199 2 6 377 99 +5187us[+7169us] +/- 60ms
^? 101.6.6.172 0 8 0 - +0ns[ +0ns] +/- 0ns
2.2.2 客户端配置
# Rocky、Almalinux、CentOS、openEuler、AnolisOS、OpenCloudOS、Kylin Server、UOS Server
[root@rocky9 ~]# yum install -y chrony
# openSUSE
zypper install -y chrony
# Ubuntu和Debian
apt install -y chrony
[root@rocky9 ~]# vim /etc/chrony.conf
-bash: vim: command not found
# Rocky和CentOS默认没有安装vim
# 安装vim
[root@rocky9 ~]# yum install -y vim
# Rocky、Almalinux、CentOS、openEuler、AnolisOS、openSUSE、Kylin Server、Uos Server
[root@rocky9 ~]# vim /etc/chrony.conf
# Please consider joining the pool (https://www.pool.ntp.org/join.html). # 在这行下面
# 删除pool行内容
pool 2.rocky.pool.ntp.org iburst
# 添加ntp Server端
server 172.31.0.9 iburst
# OpenCloudOS
[root@opencloudos9 ~]# vim /etc/chrony.conf
# Use public servers # 在这行下面
# 删除下面所有的server的行
server ntp1.tencent.com iburst
server ntp2.tencent.com iburst
server cn.pool.ntp.org iburst
server time1.tencentyun.com iburst
server time2.tencentyun.com iburst
server time3.tencentyun.com iburst
# 添加ntp Server端
server 172.31.0.9 iburst
# Ubuntu
root@ubuntu2404:~# vim /etc/chrony/chrony.conf
# See http://www.pool.ntp.org/join.html for more information. # 在这行下面
# 删除pool行内容
pool ntp.ubuntu.com iburst maxsources 4
pool 0.ubuntu.pool.ntp.org iburst maxsources 1
pool 1.ubuntu.pool.ntp.org iburst maxsources 1
pool 2.ubuntu.pool.ntp.org iburst maxsources 2
# 添加ntp Server端
server 172.31.0.9 iburst
# Debian
root@debian12:~# vim /etc/chrony/chrony.conf
# Use Debian vendor zone. # 在这行下面
# 删除pool行内容
pool 2.debian.pool.ntp.org iburst
# 添加ntp Server端
server 172.31.0.9 iburst
# 使用下面命令直接替换
SERVER=172.31.0.9
# Rocky、Almalinux、CentOS、openEuler、AnolisOS、openSUSE、Kylin Server、UOS Server
sed -i -e '/^pool.*/d' -e '/^server.*/d' -e '/^# Please consider .*/a\server '${SERVER}' iburst' /etc/chrony.conf
# OpenCloudOS
sed -i -e '/^pool.*/d' -e '/^server.*/d' -e '/^# Use public.*/a\server '${SERVER}' iburst' /etc/chrony.conf
# Ubuntu
sed -i -e '/^pool.*/d' -e '/^# See http:.*/a\server '${SERVER}' iburst' /etc/chrony/chrony.conf
# Debian
sed -i -e '/^pool.*/d' -e '/^# Use Debian.*/a\server '${SERVER}' iburst' /etc/chrony/chrony.conf
[root@rocky9 ~]# systemctl restart chronyd
[root@rocky9 ~]# systemctl enable --now chronyd
# 确认同步成功
[root@rocky9 ~]# chronyc sources -nv
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 172.31.0.9 3 6 17 18 -47us[ +43us] +/- 60ms
# 带*(星号)表示是从这个时间服务器同步的时间。
2.3 一键安装chrony脚本
Shell脚本源码地址:
Gitee:https://gitee.com/raymond9/shell
Github:https://github.com/raymond999999/shell
可以去上面的Gitee或Github代码仓库拉取脚本。
2.3.1 一键安装chrony服务端脚本
[root@rocky9 ~]# cat install_chrony_server_v3.sh
#!/bin/bash
#
#**********************************************************************************
#Author: Raymond
#QQ: 88563128
#MP: Raymond运维
#Date: 2025-08-31
#FileName: install_chrony_server_v3.sh
#URL: https://wx.zsxq.com/group/15555885545422
#Description: The chrony server install script supports
# “Rocky Linux 8, 9 and 10, Almalinux 8, 9 and 10, CentOS 7,
# CentOS Stream 8, 9 and 10, openEuler 22.03 and 24.03 LTS,
# AnolisOS 8 and 23, OpencloudOS 8 and 9, Kylin Server v10,
# UOS Server v20, Ubuntu Server 18.04, 20.04, 22.04 and 24.04 LTS,
# Debian 11 , 12 and 13, openSUSE 15“ operating systems.
#Copyright (C): 2025 All rights reserved
#**********************************************************************************
COLOR="echo -e \\033[01;31m"
END='\033[0m'
os(){
. /etc/os-release
MAIN_NAME=`sed -rn '/^NAME=/s@.*="([[:alpha:]]+).*"$@\1@p' /etc/os-release`
if [ ${MAIN_NAME} == "Kylin" ];then
MAIN_VERSION_ID=`sed -rn '/^VERSION_ID=/s@.*="([[:alpha:]]+)(.*)"$@\2@p' /etc/os-release`
else
MAIN_VERSION_ID=`sed -rn '/^VERSION_ID=/s@.*="?([0-9]+)\.?.*"?@\1@p' /etc/os-release`
fi
if [ ${MAIN_NAME} == "Ubuntu" -o ${MAIN_NAME} == "Debian" ];then
FULL_NAME="${PRETTY_NAME}"
elif [ ${MAIN_NAME} == "UOS" ];then
FULL_NAME="${NAME}"
else
FULL_NAME="${NAME} ${VERSION_ID}"
fi
}
os
NTP_SERVER1=ntp.aliyun.com
NTP_SERVER2=ntp.tencent.com
NTP_SERVER3=ntp.tuna.tsinghua.edu.cn
install_chrony(){
if [ ${MAIN_NAME} == "Rocky" -o ${MAIN_NAME} == "AlmaLinux" -o ${MAIN_NAME} == "CentOS" -o ${MAIN_NAME} == "openEuler" -o ${MAIN_NAME} == "Anolis" -o ${MAIN_NAME} == "OpenCloudOS" -o ${MAIN_NAME} == "openSUSE" -o ${MAIN_NAME} == "Kylin" -o ${MAIN_NAME} == "UOS" ];then
if [ ${MAIN_NAME} == "openSUSE" ];then
INSTALL_TOOL='zypper'
else
INSTALL_TOOL='yum'
fi
rpm -q chrony &> /dev/null || { ${COLOR}"安装chrony包,请稍等......"${END};${INSTALL_TOOL} install -y chrony &> /dev/null; }
if [ ${MAIN_NAME} == "OpenCloudOS" ];then
sed -i -e '/^pool.*/d' -e '/^server.*/d' -e '/^# Use public.*/a\server '${NTP_SERVER1}' iburst\nserver '${NTP_SERVER2}' iburst\nserver '${NTP_SERVER3}' iburst' -e 's@^#allow.*@allow 0.0.0.0/0@' -e 's@^#local.*@local stratum 10@' /etc/chrony.conf
else
sed -i -e '/^pool.*/d' -e '/^server.*/d' -e '/^# Please consider .*/a\server '${NTP_SERVER1}' iburst\nserver '${NTP_SERVER2}' iburst\nserver '${NTP_SERVER3}' iburst' -e 's@^#allow.*@allow 0.0.0.0/0@' -e 's@^#local.*@local stratum 10@' /etc/chrony.conf
fi
else
dpkg -s chrony &>/dev/null || { ${COLOR}"安装chrony包,请稍等......"${END};apt install -y chrony &> /dev/null; }
if [ ${MAIN_NAME} == "Ubuntu" ];then
sed -i -e '/^pool.*/d' -e '/^# See http:.*/a\server '${NTP_SERVER1}' iburst\nserver '${NTP_SERVER2}' iburst\nserver '${NTP_SERVER3}' iburst' /etc/chrony/chrony.conf
else
sed -i -e '/^pool.*/d' -e '/^# Use Debian.*/a\server '${NTP_SERVER1}' iburst\nserver '${NTP_SERVER2}' iburst\nserver '${NTP_SERVER3}' iburst' /etc/chrony/chrony.conf
fi
echo "allow 0.0.0.0/0" >> /etc/chrony/chrony.conf
echo "local stratum 10" >> /etc/chrony/chrony.conf
fi
systemctl restart chronyd && systemctl enable --now chronyd &> /dev/null
systemctl is-active chronyd &> /dev/null || { ${COLOR}"chrony 启动失败,退出!"${END} ; exit; }
${COLOR}"${FULL_NAME}操作系统,chrony服务端安装完成!"${END}
}
main(){
install_chrony
}
if [ ${MAIN_NAME} == "Rocky" ];then
if [ ${MAIN_VERSION_ID} == 8 -o ${MAIN_VERSION_ID} == 9 -o ${MAIN_VERSION_ID} == 10 ];then
main
fi
elif [ ${MAIN_NAME} == "AlmaLinux" ];then
if [ ${MAIN_VERSION_ID} == 8 -o ${MAIN_VERSION_ID} == 9 -o ${MAIN_VERSION_ID} == 10 ];then
main
fi
elif [ ${MAIN_NAME} == "CentOS" ];then
if [ ${MAIN_VERSION_ID} == 7 -o ${MAIN_VERSION_ID} == 8 -o ${MAIN_VERSION_ID} == 9 -o ${MAIN_VERSION_ID} == 10 ];then
main
fi
elif [ ${MAIN_NAME} == "openEuler" ];then
if [ ${MAIN_VERSION_ID} == 22 -o ${MAIN_VERSION_ID} == 24 ];then
main
fi
elif [ ${MAIN_NAME} == "Anolis" ];then
if [ ${MAIN_VERSION_ID} == 8 -o ${MAIN_VERSION_ID} == 23 ];then
main
fi
elif [ ${MAIN_NAME} == 'OpenCloudOS' ];then
if [ ${MAIN_VERSION_ID} == 8 -o ${MAIN_VERSION_ID} == 9 ];then
main
fi
elif [ ${MAIN_NAME} == "Kylin" ];then
if [ ${MAIN_VERSION_ID} == 10 ];then
main
fi
elif [ ${MAIN_NAME} == "UOS" ];then
if [ ${MAIN_VERSION_ID} == 20 ];then
main
fi
elif [ ${MAIN_NAME} == "openSUSE" ];then
if [ ${MAIN_VERSION_ID} == 15 ];then
main
fi
elif [ ${MAIN_NAME} == "Ubuntu" ];then
if [ ${MAIN_VERSION_ID} == 18 -o ${MAIN_VERSION_ID} == 20 -o ${MAIN_VERSION_ID} == 22 -o ${MAIN_VERSION_ID} == 24 ];then
main
fi
elif [ ${MAIN_NAME} == 'Debian' ];then
if [ ${MAIN_VERSION_ID} == 11 -o ${MAIN_VERSION_ID} == 12 -o ${MAIN_VERSION_ID} == 13 ];then
main
fi
else
${COLOR}"此脚本不支持${FULL_NAME}操作系统!"${END}
fi
2.3.2 一键安装chrony客户端脚本
[root@rocky9 ~]# cat install_chrony_client_v3.sh
#!/bin/bash
#
#**********************************************************************************
#Author: Raymond
#QQ: 88563128
#MP: Raymond运维
#Date: 2025-08-31
#FileName: install_chrony_client_v3.sh
#URL: https://wx.zsxq.com/group/15555885545422
#Description: The chrony client install script supports
# “Rocky Linux 8, 9 and 10, Almalinux 8, 9 and 10, CentOS 7,
# CentOS Stream 8, 9 and 10, openEuler 22.03 and 24.03 LTS,
# AnolisOS 8 and 23, OpencloudOS 8 and 9, Kylin Server v10,
# UOS Server v20, Ubuntu Server 18.04, 20.04, 22.04 and 24.04 LTS,
# Debian 11 , 12 and 13, openSUSE 15“ operating systems.
#Copyright (C): 2025 All rights reserved
#**********************************************************************************
COLOR="echo -e \\033[01;31m"
END='\033[0m'
os(){
. /etc/os-release
MAIN_NAME=`sed -rn '/^NAME=/s@.*="([[:alpha:]]+).*"$@\1@p' /etc/os-release`
if [ ${MAIN_NAME} == "Kylin" ];then
MAIN_VERSION_ID=`sed -rn '/^VERSION_ID=/s@.*="([[:alpha:]]+)(.*)"$@\2@p' /etc/os-release`
else
MAIN_VERSION_ID=`sed -rn '/^VERSION_ID=/s@.*="?([0-9]+)\.?.*"?@\1@p' /etc/os-release`
fi
if [ ${MAIN_NAME} == "Ubuntu" -o ${MAIN_NAME} == "Debian" ];then
FULL_NAME="${PRETTY_NAME}"
elif [ ${MAIN_NAME} == "UOS" ];then
FULL_NAME="${NAME}"
else
FULL_NAME="${NAME} ${VERSION_ID}"
fi
}
os
SERVER=172.31.0.9
install_chrony(){
if [ ${MAIN_NAME} == "Rocky" -o ${MAIN_NAME} == "AlmaLinux" -o ${MAIN_NAME} == "CentOS" -o ${MAIN_NAME} == "openEuler" -o ${MAIN_NAME} == "Anolis" -o ${MAIN_NAME} == "OpenCloudOS" -o ${MAIN_NAME} == "openSUSE" -o ${MAIN_NAME} == "Kylin" -o ${MAIN_NAME} == "UOS" ];then
if [ ${MAIN_NAME} == "openSUSE" ];then
INSTALL_TOOL='zypper'
else
INSTALL_TOOL='yum'
fi
rpm -q chrony &> /dev/null || { ${COLOR}"安装chrony包,请稍等......"${END};${INSTALL_TOOL} install -y chrony &> /dev/null; }
if [ ${MAIN_NAME} == "OpenCloudOS" ];then
sed -i -e '/^pool.*/d' -e '/^server.*/d' -e '/^# Use public.*/a\server '${SERVER}' iburst' /etc/chrony.conf
else
sed -i -e '/^pool.*/d' -e '/^server.*/d' -e '/^# Please consider .*/a\server '${SERVER}' iburst' /etc/chrony.conf
fi
else
dpkg -s chrony &>/dev/null || { ${COLOR}"安装chrony包,请稍等..."${END};apt install -y chrony &> /dev/null; }
if [ ${MAIN_NAME} == "Ubuntu" ];then
sed -i -e '/^pool.*/d' -e '/^# See http:.*/a\server '${SERVER}' iburst' /etc/chrony/chrony.conf
else
sed -i -e '/^pool.*/d' -e '/^# Use Debian.*/a\server '${SERVER}' iburst' /etc/chrony/chrony.conf
fi
fi
systemctl restart chronyd && systemctl enable --now chronyd &> /dev/null
systemctl is-active chronyd &> /dev/null || { ${COLOR}"chrony 启动失败,退出!"${END} ; exit; }
${COLOR}"${FULL_NAME}操作系统,chrony客户端安装完成!"${END}
}
main(){
install_chrony
}
if [ ${MAIN_NAME} == "Rocky" ];then
if [ ${MAIN_VERSION_ID} == 8 -o ${MAIN_VERSION_ID} == 9 -o ${MAIN_VERSION_ID} == 10 ];then
main
fi
elif [ ${MAIN_NAME} == "AlmaLinux" ];then
if [ ${MAIN_VERSION_ID} == 8 -o ${MAIN_VERSION_ID} == 9 -o ${MAIN_VERSION_ID} == 10 ];then
main
fi
elif [ ${MAIN_NAME} == "CentOS" ];then
if [ ${MAIN_VERSION_ID} == 7 -o ${MAIN_VERSION_ID} == 8 -o ${MAIN_VERSION_ID} == 9 -o ${MAIN_VERSION_ID} == 10 ];then
main
fi
elif [ ${MAIN_NAME} == "openEuler" ];then
if [ ${MAIN_VERSION_ID} == 22 -o ${MAIN_VERSION_ID} == 24 ];then
main
fi
elif [ ${MAIN_NAME} == "Anolis" ];then
if [ ${MAIN_VERSION_ID} == 8 -o ${MAIN_VERSION_ID} == 23 ];then
main
fi
elif [ ${MAIN_NAME} == 'OpenCloudOS' ];then
if [ ${MAIN_VERSION_ID} == 8 -o ${MAIN_VERSION_ID} == 9 ];then
main
fi
elif [ ${MAIN_NAME} == "Kylin" ];then
if [ ${MAIN_VERSION_ID} == 10 ];then
main
fi
elif [ ${MAIN_NAME} == "UOS" ];then
if [ ${MAIN_VERSION_ID} == 20 ];then
main
fi
elif [ ${MAIN_NAME} == "openSUSE" ];then
if [ ${MAIN_VERSION_ID} == 15 ];then
main
fi
elif [ ${MAIN_NAME} == "Ubuntu" ];then
if [ ${MAIN_VERSION_ID} == 18 -o ${MAIN_VERSION_ID} == 20 -o ${MAIN_VERSION_ID} == 22 -o ${MAIN_VERSION_ID} == 24 ];then
main
fi
elif [ ${MAIN_NAME} == 'Debian' ];then
if [ ${MAIN_VERSION_ID} == 11 -o ${MAIN_VERSION_ID} == 12 -o ${MAIN_VERSION_ID} == 13 ];then
main
fi
else
${COLOR}"此脚本不支持${FULL_NAME}操作系统!"${END}
fi
- 点赞
- 收藏
- 关注作者
评论(0)