fix error for changing server name

This commit is contained in:
邱博亞 2021-02-19 17:20:13 +08:00
parent cb7deed4ac
commit 2a2ed90114
1 changed files with 2 additions and 2 deletions

View File

@ -12,8 +12,8 @@ namespace :create_site do
nginx_file_content = exec_command_by_user(ssh,"cat #{site_construct.nginx_file}")
nginx_file_content = nginx_file_content.gsub(/^[ \t]*server_name[ \t]+.*;/," server_name #{args.server_name};").gsub('$','\$')
puts nginx_file_content
cmd = "sh -c \"echo '#{nginx_file_content}' > #{site_construct.nginx_file}\""
exec_ssh_command_by_sudo(ssh,cmd)
cmd = "x='#{nginx_file_content}'; echo '#{@password}' | sudo -S sh -c \"echo '$x' > #{site_construct.nginx_file}\""
exec_command_by_user(ssh,cmd)
exec_ssh_command_by_sudo(ssh,"service nginx restart")
end
site_construct.update_attributes(domain_name: args.server_name)