|
|
@ -10,12 +10,13 @@ welcome () { |
|
|
|
echo "" |
|
|
|
echo "" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# 检测mac mini的cpu芯片 |
|
|
|
# 获取mac mini的cpu芯片型号信息 |
|
|
|
getCpuInfo () { |
|
|
|
getCpuInfo () { |
|
|
|
cpu_info=`sysctl -n machdep.cpu.brand_string` |
|
|
|
cpu_info=`sysctl -n machdep.cpu.brand_string` |
|
|
|
echo "你的电脑芯片型号:${cpu_info}" |
|
|
|
echo "你的电脑芯片型号:${cpu_info}" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 获取电脑cpu类型 |
|
|
|
# 返回值:1 = intel芯片,2 = 苹果芯片 |
|
|
|
# 返回值:1 = intel芯片,2 = 苹果芯片 |
|
|
|
getCpuType () { |
|
|
|
getCpuType () { |
|
|
|
cpu_info=`sysctl -n machdep.cpu.brand_string` |
|
|
|
cpu_info=`sysctl -n machdep.cpu.brand_string` |
|
|
@ -27,6 +28,29 @@ getCpuType () { |
|
|
|
return 2 #默认为苹果芯片 |
|
|
|
return 2 #默认为苹果芯片 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 检测是否已经安装了docker |
|
|
|
|
|
|
|
# 返回值:0 - 未安装,1 - 已安装 |
|
|
|
|
|
|
|
detectDockerInstalled () { |
|
|
|
|
|
|
|
if [ command -v docker > /dev/null ]; then |
|
|
|
|
|
|
|
return 1 |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 检测docker desktop是否启动 |
|
|
|
|
|
|
|
# 返回值:0 - 未启动,1 - 已启动 |
|
|
|
|
|
|
|
detectDockerStarted () { |
|
|
|
|
|
|
|
res=`docker images | grep -v grep | grep "IMAGE ID" | wc -l` |
|
|
|
|
|
|
|
if [ $res -gt 0 ]; then |
|
|
|
|
|
|
|
return 1 |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 检测域名是否能连接 |
|
|
|
|
|
|
|
# 返回值:0 - 不能连接,1 - 可连接 |
|
|
|
detectDomainCanConnect () { |
|
|
|
detectDomainCanConnect () { |
|
|
|
domain=$1 |
|
|
|
domain=$1 |
|
|
|
if [ -z "${domain}" ]; then |
|
|
|
if [ -z "${domain}" ]; then |
|
|
@ -42,6 +66,7 @@ detectDomainCanConnect () { |
|
|
|
return 1 |
|
|
|
return 1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 获取docker desktop下载地址 |
|
|
|
# 参数:connect_res,可选值:[0, 1] |
|
|
|
# 参数:connect_res,可选值:[0, 1] |
|
|
|
getDockerDesktopDownloadUrl () { |
|
|
|
getDockerDesktopDownloadUrl () { |
|
|
|
getCpuType |
|
|
|
getCpuType |
|
|
@ -64,6 +89,7 @@ getDockerDesktopDownloadUrl () { |
|
|
|
fi |
|
|
|
fi |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 下载docker desktop |
|
|
|
downloadDockerDesktop () { |
|
|
|
downloadDockerDesktop () { |
|
|
|
link=$1 |
|
|
|
link=$1 |
|
|
|
if [ -z "${link}" ]; then |
|
|
|
if [ -z "${link}" ]; then |
|
|
@ -75,20 +101,54 @@ downloadDockerDesktop () { |
|
|
|
echo "即将在浏览器中打开docker desktop的下载链接并开始下载" |
|
|
|
echo "即将在浏览器中打开docker desktop的下载链接并开始下载" |
|
|
|
echo "请在docker desktop下载完成后,双击打开安装" |
|
|
|
echo "请在docker desktop下载完成后,双击打开安装" |
|
|
|
open "${link}" |
|
|
|
open "${link}" |
|
|
|
|
|
|
|
|
|
|
|
echo "如果你已经安装完成,请按Y继续安装machete镜像" |
|
|
|
|
|
|
|
read -p "docker desktop已安装,继续?(Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1 |
|
|
|
|
|
|
|
echo "正在为你安装machete镜像..." |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 安装docker desktop和machete |
|
|
|
# 安装docker desktop和machete |
|
|
|
welcome |
|
|
|
welcome |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
detectDockerInstalled |
|
|
|
|
|
|
|
docker_installed=$? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ $docker_installed -eq 0 ]; then |
|
|
|
getCpuInfo |
|
|
|
getCpuInfo |
|
|
|
getCpuType |
|
|
|
getCpuType |
|
|
|
detect_domain='https://desktop.docker.com' |
|
|
|
detect_domain='https://desktop.docker.com' |
|
|
|
echo "正在检测是否能连接[${detect_domain}],请稍后..." |
|
|
|
echo "正在检测是否能连接[${detect_domain}],请稍后..." |
|
|
|
detectDomainCanConnect "${detect_domain}" |
|
|
|
detectDomainCanConnect "${detect_domain}" |
|
|
|
connect_res=$? |
|
|
|
connect_res=$? |
|
|
|
|
|
|
|
if [ $connect_res -eq 0 ]; then |
|
|
|
|
|
|
|
echo "⚠️⚠️" |
|
|
|
|
|
|
|
echo "当前网络无法连接[${detect_domain}],即将从备用网址下载docker desktop,预计耗时 30 分钟" |
|
|
|
|
|
|
|
echo "如果你已经下载过docker desktop,请复制到当前电脑直接安装" |
|
|
|
|
|
|
|
read -p "确认继续下载?(Y/N): " confirm |
|
|
|
|
|
|
|
if [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]]; then |
|
|
|
link=`getDockerDesktopDownloadUrl $connect_res` |
|
|
|
link=`getDockerDesktopDownloadUrl $connect_res` |
|
|
|
downloadDockerDesktop "${link}" |
|
|
|
downloadDockerDesktop "${link}" |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "如果你已经安装完成,请按Y继续安装machete镜像" |
|
|
|
|
|
|
|
read -p "docker desktop已安装,继续?(Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
detectDockerInstalled |
|
|
|
|
|
|
|
docker_installed=$? |
|
|
|
|
|
|
|
if [ $docker_installed -eq 0 ]; then |
|
|
|
|
|
|
|
echo "⚠️⚠️⚠️" |
|
|
|
|
|
|
|
echo "命令行检测不到docker,请确认docker desktop已经安装" |
|
|
|
|
|
|
|
echo "如果docker desktop已经安装,请关闭当前termina窗口重新打开命令行终端窗口,重新执行此安装脚本" |
|
|
|
|
|
|
|
exit 1 |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
detectDockerStarted |
|
|
|
|
|
|
|
docker_started=$? |
|
|
|
|
|
|
|
if [ $docker_started -eq 0 ]; then |
|
|
|
|
|
|
|
echo "⚠️⚠️" |
|
|
|
|
|
|
|
echo "请双击docker图标启动docker desktop,再继续下一步" |
|
|
|
|
|
|
|
read -p "已经启动docker desktop,继续安装?(Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1 |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "" |
|
|
|
|
|
|
|
echo "正在为你安装machete镜像..." |
|
|
|
|
|
|
|
echo "" |
|
|
|