[+] 增加初始化镜像源的脚步

This commit is contained in:
Martin 2025-01-04 14:45:10 +08:00
commit 6d0de77ae3
4 changed files with 66 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.idea/

16
README.md Normal file
View File

@ -0,0 +1,16 @@
#### 镜像源配置测试
```bash
docker compose run debian ./init-apt.sh
```
```bash
docker compose run ubuntu ./init-apt.sh
```

16
docker-compose.yaml Normal file
View File

@ -0,0 +1,16 @@
x-app-config: &app-config
command: bash
working_dir: /app
volumes:
- ./:/app
services:
debian:
<<: *app-config
image: docker.martin98.com/library/debian:latest
ubuntu:
<<: *app-config
image: docker.martin98.com/library/ubuntu:latest

33
init-apt.sh Normal file
View File

@ -0,0 +1,33 @@
#!/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