test:1
This commit is contained in:
82
scripts/setup.sh
Normal file
82
scripts/setup.sh
Normal file
@@ -0,0 +1,82 @@
|
||||
#!/bin/bash
|
||||
set -eux
|
||||
|
||||
# 备份原来的 sources.list
|
||||
cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
|
||||
# 使用国内源(这里以阿里云为例,你也可以选择其他源)
|
||||
cat > /etc/apt/sources.list <<EOF
|
||||
deb http://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
|
||||
deb http://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
|
||||
deb http://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
|
||||
deb http://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse
|
||||
EOF
|
||||
|
||||
# 更新系统并安装基础工具
|
||||
apt-get update
|
||||
apt-get install -y \
|
||||
curl \
|
||||
git \
|
||||
vim \
|
||||
htop \
|
||||
tree \
|
||||
ca-certificates \
|
||||
gnupg \
|
||||
lsb-release\
|
||||
net-tools\
|
||||
lrzsz \
|
||||
chrony
|
||||
|
||||
|
||||
install -m 0755 -d /etc/apt/keyrings
|
||||
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo tee /etc/apt/keyrings/docker.asc > /dev/null
|
||||
chmod a+r /etc/apt/keyrings/docker.asc
|
||||
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
|
||||
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
|
||||
|
||||
apt-get update
|
||||
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||
|
||||
|
||||
mkdir -p /etc/docker
|
||||
cat > /etc/docker/daemon.json <<EOF
|
||||
{
|
||||
"registry-mirrors": [
|
||||
"https://hub-mirror.c.163.com",
|
||||
"https://mirror.baidubce.com",
|
||||
"https://registry.docker-cn.com",
|
||||
"https://docker.mirrors.ustc.edu.cn"
|
||||
],
|
||||
"exec-opts": ["native.cgroupdriver=systemd"]
|
||||
}
|
||||
EOF
|
||||
|
||||
systemctl enable --now docker
|
||||
systemctl restart docker
|
||||
usermod -aG docker ubuntu
|
||||
docker --version
|
||||
|
||||
|
||||
# 设置为中国时区
|
||||
timedatectl set-timezone Asia/Shanghai
|
||||
|
||||
# 使用阿里云 NTP 源
|
||||
sed -i '/^pool /d' /etc/chrony/chrony.conf
|
||||
cat >> /etc/chrony/chrony.conf <<EOF
|
||||
|
||||
server 192.168.100.105 iburst
|
||||
EOF
|
||||
|
||||
# 启动并同步时间
|
||||
systemctl enable --now chrony
|
||||
sleep 2
|
||||
chronyc makestep # 立即强制同步一次
|
||||
|
||||
# 查看时间同步状态
|
||||
timedatectl status
|
||||
chronyc sources -v
|
||||
|
||||
echo "✅ 系统时区和时间已校准完成。"
|
||||
Reference in New Issue
Block a user