user2439278 user2439278 - 4 months ago 13
Bash Question

Execute shell script present in host machine path in vagrant

My Vagrantfile is

$script = <<SCRIPT
cd /opt/IBM/WebSphere/AppServer/
sudo sh startServer.sh server1
SCRIPT
Vagrant.configure(2) do |config|
config.vm.box = "bolbase"
config.vm.network "public_network"
config.vm.network "forwarded_port", guest: 6000, host: 6000
config.vm.network "forwarded_port", guest: 9060, host: 9060
config.vm.provision "shell", inline: $script
config.vm.provider "virtualbox" do |v|
v.memory = 4096
v.cpus = 2
end
end


Error Message :


==> default: sh: line 1: startServer.sh: not found The SSH command responded with a non-zero exit status. Vagrant assumes that this means
the command failed. The output for this command should be in the log
above. Please read the output to determine what went wrong


In script tag, i mentioned the path as /opt/IBM/WebSphere/AppServer/. This path present inside my solaris box. During vagrant up i need execute the below command inside the solaris box

startServer.sh server1


What is the best way to achieve this.

Answer

Could you change this;

cd /opt/IBM/WebSphere/AppServer/bin/

or

sudo sh /opt/IBM/WebSphere/AppServer/bin/startServer.sh server1