概述:
我正在尝试为一套 MacMini 在教学套件中运行执行以下操作。
全新安装后(使用 Apple 远程桌面和 bash 脚本)
- 安装一些应用程序(Chrome、Logic、Imovie)
- 创建用户(本例为 u:p 学生/学生)
- 向该用户添加家长控制,并限制他们可以使用的应用程序。
- 修改 Dock(通过 plist 文件)以仅显示我们想要的应用程序,并在每次启动时运行它(以防止学生为下一个用户搞砸它)
我有 90% 的工作,但完全被困在试图让我的 plist 工作和加载。
它可以在我的计算机(也是 10.13)上运行并且加载正常,它可以在同一个 mac 上以管理员身份加载它。尝试以用户身份加载它不起作用。
当前进程
在下面运行 Bash 脚本:
#! /bin/bash # Supercedes the above make user , this CANNOT be run as root , so run as the administrator user we added at creation. sysadminctl -addUser student -fullName "Bamm Student" -password student -hint student createhomedir -c /Users/student # Import the parental controls plist dscl . -mcximport /Users/student /tmp/parental_controls.plist # Dock script needs to be copied to the correct location first # Set the permissions on the dock script chmod +x /usr/local/dock.sh chown student:staff /usr/local/dock.sh
这部分一切正常,我得到了一个用户,我得到了主目录,我将停靠脚本复制到/usr/local
(当从命令行以用户身份运行时它可以工作)
- 我将我的 plist 文件复制到该位置
/Users/student/LaunchAgents/
- 确保其归学生所有:员工
- 确保它是 644 权限
- 停靠脚本是可执行的并由学生用户拥有,这可以作为学生用户从命令行运行(通过 ssh 会话)
这个,行不通(我试过很多方法)
# load the dock launchAgent (run as the student user)
launchctl load /Users/student/Libray/launchAgent/com.mitsuite.login.plist
给/Users/temp/Library/LaunchAgents/com.mitsuite.login.plist: Operation not permitted
我也试过
launchctl bootstrap gui/502 /Users/student/Libray/launchAgent/com.mitsuite.login.plist
给Could not find domain for
launchctl bootstrap user/502 /Users/student/Libray/launchAgent/com.mitsuite.login.plist
这些给了我各种错误,system.log
主要是这样的:
Aug 10 15:12:59 MIT-1 com.apple.xpc.launchd[1] (com.apple.xpc.launchd.user.domain.501.100008.Aqua): Caller not allowed to perform action: launchctl.671, action = service bootstrap, code = 1: Operation not permitted, uid = 502, euid = 502, gid = 20, egid = 20, asid = 649
我尝试在不添加任何家长控制(通过管理面板,没有脚本编写乐趣)的情况下创建标准用户并遇到相同的问题。
我的 Plist 看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>local.job</string>
<key>Program</key>
<string>/usr/local/dock.sh</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
更新:
作为测试,我在同一台计算机上创建了一个管理员用户,然后运行它,一切正常,加载 plist 并在启动时运行。
如何让标准用户通过命令行安装 plist?
更新 2:
从另一个 Stackoverflow 问题中,我已将用户名添加到 .plist 文件中,然后将其放在 /Library/LaunchDaemons 中,这一切都在 root 运行时运行 launchctl load /Library/LaunchDaemons/com.mitquite.login.plist
然而,这似乎违反直觉(除非它的意图是因为标准用户无法安装应用程序?)