【问题标题】:Chef Recipe - interactive responses for DropBox install on UbuntuChef Recipe - 在 Ubuntu 上安装 DropBox 的交互式响应
【发布时间】:2018-05-06 08:03:35
【问题描述】:

我是 Chef 的新手,正在尝试学习如何通过 CLI 提供安装脚本的答案。我运气不好,希望能得到一些帮助吗?

  bash 'DropboxInstall' do 
  user 'root'
  cwd  '/opt/dropbox'
  code <<-EOH
       dropbox start -i
       expect "Starting Dropbox...\rDropbox is the easiest way to share and store your files online. Want to learn more? Head to https://www.dropbox.com/\rIn order to use Dropbox, you must download the proprietary daemon. [y/n]"
       send "y\r"
       dropbox autostart y
  EOH
end

我得到的错误是:

  * bash[DropboxInstall] action run[2018-04-23T07:47:53+00:00] INFO: Processing bash[DropboxInstall] action run (dropbox::default line 24)
[2018-04-23T07:47:53+00:00] DEBUG: Providers for generic bash resource enabled on node include: [Chef::Provider::Script]
[2018-04-23T07:47:53+00:00] DEBUG: Provider for action run on resource bash[DropboxInstall] is Chef::Provider::Script

    [execute] Starting Dropbox...dropbox: locating interpreter
              dropbox: logging to /tmp/dropbox-antifreeze-umikIQ
              dropbox: initializing
              dropbox: initializing python 2.7.11
              dropbox: setting program path '/root/.dropbox-dist/dropbox-lnx.x86_64-47.4.74/dropbox'
              dropbox: setting home path '/root/.dropbox-dist/dropbox-lnx.x86_64-47.4.74'
              dropbox: setting python path '/root/.dropbox-dist/dropbox-lnx.x86_64-47.4.74:/root/.dropbox-dist/dropbox-lnx.x86_64-47.4.74/python-packages-27.zip'
              dropbox: python initialized
              dropbox: running dropbox
              dropbox: setting args
              dropbox: applying overrides
              dropbox: running main script
              dropbox: load fq extension '/root/.dropbox-dist/dropbox-lnx.x86_64-47.4.74/cryptography.hazmat.bindings._constant_time.so'
              dropbox: load fq extension '/root/.dropbox-dist/dropbox-lnx.x86_64-47.4.74/cryptography.hazmat.bindings._openssl.so'
              dropbox: load fq extension '/root/.dropbox-dist/dropbox-lnx.x86_64-47.4.74/cryptography.hazmat.bindings._padding.so'
              dropbox: load fq extension '/root/.dropbox-dist/dropbox-lnx.x86_64-47.4.74/psutil._psutil_linux.so'
              dropbox: load fq extension '/root/.dropbox-dist/dropbox-lnx.x86_64-47.4.74/psutil._psutil_posix.so'
              dropbox: load fq extension '/root/.dropbox-dist/dropbox-lnx.x86_64-47.4.74/linuxffi.pthread._linuxffi_pthread.so'
              dropbox: load fq extension '/root/.dropbox-dist/dropbox-lnx.x86_64-47.4.74/tornado.speedups.so'
              dropbox: load fq extension '/root/.dropbox-dist/dropbox-lnx.x86_64-47.4.74/cpuid.compiled._cpuid.so'
              dropbox: load fq extension '/root/.dropbox-dist/dropbox-lnx.x86_64-47.4.74/linuxffi.resolv.compiled._linuxffi_resolv.so'
              dropbox: load fq extension '/root/.dropbox-dist/dropbox-lnx.x86_64-47.4.74/linuxffi.sys.compiled._linuxffi_sys.so'
              dropbox: load fq extension '/root/.dropbox-dist/dropbox-lnx.x86_64-47.4.74/posixffi.libc._posixffi_libc.so'
              dropbox: load fq extension '/root/.dropbox-dist/dropbox-lnx.x86_64-47.4.74/librsyncffi.compiled._librsyncffi.so'

Chef 脚本正在完成安装,但是当它尝试从 CLI 执行“expect”时它会死机:

              Dropbox is the easiest way to share and store your files online. Want to learn more? Head to https://www.dropbox.com/

              In order to use Dropbox, you must download the proprietary daemon. [y/n] Traceback (most recent call last):
                File "/usr/bin/dropbox", line 1404, in start
                  download()
                File "/usr/bin/dropbox", line 547, in download
                  if not yes_no_question("%s%s" % (WARNING, GPG_WARNING_MSG)):
                File "/usr/bin/dropbox", line 138, in yes_no_question
                  text = raw_input()
              EOFError: EOF when reading a line
              ****/tmp/chef-script20180423-29717-15l42km: line 2: expect: command not found
              /tmp/chef-script20180423-29717-15l42km: line 3: send: command not found****
[2018-04-23T07:48:54+00:00] INFO: bash[DropboxInstall] ran successfully
    - execute "bash"  "/tmp/chef-script20180423-29717-15l42km"

我毫不怀疑是我自己,但我已经阅读了一些内容,但不知道如何最好地解决这个问题。看起来当它尝试执行 bash 脚本时出现问题,但我尝试“cat /tmp/chef-script20180423-29717-15l42km”它不存在,所以我不知道如何解决这个问题。

提前致谢!

【问题讨论】:

  • 你在显示实际失败之前切断了错误信息。
  • 您好,感谢您的回复,我更新了整个调试块。任何想法都会非常感激。
  • 另外,“为了使用 Dropbox,您必须下载专有的守护程序。”提示在大约 30 秒后出现是否重要?谢谢!
  • 您似乎在尝试混合 shell 命令和期望命令?您所拥有的是一个 bash 脚本,因此它按顺序运行命令,而不是在 TTY 中。
  • 您好 coderanger,谢谢!我最终作弊了一点,使用了expect和TCL。根据我所阅读的内容,它并不是最好的或推荐的方式,但 Dropbox 安装程序没有答案文件或无人值守的安装选项:-/ 谢谢队友,我很感激!如果这对其他人有帮助,请随意使用:

标签: installation chef-infra ubuntu-16.04 dropbox recipe


【解决方案1】:
file '/tmp/dropbox.sh' do
      mode '0755'
      owner 'root'
      group 'root'
      content 'puts "Running Dropbox Installer..."
               log_user 0
               spawn dropbox start -i
               expect {
                       "*In order to use Dropbox, you must download the proprietary daemon*" {send "y\r"}
                      }
               exec sleep 360
                       puts "Dropbox installer completed"'
    end

    bash 'DropboxInstall' do
      user 'root'
      cwd  '/tmp'
      code <<-EOF
      /usr/bin/expect -d dropbox.sh
      EOF
    end

【讨论】:

    猜你喜欢
    • 2015-12-30
    • 1970-01-01
    • 2022-01-20
    • 1970-01-01
    • 1970-01-01
    • 2014-10-18
    • 2013-01-30
    • 1970-01-01
    • 2015-04-22
    相关资源
    最近更新 更多