diff --git a/lib/tasks/change_site_server_name.rake b/lib/tasks/change_site_server_name.rake index 254fa37..fc0a40a 100644 --- a/lib/tasks/change_site_server_name.rake +++ b/lib/tasks/change_site_server_name.rake @@ -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)