hello.

make your scripts idempotent.

just add those lines if you need them

ie

config.vm.provision "shell", inline: 'grep P4CONFIG /home/vagrant/.bashrc
|| echo "export P4CONFIG=/vagrant/repos/.p4config" >> /home/vagrant/.bashrc'

Thanks
Alvaro


On Sat, Mar 23, 2019 at 12:20 AM Jason Yu <[email protected]> wrote:

> I have the following vagrantfile. If I run it for the  first time with
> "vagrant up", it works well. but when I ran it for the second time with
> "vagrant up --provision" it added the "export
> P4CONFIG=/vagrant/repos/.p4config"
>
> it adds this line every time I run the command. Is there a way I can avoid
> it to be added twice?
>
> Vagrant.configure("2") do |config|
> ## Specify the base box
> config.vm.box = "xxxxx/vagrant_developer_box"
> config.vm.box_version = "0.07"
>
>
> ## source .p4config file in .bashrc
> config.vm.provision "shell", inline: 'echo "export
> P4CONFIG=/vagrant/repos/.p4config" >> /home/vagrant/.bashrc'
> config.vm.provision "shell", inline: 'echo "After you ssh in, please
> modify the P4USER and P4PASSWD in your .p4config file" >> /etc/motd'
>
> ## Mount the user repos dir
> config.vm.synced_folder '.', '/vagrant/repos', id: "vagrant-root",
> owner: "vagrant",
> group: "vagrant",
> mount_options: ["dmode=775,fmode=664"]
> config.vm.box_download_insecure = true
>
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in
> violation of those guidelines may result in your removal from this mailing
> list.
>
> GitHub Issues: https://github.com/mitchellh/vagrant/issues
> IRC: #vagrant on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Vagrant" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/vagrant-up/6d89ab57-a6c7-4bce-bbe6-d996dc1ffd23%40googlegroups.com
> <https://groups.google.com/d/msgid/vagrant-up/6d89ab57-a6c7-4bce-bbe6-d996dc1ffd23%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Alvaro

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
--- 
You received this message because you are subscribed to the Google Groups 
"Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vagrant-up/CAHqq0ewm6VncHrb1sALFEp%2BHpsgTdEDDcSZM5OHYV%3DEJ0ajhTA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to