Comments (11)
Here is my proposed solution.
In the Vagranfile, under "config.vm.provision section", insert a line of command to run a script file. This script file will use the OSX launchd service to make the system run the "vagrant reload" command every time the system boot.
from ole--vagrant-community.
@xinglunxu thanks for the first part which is not as easy as you think ;)
not everybody has a macosx ;)
-> we will solve that in a later step
Anyhow right now I am very much interested in that script which will use OSX launchd
@xinglunxu add more links
and/or a possible solution
from ole--vagrant-community.
Here is a link to the official launchd manual.
It is like a system service native in osx.
https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/ScheduledJobs.html
It should be easy to use because it is all about removing and adding file.
For example, there is directory whose files will be run by the system on every boot. We only need to add our script reloading the vagrant machine to this directory. Not exactly but something similar to this. I am still learning.
We can also use crontab to do the same thing and it might be easier. But from what I learned, it seems that crontab is a deprecated service and launchd is a better solution. The difference between crontab and launchd is also stated in the launchd manual given above.
As for the script to reload the vagrant machine, there are some problems.
I like to use "vagrant reload" to reboost the "community" vagrant machine.
This can be achieve in two ways. One require the id or name of the machine and the other require the path of the vagrant machine. I prefer the former one.
I believe that the id of vagrant machine is different for different host so we need to use the name of machine to target it. However, I fail to do that.
For example, vagrant reload community
does not work when "community" is the name of the machine.
I am still trying to figure out how to write this script.
from ole--vagrant-community.
So after hours of searching and testing, I am now finally able to run a vagrant machine on boot in Mac using launchd service, at lease on my machine. The whole process does not require any GUI operation or any mousing. It uses only terminal commands.
First, let me briefly explain how it work. There is a folder in mac that users can place plist file inside and the system will run all the files inside one by one on boot. The folder path is /Library/LaunchDaemons/ . So we are going to create a plist file to somehow run the command "vagrant reload <id/name>" and place it into this folder. And that's it.
In detail, here is what I did to make it work.
1. Create a plist file in path /Library/LaunchDaemons/ .
As for what is plist file and how to write one, here are some good references:
Official One
Non Official but also good one
And the code for my plist file, com.example.test.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>com.example.test</string>
<key>ProgramArguments</key>
<array>
<string>/Users/username/hw.sh</string>
</array>
<key>WorkingDirectory</key>
<string>/Users/username</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
What this plist file mainly does is that it run a script file in path /Users/username/hw.sh.
2. Create a script file in path /Users/username/hw.sh.
The code for the script file:
#!/bin/bash
export PATH=$PATH:/usr/local/bin
sudo -u <username> vagrant reload <id/name>
This script file will run the command to reload the vagrant machine.
The reason that I run this command as another user using sudo is because of the following(Actually I am not positive about this). When the system runs the vagrant command in the script above, it runs as root user. Root user cannot manage the vagrant machine because vagrant machines are created by normal users and only the creator users can manage their machines.
As a result, I tried to run the vagrant command as a log-in user.
Also, we need to set the permissions of the /Users/username/hw.sh file. For simplicity purpose, I run chmod 777 /Users/username/hw.sh so that it can be read and written by anyone.
And that's it. When the system reboot, this plist file will be run and the vagrant machine will be reloaded.
We can test the plist file by running the command
sudo launchctl load /Library/LaunchDaemons/com.example.test.plist
I am not sure that if I miss something. If I do find out I will add more.
from ole--vagrant-community.
@xinglunxu very impressed with this work, looks quite good. I'm a Mac user and I would love to test it out if you have an "installvagrantboot"script that you can send to me via pull request. If you do, I'll test it and get back to you. If anyone else uses a Mac OS, let us know and it would be great to have multiple people test it once the script is done by @xinglunxu.
from ole--vagrant-community.
May I ask what you want this "installvagrantboot" script to do?
from ole--vagrant-community.
@xinglunxu that script should install all the modifications necessary to get vagrant started on boot ;)
by the way we should also think about an uninstall script ...
from ole--vagrant-community.
from ole--vagrant-community.
@xinglunxu so I tested it and it works well, thanks! We should continue to work on it and clean it up a bit (we should change where the files go and such), but overall, looks good.
Information on how to start is should be included in our code but it's a great start!!
from ole--vagrant-community.
@EmilyLarkin Hi, during the hangout, you mentioned that sometimes the vagrantboot script does not work. Can you give me more information here?
Edit: BTW, when you run installvagrantboot.sh, a stde.txt and stdo.txt files are generated on the same path and their purpose is to store debug message. You can look into them if something go wrong.
from ole--vagrant-community.
@xinglunxu absolutely, I do want to play around with it a bit more because I don't really know why or how, but I know that it doesn't always work.
Let me test it out tomorrow and get back to you once I can give you more details.
from ole--vagrant-community.
Related Issues (17)
- add Bios tweaks to README.md HOT 15
- Create redirect at port 80 to the right port and subdirectory HOT 1
- scripts for downloading all the necessary software HOT 20
- Uninstall script to help with testing HOT 16
- set other then standard password HOT 16
- research into how do installation process with a one liner HOT 5
- windows: add more software to README.md HOT 5
- test
- Proof of Concept to install and uninstall the required software with Chocolatey HOT 4
- Should we download also Firefox with choco? HOT 3
- windows: improve start vagrant on boot HOT 2
- create a section about network and firewall HOT 22
- macOS vagrant start on boot (suggestion)
- ubuntu: start vagrant on boot
- shortcut icon on desktop HOT 8
- simple install by single script HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ole--vagrant-community.