Fix quotation mark errors caused by translation
This commit is contained in:
parent
c54876f439
commit
539354f792
|
|
@ -26,17 +26,28 @@ namespace :create_site do
|
|||
puts [e,e.backtrace]
|
||||
end
|
||||
end
|
||||
def change_construct_nginx(ssh,site_construct,update_multithread=false)
|
||||
def change_construct_nginx(ssh, site_construct, update_multithread=false)
|
||||
@is_multithread = update_multithread
|
||||
auto_update_infos("Reading setting file...")
|
||||
nginx_file_content = exec_command_by_user(ssh,"cat #{site_construct.nginx_file}")
|
||||
nginx_file_content = site_construct.generate_nginx_text(nginx_file_content)
|
||||
auto_update_infos("Writing...")
|
||||
cmd = "x='#{nginx_file_content.gsub("\\$","$").gsub(/'{1,3}/,"\"\'\"")}'; 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")
|
||||
raw_content = exec_command_by_user(ssh, "cat #{site_construct.nginx_file}")
|
||||
nginx_file_content = site_construct.generate_nginx_text(raw_content)
|
||||
auto_update_infos("Writing via safe stream...")
|
||||
ssh.open_channel do |channel|
|
||||
channel.exec("sudo -S sh -c 'cat > #{site_construct.nginx_file}'") do |ch, success|
|
||||
ch.on_extended_data do |c, type, data|
|
||||
if data =~ /password/i
|
||||
c.send_data("#{@password}\n")
|
||||
end
|
||||
end
|
||||
ch.send_data(nginx_file_content)
|
||||
ch.eof!
|
||||
end
|
||||
end
|
||||
ssh.loop
|
||||
exec_ssh_command_by_sudo(ssh, "service nginx restart")
|
||||
auto_update_infos("Finish!")
|
||||
end
|
||||
end
|
||||
|
||||
def exec_command_by_user(session,command)
|
||||
output = session.exec!(command)
|
||||
return output[0...-1].gsub(/^\n[\n]+/,'')
|
||||
|
|
|
|||
Loading…
Reference in New Issue