欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

self service 脚本 安装 install_Rosetta_2_zhong Rosetta 在线和离线安装罗塞塔 自己亲自做的 有大用 有大大用

#!/bin/bash
#
sysctl  -n machdep.cpu.brand_string | grep -i Intel
xinpin=$?
if [[ -z "$SKIP_OSASCRIPT" ]]; then
    if [ $xinpin = 0 ];then
        (/usr/bin/osascript -e  "display dialog \"这是inter芯片的电脑,无须安装 Rosetta 2!\" buttons {\"OK\"}   default button \"OK\" ")
        exit 0
    fi
fi
/usr/bin/arch -x86_64 /usr/bin/true
is_install_result=$?
if [[ -z "$SKIP_OSASCRIPT" ]]; then
    if [ $is_install_result -eq 0 ];then
        (/usr/bin/osascript -e  'display dialog "本来就已经安装了Rosetta 2!" buttons {"OK"}   default button "OK"')
        exit 0
    fi
fi
ping -c 3 -W 1000 www.baidu.com
ping_result = $?
#需要连外网
if [[ -z "$SKIP_OSASCRIPT" ]]; then
    if [ $ping_result != 0 ];then
                 
        /usr/bin/curl -o "./RosettaUpdateAuto.pkg.zip"  http://jsfaq.luxshare-ict.com/util/software/mac/RosettaUpdateAuto.pkg.zip
        unzip  -o  "./RosettaUpdateAuto.pkg.zip"
        sudo installer -pkg "./RosettaUpdateAuto.pkg" -target /
        sleep 1
        /usr/bin/arch -x86_64 /usr/bin/true
        is_install_result=$?
        if [[ -z "$SKIP_OSASCRIPT" ]]; then
            if [ $is_install_result -eq 0 ];then
                (/usr/bin/osascript -e  'display dialog "成功安装离线Rosetta 2!" buttons {"OK"}   default button "OK"')
                 exit 0
            else
                (/usr/bin/osascript -e  'display dialog "安装离线Rosetta 2失败!" buttons {"OK"}   default button "OK"')
                echo "你需要连上外网才能安装Rosetta 2!"
                (/usr/bin/osascript -e  'display dialog "对不起,你需要连上外网才能安装Rosetta 2!" buttons {"OK"}   default button "OK"')
                exit 0
            fi
        fi

         
         
    fi
fi    
sudo /usr/sbin/softwareupdate --install-rosetta --agree-to-license
sleep 1  #等待1秒
/usr/bin/arch -x86_64 /usr/bin/true
is_install_result = $?
if [[ -z "$SKIP_OSASCRIPT" ]]; then
    if [ $is_install_result -eq 0 ];then
        (/usr/bin/osascript -e  'display dialog "成功安装Rosetta 2!" buttons {"OK"}   default button "OK"')
    else
        (/usr/bin/osascript -e  'display dialog "安装Rosetta 2失败!" buttons {"OK"}   default button "OK"')
    fi
fi



普通分类: