what about this:
/var/log/secure:Apr 9 07:58:52 oracle65-4disk sudo: vagrant : TTY=unknown ; PWD=/home/vagrant ; USER=root ; COMMAND=/bin/bash -l /var/log/secure:Apr 9 07:58:52 oracle65-4disk sudo: vagrant : TTY=unknown ; PWD=/home/vagrant ; USER=root ; COMMAND=/bin/bash -l On Wed, Apr 9, 2014 at 6:02 AM, beporter <[email protected]> wrote: > I tried asking this in the IRC channel and didn't get a response. > > Maybe this is a basic question, but is there any uniform way to detect if > you are currently inside an environment that was started via vagrant up? > Specifically in a scripting context, I'd like to be able to detect this > case so a shell script could behave differently when run inside a > vagrant-launched box vs otherwise. > > Note that I'd like to be able to distinguish from launching the box > manually via a provider (such as starting the VM from VirtualBox instead of > via vagrant.) I am wondering if there is a universal way to answer the > question, *"was this machine started via `vagrant up`?"* > > Some suggestions that won't work (and why): > > - Check for a `vagrant` user. (If the same provisioning, say via > puppet, is used for the vagrant box as for other instances, it's possible > this user may exist in all environments. I agree that it's not a good idea > to do this, but that doesn't change the possibility of it happening.) > - Check for the shared `/vagrant` folder. (I have not been able to > confirm that this is *always *present and not just "commonly > specified" in most Vagrantfiles.) > - Set some kind of marker file or environment variable inside the > *base* box. (The box may be used in environments other than vagrant. > It may be launched directly via VirtualBox and not via `vagrant up`.) > - Set a marker using `config.vm.provision`. (If a given Vagrantfile > omits this line, the check will be inaccurate. The same for using a vagrant > plugin to set some kind of marker-- the plugin may not be installed on a > given host.) > > So we're back to my question: Does *vagrant itself* leave any clue inside > the VM when the box is specifically started via `vagrant up`? Is there a > reasonably guest-agnostic way to even do this? VirtualBox (at least) > provides for guest > properties<https://www.virtualbox.org/manual/ch04.html#guestadd-guestprops> > which > seems like the right kind of mechanism for this. > > Thanks. > > -- > 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]. > For more options, visit https://groups.google.com/d/optout. > -- 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]. For more options, visit https://groups.google.com/d/optout.
