#!/bin/bash
#
sudo killall -9 "AppleConnect"
/bin/mkdir -p "${HOME}/Desktop/downloadfromjamf"
cd "${HOME}/Desktop/downloadfromjamf"
sudo rm -Rf "/Applications/AppleConnect.app/"
ver=`sw_vers -productVersion | cut -d'.' -f1`
#ver2=`sw_vers -productVersion | cut -d'.' -f2`
let ver="$ver" #大版本
#let ver2="$ver2" #小版本
if [ $ver -ge 12 ];then
unzip -o "./AppleConnectInstaller6-1.dmg.zip"
hdiutil attach "./AppleConnectInstaller6-1.dmg"
sudo installer -pkg /Volumes/AppleConnect/AppleConnect.pkg -target /
hdiutil detach /Volumes/AppleConnect
elif [ $ver -eq 11 ];then
/usr/bin/curl -o "./AppleConnectInstaller5-5.dmg.zip" http://aaa.bbb.com/util/software/AppleConnectInstaller5-5.dmg.zip #旧版 11
unzip -o "./AppleConnectInstaller5-5.dmg.zip"
hdiutil attach "./AppleConnectInstaller5-5.dmg"
sudo installer -pkg /Volumes/AppleConnect/AppleConnect.pkg -target /
hdiutil detach /Volumes/AppleConnect
else
/usr/bin/curl -o "./AppleConnect5.2.pkg.zip" http://aaa.bbb.com/util/software/AppleConnect5.2.pkg.zip #旧版 10及以下
unzip -o "./AppleConnect5.2.pkg.zip"
sudo installer -pkg "${HOME}/Desktop/downloadfromjamf/AppleConnect5.2.pkg" -target /
fi
(/usr/bin/osascript -e 'display dialog "成功安装AppleConnect,您可以删除桌面上的downloadfromjamf目录,如果打开AppleConnect出现错误,请重启电脑!" buttons {"OK"} default button "OK"')
#把文件夹权限置为 777 ,让所有人可以删
sudo chmod -R 777 "${HOME}/Desktop/downloadfromjamf/"
#cd ../
#rm -Rf "${HOME}/Desktop/downloadfromjamf"
exit 0