38 lines
797 B
Bash
38 lines
797 B
Bash
#!/bin/bash
|
|
|
|
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
|
|
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/docker-install.sh | sh
|
|
fi
|
|
|
|
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
|