【问题标题】:Capistrano: cap staging git:check - how to configure ssh path in git-ssh.sh?Capistrano: cap staging git:check - 如何在 git-ssh.sh 中配置 ssh 路径?
【发布时间】:2014-09-03 11:28:31
【问题描述】:

我想弄清楚如何在执行部署命令后通过 capistrano 复制到服务器的git-ssh.sh 文件中设置 ssh 的路径。

其实 git-ssh.sh 的第二行是这样的:

exec /usr/bin/ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no "$@"

我不能直接在服务器上执行这个命令。出现以下错误:

[5b4fcea9] /tmp/app.de/git-ssh.sh: line 2: /usr/bin/ssh: No such file or directory

在编辑/usr/local/bin/ssh 的 ssh 路径后,它运行良好,但 capistrano 每次调用 cap staging deploy 时都会上传此文件。

有关更多详细信息,请参阅我的 Pastie 日志,特别是在 git:check 部分: http://pastie.org/9523811

可以在我的 deploy.rb 中设置这个路径吗?

感谢和欢呼 米尔科

【问题讨论】:

    标签: ssh capistrano3


    【解决方案1】:

    是的,我明白了。 :))

    Rake::Task["deploy:check"].clear_actions
    
    namespace :deploy do
        task check: :'git:wrapper'  do
            on release_roles :all do
                execute :mkdir, "-p", "#{fetch(:tmp_dir)}/#{fetch(:application)}/"
                upload! StringIO.new("#!/bin/sh -e\nexec /usr/local/bin/ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no \"$@\"\n"), "#{fetch(:tmp_dir)}/#{fetch(:application)}/git-ssh.sh"
                execute :chmod, "+x", "#{fetch(:tmp_dir)}/#{fetch(:application)}/git-ssh.sh"
            end
        end
    end
    

    【讨论】:

      【解决方案2】:

      这一行似乎是在 capistrano 源代码 link here 中硬编码的。

      您为什么不在服务器上创建/usr/bin/ssh 符号链接,而不是更改 capistrano 源?所以这个:

      ln -s /usr/local/bin/ssh /usr/bin/ssh
      

      这将创建一个/usr/bin/ssh 符号链接,执行时将运行/usr/local/bin/ssh

      【讨论】:

      • 二进制文件是硬编码且不可配置的有什么原因吗?
      【解决方案3】:

      如果你在 Capfile 中添加以下行,你可以覆盖 git 任务:

      require 'capistrano/git'
      

      【讨论】:

      • 这似乎没有回答原来的问题
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-29
      • 2016-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多