在 vagrant 的主机路径中执行 shell 脚本

Execute shell script present in host machine path in vagrant

我的 Vagrantfile 是

$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

错误信息:

==> 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

在脚本标签中,我将路径提到为 /opt/IBM/WebSphere/AppServer/。这条路径存在于我的 solaris 盒子中。在 vagrant up 期间,我需要在 solaris box

中执行以下命令
startServer.sh server1

实现此目标的最佳方法是什么。

你能改变这个吗?

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

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