init/init-docker.sh
Martin 28a83e30f5
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 38s
[*] 修改判断条件
2025-01-05 23:55:09 +08:00

29 lines
608 B
Bash

#!/bin/bash
command_exists() {
command -v "$@" > /dev/null 2>&1
}
if command_exists docker; then
echo "docker 已安装.... 跳过"
( set -x; sleep 5 )
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