首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >VBoxLinuxAdditions.run从不退出0

VBoxLinuxAdditions.run从不退出0
EN

Stack Overflow用户
提问于 2014-08-21 19:07:56
回答 5查看 2.1K关注 0票数 1

我试图使用Chef自动安装Virtualbox客户添加,但是我遇到了一个问题,在退出代码0中,VBoxLinuxAdditions.run从来不存在。我总是得到退出代码1,即使没有任何错误报告在脚本打印输出。

它们似乎正在安装,所以我不明白为什么这个脚本总是返回1。

我正在开发一个Windows8.1主机,Virtualbox 4.3.12和Debian 6客户操作系统。

我正试图通过使用厨房运行以下菜谱来实现这一点:

代码语言:javascript
运行
复制
include_recipe "apt"

%W[make gcc xserver-xorg xserver-xorg-core linux-headers-#{node['kernel']['release']} dkms].each do |p|
  package p do
    action :install
  end
end

# get additions iso file
remote_file "#{Chef::Config[:file_cache_path]}/vboxAdditions.iso" do
  source "http://download.virtualbox.org/virtualbox/#{node['virtualbox']['version']}/VBoxGuestAdditions_#{node['virtualbox']['version']}.iso"
end

# create the mount point
directory "/mnt/vboxAdditions" do
  owner "root"
  group "root"
  mode "0755"
  action :create
end

# mount the iso
mount "/mnt/vboxAdditions" do
  action :mount
  device "#{Chef::Config[:file_cache_path]}/vboxAdditions.iso"
fstype "iso9660"
  options "loop"
end

# run the installer script
execute "install vbox guest additions" do
  command "sh /mnt/vboxAdditions/VBoxLinuxAdditions.run"
end

我的.kitchen.yml文件:

代码语言:javascript
运行
复制
---
driver_plugin: vagrant

platforms:
- name: debian-6
  driver_config:
    box: opscode-debian-6.0.7
    box_url: http://opscode-vm.s3.amazonaws.com/vagrant/opscode_debian-6.0.7_chef-11.2.0.box
    require_chef_omnibus: 11.4.0

suites:

- name: guest_additions
  run_list: ["recipe[virtualbox::guest_additions]"]
  attributes: {
    "virtualbox": {
      "version": "4.3.12"
    }
  }

下面是我收到的输出:

代码语言:javascript
运行
复制
       ================================================================================
       Error executing action `run` on resource 'execute[install vbox guest additions]'
       ================================================================================


       Mixlib::ShellOut::ShellCommandFailed
       ------------------------------------
       Expected process to exit with [0], but received '1'
       ---- Begin output of sh /mnt/vboxAdditions/VBoxLinuxAdditions.run ----
       STDOUT: Verifying archive integrity... All good.
       Uncompressing VirtualBox 4.3.12 Guest Additions for Linux............
       STDERR: VirtualBox Guest Additions installer
       Removing installed version 4.2.6 of VirtualBox Guest Additions...
       Copying additional installer modules ...
       add_symlink: link file /usr/lib/VBoxGuestAdditions already exists
       Installing additional modules ...
       Removing existing VirtualBox DKMS kernel modules ...done.
       Removing existing VirtualBox non-DKMS kernel modules ...done.
       Building the VirtualBox Guest Additions kernel modules ...done.
       Doing non-kernel setup of the Guest Additions ...done.
       Starting the VirtualBox Guest Additions ...done.
       Installing the Window System drivers
       Installing X.Org Server 1.7 modules ...done.
       Setting up the Window System to use the Guest Additions ...done.
       You may need to restart the hal service and the Window System (or just restart
       the guest system) to enable the Guest Additions.

       Installing graphics libraries and desktop services components ...done.
       ---- End output of sh /mnt/vboxAdditions/VBoxLinuxAdditions.run ----
       Ran sh /mnt/vboxAdditions/VBoxLinuxAdditions.run returned 1


       Resource Declaration:
       ---------------------
       # In /tmp/kitchen/cookbooks/virtualbox/recipes/guest_additions.rb

        70:   execute "install vbox guest additions" do
        71:     command "sh /mnt/vboxAdditions/VBoxLinuxAdditions.run"
        72:   end
        73:



       Compiled Resource:
       ------------------
       # Declared in /tmp/kitchen/cookbooks/virtualbox/recipes/guest_additions.rb:70:in `from_file'

       execute("install vbox guest additions") do
         action "run"
         retries 0
         retry_delay 2
         command "sh /mnt/vboxAdditions/VBoxLinuxAdditions.run"
         backup 5
         returns 0
         cookbook_name :virtualbox
         recipe_name "guest_additions"
       end



       [2014-08-21T19:34:55+00:00] INFO: Running queued delayed notifications before re-raising exception
       [2014-08-21T19:34:55+00:00] ERROR: Running exception handlers
       [2014-08-21T19:34:55+00:00] ERROR: Exception handlers complete
       Chef Client failed. 14 resources updated
       [2014-08-21T19:34:55+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       [2014-08-21T19:34:55+00:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: execute[install vbox guest additions] (virtualbox::guest_additions line 70) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
       ---- Begin output of sh /mnt/vboxAdditions/VBoxLinuxAdditions.run ----
       STDOUT: Verifying archive integrity... All good.
       Uncompressing VirtualBox 4.3.12 Guest Additions for Linux............
       STDERR: VirtualBox Guest Additions installer
       Removing installed version 4.2.6 of VirtualBox Guest Additions...
       Copying additional installer modules ...
       add_symlink: link file /usr/lib/VBoxGuestAdditions already exists
       Installing additional modules ...
       Removing existing VirtualBox DKMS kernel modules ...done.
       Removing existing VirtualBox non-DKMS kernel modules ...done.
       Building the VirtualBox Guest Additions kernel modules ...done.
       Doing non-kernel setup of the Guest Additions ...done.
       Starting the VirtualBox Guest Additions ...done.
       Installing the Window System drivers
       Installing X.Org Server 1.7 modules ...done.
       Setting up the Window System to use the Guest Additions ...done.
       You may need to restart the hal service and the Window System (or just restart
       the guest system) to enable the Guest Additions.

       Installing graphics libraries and desktop services components ...done.
       ---- End output of sh /mnt/vboxAdditions/VBoxLinuxAdditions.run ----
       Ran sh /mnt/vboxAdditions/VBoxLinuxAdditions.run returned 1
>>>>>> Converge failed on instance <guest-additions-debian-6>.
>>>>>> Please see .kitchen/logs/guest-additions-debian-6.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [sudo -E chef-solo --config /tmp/kitchen/solo.rb --json-attributes /tmp/kitchen/dna.json  --log_level info]
>>>>>> ----------------------
bash.exe"-3.1$
EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2014-09-19 23:16:14

我在Linux上运行4.3.16,并遇到了同样的问题。我的安装也嵌入到一个自动化的过程中。

您可以解压存档以检查文件。

代码语言:javascript
运行
复制
./VBoxLinuxAdditions.run --target foo --noexec

引起问题的错误和无用的代码在install.sh中开始如下:

代码语言:javascript
运行
复制
test ! -d "$INSTALLATION_DIR" && REMOVE_INSTALLATION_DIR=1

(REMOVE_INSTALLATION_DIR从未被设置为1,不管是否存在$INSTALLATION_DIR )。

文件末尾的错误是:

代码语言:javascript
运行
复制
test -n "$REMOVE_INSTALLATION_DIR" &&
    echo "$INSTALLATION_DIR/" >> "$CONFIG_DIR/$CONFIG_FILES"

由于$REMOVE_INSTALLATION_DIR从未设置,所以测试-n返回1(失败),而不是像作者应该提供的那样在安装脚本的末尾提供一个出口0,而是从末尾掉下来,并将最后的退出代码提供给shell。

成功的解决办法:

代码语言:javascript
运行
复制
# REMOVE_INSTALLATION_DIR=0 ./VBoxLinuxAdditions.run
# echo $?
0
票数 7
EN

Stack Overflow用户

发布于 2020-10-24 00:17:30

重复Victor Roetman的方法,避免了一些不必要的问题:

代码语言:javascript
运行
复制
if ! modinfo vboxsf >/dev/null 2>&1; then
  echo "Cannot find vbox kernel module. Installation of guest additions unsuccessful!"
  exit 1
fi
票数 2
EN

Stack Overflow用户

发布于 2015-09-27 04:43:04

我可以确认版本5.0.4的install.sh脚本中仍然存在这个问题,而且德里克的解决方案仍然不错。我在下面的代码示例中包含了相关的片段:

代码语言:javascript
运行
复制
27  PACKAGE="VBoxGuestAdditions"
...
32  INSTALLATION_VER="5.0.4"
33  INSTALLATION_REV="102546"
...
38  INSTALLATION_DIR="/opt/$PACKAGE-$INSTALLATION_VER"
...
324 INSTALLATION_MODULES_DIR="$INSTALLATION_DIR/installer/"
...
329 mkdir -p -m 755 "$INSTALLATION_MODULES_DIR"
...
343 test ! -d "$INSTALLATION_DIR" && REMOVE_INSTALLATION_DIR=1
344 mkdir -p -m 755 "$INSTALLATION_DIR"
...
531 test -n "$REMOVE_INSTALLATION_DIR" &&
532   echo "$INSTALLATION_DIR/" >> "$CONFIG_DIR/$CONFIG/FILES"

REMOVE_INSTALLATION_DIR永远不会在第343行上设置为1,因为INSTALLATION_DIR是为第329行的INSTALLATION_MODULES_DIR创建的(作为父目录)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25434139

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档