gpt4 book ai didi

chef-infra - 如何在 Chef Recipe 中转换以下Shell命令?

转载 作者:行者123 更新时间:2023-12-01 06:15:08 26 4
gpt4 key购买 nike

如何在厨师食谱中转换以下Shell命令?

安装

sudo easy_install pygments
sudo echo 'export RAILS_ENV=production' >> ~/.bash_profile
sudo adduser --system --shell /bin/sh --gecos 'git version control' --group --disabled-password --home /home/git git
ssh-keygen -t rsa
sudo -H -u git gitosis-init < ~/.ssh/id_rsa.pub
sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update

echo "gem: --no-rdoc --no-ri" > ~/.gemrc
rvmsudo gem install passenger
rvmsudo passenger-install-nginx-module

为Nginx创建Upstart文件

须藤vim /etc/init/nginx.conf
description "Nginx HTTP Server"

start on filesystem
stop on runlevel [!2345]

respawn

exec /opt/nginx/sbin/nginx -g "daemon off;"

重新启动虚拟机
sudo shutdown -r now

验证Nginx是否正在运行
sudo initctl list | grep nginx

最佳答案

这不一定是执行此操作的理想方法,但它应该可以工作(请注意,我尚未测试)。

在菜谱的元数据中,首先请确保您具有以下内容:

depends "python"

那么您的食谱可以如下所示:
pip_package "pygments"

execute "echo 'export RAILS_ENV=production' >> ~/.bash_profile" do
not_if "grep RAILS_ENV ~/.bash_profile"
end

user "git" do
system True
end

execute "ssh-keygen -N '' -f ~/.ssh/id_rsa"
user "git"
not_if "test -f /home/git/.ssh/id_rsa"
end

execute "gitosis-init < ~/.ssh/id_rsa.pub && chmod 755 ~/repositories/gitosis-admin.git/hooks/postupdate"
#not sure how do check if this has been run, maybe this is right:
not_if "test -f /home/git/repositories/gitosis-admin.git/hooks/post-update"
end

gem_package "passenger" do
action :install
end

#Instead of creating your own upstart service, why not use the stock nginx config.
include_recipe "nginx"

execute "passenger-install-nginx-module" do
#I'm not familiar with this, so I don't know how to check if it's already been run.
notifies :restart, "service[nginx]"
end

大部分信息应该可以从厨师文档btw轻松访问。

关于chef-infra - 如何在 Chef Recipe 中转换以下Shell命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8389972/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com