【发布时间】:2015-06-06 08:54:10
【问题描述】:
我需要一种在我的目录中自动执行vagrant up 命令的方法/Users/user/Dropbox/Development/Homestead
有人知道如何实现吗?
【问题讨论】:
-
Apple 做这些事情的方法是使用
launchd和launchctl。难度不大,可以改编这个stackoverflow.com/questions/17076493/…
我需要一种在我的目录中自动执行vagrant up 命令的方法/Users/user/Dropbox/Development/Homestead
有人知道如何实现吗?
【问题讨论】:
launchd 和launchctl。难度不大,可以改编这个stackoverflow.com/questions/17076493/…
您可以编写一个自动化应用程序(即工作流),并在该应用程序中使用您想要的 vagrant 命令运行 shell 脚本。然后转到系统偏好设置 -> 帐户 -> 登录项并将该应用程序添加为登录项。
【讨论】:
带有 LaunchD 项目。在 /Library/LaunchDaemons 目录中放置一个包含此文件的文件:
<?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>UserName</key>
<string>user</string>
<key>Label</key>
<string>org.xyzzy.vagrantsrc</string>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin</string>
</dict>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/vagrant</string>
<string>up</string>
</array>
<key>RunAtLoad</key><true/>
<key>UserName</key><string>jenkins</string>
<key>WorkingDirectory</key><string>/Users/user/Dropbox/Development/Homestead</string>
</dict>
</plist>
它需要由 root 拥有并称为 something.plist
【讨论】: