capistrano 使用 sudo 运行内部命令
我们的 capistrano 设置是:使用普通用户 ssh,但部署到需要 sudo 权限才能创建文件的位置。
我想运行特定的 capistrano 命令 run "cd #{configuration[:releases_path]} && #{decompress(remote_filename).join(" ")} && rm #{remote_filename}"< /代码> 使用 sudo。有没有一种巧妙的方法来超越它?
def distribute!
upload(filename, remote_filename)
run "cd #{configuration[:releases_path]} && #{decompress(remote_filename).join(" ")} && rm #{remote_filename}"
end
Our capistrano setup is: ssh with regular user, but deploy to a location requiring sudo permissions to create files.
I want to run the specific capistrano command run "cd #{configuration[:releases_path]} && #{decompress(remote_filename).join(" ")} && rm #{remote_filename}"
using sudo. Is there a neat way to over ride it?
def distribute!
upload(filename, remote_filename)
run "cd #{configuration[:releases_path]} && #{decompress(remote_filename).join(" ")} && rm #{remote_filename}"
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信你可以在 capistrano 中使用“sudo”功能,例如
I believe you can use the "sudo" function inside capistrano e.g.
以下解决方法使其有效。
在“deploy:update_code”、“deploy:self_own_dirs”之前
The following workaround made it work.
before 'deploy:update_code', 'deploy:self_own_dirs'