#!/bin/bash
#
/bin/mkdir -p "${HOME}/Desktop/downloadfromjamf"
cd "${HOME}/Desktop/downloadfromjamf"
sysctl -n machdep.cpu.brand_string | grep -i Intel
if [ $? = 0 ];then
#inter
unzip -o "./Anaconda3-2022.10-MacOSX-x86_64.sh.zip"
chmod -R 777 "${HOME}/Desktop/downloadfromjamf"
bash ./Anaconda3-2022.10-MacOSX-x86_64.sh -b -p ${HOME}/anaconda3/
echo 'export PATH="${HOME}/anaconda3/bin:$PATH"' >> ${HOME}/.bash_profile
source ${HOME}/.bash_profile
echo 'export PATH="${HOME}/anaconda3/bin:$PATH"' >> ${HOME}/.zshrc
source ${HOME}/.zshrc
source ${HOME}/anaconda3/bin/activate
conda init
else
#M1 or M2
unzip -o "./Anaconda3-2022.10-MacOSX-arm64.sh.zip"
chmod -R 777 "${HOME}/Desktop/downloadfromjamf"
bash ./Anaconda3-2022.10-MacOSX-arm64.sh -b -p /${HOME}/anaconda3/
echo 'export PATH="${HOME}/anaconda3/bin:$PATH"' >> ${HOME}/.bash_profile
source ${HOME}/.bash_profile
echo 'export PATH="${HOME}/anaconda3/bin:$PATH"' >> ${HOME}/.zshrc
source ${HOME}/.zshrc
source ${HOME}/anaconda3/bin/activate
conda init zsh
fi
#myenv.zip是python3.12.2, 把 python3.12的内容 复制到 Users/bbbb-admin/anaconda3/envs/
unzip -o "./myenv3.12.zip"
sudo /bin/cp -a ./myenv3.12 "${HOME}/anaconda3/envs/"
#myenv3.11.zip是python3.11, 把 python3.11的内容 复制到 Users/bbbb-admin/anaconda3/envs/
unzip -o "./myenv3.11.zip"
sudo /bin/cp -a ./myenv3.11 "${HOME}/anaconda3/envs/"
#myenv3.10.zip是python3.10, 把 python3.10的内容 复制到 Users/bbbb-admin/anaconda3/envs/
unzip -o "./myenv3.10.zip"
sudo /bin/cp -a ./myenv3.10 "${HOME}/anaconda3/envs/"
(/usr/bin/osascript -e 'display dialog "成功安装Anaconda3,您可以删除桌面上的downloadfromjamf目录,如果打开Anaconda3出现错误,请重启电脑!" buttons {"OK"} default button "OK"')
#把文件夹权限置为 777 ,让所有人可以删
sudo chmod -R 777 "${HOME}/Desktop/downloadfromjamf/"
#rm -Rf "${HOME}/Desktop/downloadfromjamf"
exit 0