ValRob
ValRob

Reputation: 2682

How to add a redirect after vagrant ssh

I am new to Vagrant. I have tested different boxes for different cms. Like Drupal VM and VCCW.

In the first scenario, with DruaplVM, after entering into the virtual machine with vagrant ssh it sends me to the actual Drupal site. Directly.

I want to do the same for the VCCW, after entering, I want to go to Vagrant/Wordpress, but I don't really know how that works in Vagrant. I am checking the code in the DrupalVM project, but I haven't found anything.

Upvotes: 0

Views: 161

Answers (1)

nickgryg
nickgryg

Reputation: 28643

What you are asking for is just linux .bashrc routine.

You can use the following Vagrantfile as an example to achieve your goal:

Vagrant.configure("2") do |config|
  config.vm.box = "vccw-team/xenial64"
  config.vm.provision "shell", inline: <<-SHELL
    echo "cd /vagrant/wordpress" >> /home/vagrant/.bashrc
    . /home/vagrant/.bashrc 
  SHELL
end

And after vagrant up we have:

$ vagrant ssh
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-87-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

2 packages can be updated.
0 updates are security updates.


vagrant@vagrant:/vagrant/wordpress$ pwd
/vagrant/wordpress

Upvotes: 0

Related Questions