I know about the provisioning script, but this is a different script that I am asking about. I want a script to be executed after every restart of the guest.
I am using shell provisioner.
config.vm.provision :shell, path: "vagrant/bootstrap.sh"
I can't put my commands in this script that I want to run after every restart.
Basically, I want one of my applications to be started when user executes vagrant up
.
My guest is ubuntu 14.04 trusty and one solution I found was to do following on my guest -
sudo crontab -e
#add the following line
@reboot sh /path/to/my_script_on_guest.sh
I can try to do this in my provisioning script, but sudo crontab -e
asks for an editor and I have to kind of interactively add the line. Since the crontab file is not fixed I don't know if it is feasible to do one liner file edits like
echo '@reboot sh /path/to/my_script_on_guest.sh' >> crontab_file
I am guessing that this must be a guest OS specific thing.
Is this possible to achieve using Vagrant?
EDIT: corrected from ssh provisioner to shell provisioner.