4

I need a way to automatically do a vagrant up command inside my directory /Users/user/Dropbox/Development/Homestead

Does anyone know how this can be achieved?

Opal
  • 81,889
  • 28
  • 189
  • 210
V4n1ll4
  • 5,973
  • 14
  • 53
  • 92
  • The Apple way to do these things is to use `launchd` and `launchctl`. It is not too difficult, and you can adapt this http://stackoverflow.com/questions/17076493/making-mac-osx-launchctl-launch-a-process-as-root-on-startup – Mark Setchell Jun 06 '15 at 10:18

2 Answers2

4

You can write an automator application (i.e. workflow) and in that application have it run the shell script with your desired vagrant command. Then go to System Preferences -> Accounts -> Login items and add that application as a login item.

enter image description here

JP.
  • 5,536
  • 7
  • 58
  • 100
2

With a LaunchD item. Put a file containing this in your /Library/LaunchDaemons directory:

<?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>

It needs to be owned by root and called something.plist