41 lines
1.3 KiB
Bash
41 lines
1.3 KiB
Bash
#!/bin/bash
|
|
|
|
# 配置 ubuntu 源
|
|
if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then
|
|
cat > /etc/apt/sources.list.d/ubuntu.sources <<EOF
|
|
Types: deb
|
|
URIs: https://mirrors.martin98.com/repository/ubuntu-tsinghua/
|
|
Suites: noble noble-updates noble-backports
|
|
Components: main restricted universe multiverse
|
|
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
|
|
EOF
|
|
# 配置 debian 源
|
|
elif [ -f /etc/apt/sources.list.d/debian.sources ]; then
|
|
cat > /etc/apt/sources.list.d/debian.sources <<EOF
|
|
Types: deb
|
|
URIs: https://mirrors.martin98.com/repository/debian-tsinghua/
|
|
Suites: bookworm bookworm-updates bookworm-backports
|
|
Components: main contrib non-free non-free-firmware
|
|
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
|
|
EOF
|
|
else
|
|
echo "没有找到合适的源"
|
|
exit 1
|
|
fi
|
|
|
|
# 更新证书
|
|
APT_OPTIONS="-o Acquire::https::mirrors.martin98.com::Verify-Peer=false -o Acquire::https::mirrors.martin98.com::Verify-Host=false"
|
|
apt update $APT_OPTIONS && apt install $APT_OPTIONS -y ca-certificates && update-ca-certificates
|
|
apt update && apt upgrade -y
|
|
|
|
|
|
# NTP
|
|
# 启用阿里云 ntp
|
|
apt install chrony -y
|
|
cat > /etc/chrony.conf <<EOF
|
|
server ntp4.aliyun.com minpoll 4 maxpoll 10 iburst
|
|
server ntp5.aliyun.com iburst
|
|
driftfile /var/lib/chrony/drift
|
|
allow 127.0.0.1
|
|
EOF
|
|
systemctl restart chrony && systemctl enable chrony |