如何在MacOS中静静地安装.dmg?

我有一个.dmg MacOS包(带有“继续”button,EULA等),我需要安装在多台计算机上。 这是一种通过bash / python / ruby​​ / etc脚本静静地执行的方式,就像Windows中的静默MSI安装一样吗? 我可以自动安装编写脚本,将点击button,但看起来有点不自然:)。

安装一个DMG你可以这样做:

cd ~/Desktop curl -O http://darwinports.opendarwin.org/downloads/DarwinPorts-1.2-10.4.dmg hdiutil attach DarwinPorts-1.2-10.4.dmg cd /Volumes/DarwinPorts-1.2/ sudo installer -pkg DarwinPorts-1.2.pkg -target "/" hdiutil detach /Volumes/DarwinPorts-1.2/ 

简而言之,这个

  1. 转到您的桌面文件夹
  2. 从opendarwin站点抓取DarwinPorts
  3. 挂载dmg
  4. 去新安装的DarwinPorts卷
  5. 以root用户身份安装定位到根的软件包
  6. popup安装的光盘镜像。

你然后可以使用Automator来做到这一点…

代码从这个页面采取

如果你pipe理多个Mac,我强烈build议投资一份ARD – 我确定你的问题有一个脚本答案,但是我一直在使用ARD这么长时间,恐怕我没有知道!

这是一个DMG加上一个PKG?

因为DMG不能被安装,所以它只是一个卷,一个图像,就像ISO一样。 所以可能你所拥有的是一个DMG加上PKG或安装程序…

如果是PKG,可能是远程安装,也可能是默默安装,但如果是另一个安装程序,可能会更棘手,现在请注意…

正如adamvs所说,远程桌面也可以将软件包部署到您的安装中。

 echo "mounting server" mount_afp afp://username:password@yourserver hdiutil attach /Volumes/yourserver/pathtodmg.dmg /usr/sbin/installer -pkg /Volumes/pathtopkgfile.pkg -target / -verboseR echo "umounting the repository" umount /Volumes/yourserver status=$? if [ $status != 0 ] then echo "Something went wront unmounting the server... no problem... we'll just remove the directory" rmdir /Volumes/yourserver fi 

我发现这是非常干净的安装方式,几乎完全没有声音(除了最初的附件)