Chef Recipe - 在Ubuntu上安装DropBox的交互式响应

时间:2018-04-18 05:01:35

标签: installation chef ubuntu-16.04 dropbox recipe

我是厨师的新手,并试图通过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”它不在那里,所以我不知道如何解决这个问题。 / p>

提前致谢!

1 个答案:

答案 0 :(得分:0)

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