#!/bin/sh # 显示欢迎信息 welcome () { echo "==欢迎使用machete_installer==" echo "本脚本为开源项目,网址:https://git.filesite.io/filesite/machete_installer" echo "它将指引并安装docker desktop和machete的docker镜像" echo "并完成machete的基本配置,在你的电脑上创建两个网站,一个管理图片,一个管理视频" echo "" } # 检测mac mini的cpu芯片 getCpuInfo () { cpu_info=`sysctl -n machdep.cpu.brand_string` echo "你的电脑芯片型号:${cpu_info}" } # 返回值:1 = intel芯片,2 = 苹果芯片 getCpuType () { cpu_info=`sysctl -n machdep.cpu.brand_string` if [[ $cpu_info == *"Intel"* ]]; then return 1 #intel芯片 fi return 2 #默认为苹果芯片 } getDockerDesktopDownloadUrl () { getCpuType cup_type=$? dmgLink="https://desktop.docker.com/mac/main/arm64/Docker.dmg" if [ $cup_type -eq 1 ]; then dmgLink="https://desktop.docker.com/mac/main/amd64/Docker.dmg" fi echo "${dmgLink}" } downloadDockerDesktop () { link=$1 echo "docker desktop下载链接:${link}" echo "即将在浏览器中打开docker desktop的下载链接并开始下载" echo "请在docker desktop下载完成后,双击打开安装" open "${link}" echo "如果你已经安装完成,请按Y继续安装machete镜像" read -p "docker desktop已安装,继续?(Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1 echo "正在为你安装machete镜像..." } # 测试代码 welcome getCpuInfo getCpuType link=`getDockerDesktopDownloadUrl` downloadDockerDesktop "${link}"