简体   繁体   中英

How can I automatically do vagrant up every time my OSX machine boots?

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?

You can write an automator application (ie 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.

在此输入图像描述

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM