All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 50s
44 lines
1.4 KiB
Bash
44 lines
1.4 KiB
Bash
#!/bin/bash
|
|
|
|
lsb_dist=$(cat /etc/*release | grep ^ID= | cut -d= -f2) # ubuntu or debian?
|
|
release=$(cat /etc/*release | grep VERSION_CODENAME | cut -d= -f2) # ubuntu(jammy oracular) debian(bookworm)....
|
|
|
|
command_exists() {
|
|
command -v "$@" > /dev/null 2>&1
|
|
}
|
|
is_wsl() {
|
|
case "$(uname -r)" in
|
|
*microsoft* ) true ;; # WSL 2
|
|
*Microsoft* ) true ;; # WSL 1
|
|
* ) false;;
|
|
esac
|
|
}
|
|
|
|
if is_wsl; then
|
|
echo "检测到 WSL 环境,建议使用 Docker Desktop."
|
|
exit 0
|
|
elif command_exists docker; then
|
|
echo "Docker 已安装.... 跳过安装"
|
|
else
|
|
# docker
|
|
if [ ! -f /usr/share/keyrings/docker-archive-keyring.gpg ]; then
|
|
curl -fsSL https://mirrors.martin98.com/repository/docker-ce/linux/$lsb_dist/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
|
|
fi
|
|
echo "deb [signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.martin98.com/repository/docker-ce/linux/$lsb_dist $release stable" > /etc/apt/sources.list.d/docker.list
|
|
|
|
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/docker-install.sh | sh
|
|
cat > /etc/docker/daemon.json <<EOF
|
|
{
|
|
"registry-mirrors": [
|
|
"https://docker.martin98.com",
|
|
"https://registry-docker.martin98.com",
|
|
"https://registry-dockerhub.hk.martin98.com"
|
|
]
|
|
}
|
|
EOF
|
|
if pidof systemd >/dev/null 2>&1; then
|
|
systemctl restart docker
|
|
else
|
|
echo "systemctl 不存在,跳过 docker 重启。"
|
|
fi
|
|
fi |