Fix bug.
This commit is contained in:
parent
b93bf910d2
commit
2d0d00f8ba
|
@ -24,14 +24,14 @@ namespace :create_site do
|
||||||
@site_construct.update(:status=>"creating")
|
@site_construct.update(:status=>"creating")
|
||||||
@site_construct.update!(:infos=>[])
|
@site_construct.update!(:infos=>[])
|
||||||
begin
|
begin
|
||||||
Net::SSH.start(args.ip , args.user , { password: args.password, port: args.server_port}) do |ssh|
|
Net::SSH.start(args.ip , args.user , { password: @password, port: args.server_port}) do |ssh|
|
||||||
end
|
end
|
||||||
rescue Net::SSH::HostKeyMismatch
|
rescue Net::SSH::HostKeyMismatch
|
||||||
system("ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{args.ip}")
|
system("ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{args.ip}")
|
||||||
rescue Errno::ENOTTY
|
rescue Errno::ENOTTY
|
||||||
system("ssh-add \"$HOME/.ssh/id_rsa\"")
|
system("ssh-add \"$HOME/.ssh/id_rsa\"")
|
||||||
end
|
end
|
||||||
Net::SSH.start(args.ip , args.user , { password: args.password, port: args.server_port}) do |ssh|
|
Net::SSH.start(args.ip , args.user , { password: @password, port: args.server_port}) do |ssh|
|
||||||
update_infos("Setting nginx for #{args.site_name}")
|
update_infos("Setting nginx for #{args.site_name}")
|
||||||
nginx_setting_texts = @site_construct.generate_nginx_text
|
nginx_setting_texts = @site_construct.generate_nginx_text
|
||||||
exec_ssh_command_by_sudo_for_copy(ssh,"touch /etc/nginx/orbit_sites/#{@site_construct.get_site_name}")
|
exec_ssh_command_by_sudo_for_copy(ssh,"touch /etc/nginx/orbit_sites/#{@site_construct.get_site_name}")
|
||||||
|
@ -50,10 +50,10 @@ namespace :create_site do
|
||||||
ls_out = exec_ssh_command_for_copy(ssh, "if [ ! -d \"#{@site_construct.full_site_path}/app\" ]; then echo 'No such file or directory: #{@site_construct.full_site_path}/app'; fi", false).join("\n")
|
ls_out = exec_ssh_command_for_copy(ssh, "if [ ! -d \"#{@site_construct.full_site_path}/app\" ]; then echo 'No such file or directory: #{@site_construct.full_site_path}/app'; fi", false).join("\n")
|
||||||
if ls_out.include?("No such file or directory") || org_creating
|
if ls_out.include?("No such file or directory") || org_creating
|
||||||
if @site_construct.server_type == template_site.server_type
|
if @site_construct.server_type == template_site.server_type
|
||||||
exec_ssh_command_for_copy(ssh,"rsync -ar --info=progress2 --no-inc-recursive --delete --exclude={tmp/cache/,tmp/unicorn.sock,tmp/pids/*#{extra_exclude_path}} #{template_site.path}/#{template_site.get_site_name}/ #{args.path}/#{@site_construct.get_site_name}/",true)
|
exec_ssh_command_for_copy(ssh,"rsync -ar -e 'ssh -o \"StrictHostKeyChecking=no\" -p 22' --info=progress2 --no-inc-recursive --delete --exclude={tmp/cache/,tmp/unicorn.sock,tmp/pids/*#{extra_exclude_path}} #{template_site.path}/#{template_site.get_site_name}/ #{args.path}/#{@site_construct.get_site_name}/",true)
|
||||||
else
|
else
|
||||||
exec_ssh_command_for_copy(ssh,"sudo -p 'sudo password:' apt-get install -y sshpass")
|
exec_ssh_command_for_copy(ssh,"sudo -p 'sudo password:' apt-get install -y sshpass")
|
||||||
outputs = exec_ssh_command_for_copy(ssh,"sshpass -p \"#{server.password}\" rsync -ar --info=progress2 --no-inc-recursive --delete --exclude={tmp/cache/,tmp/unicorn.sock,tmp/pids/*#{extra_exclude_path}} #{server.account}@#{server.ip}:#{template_site.path}/#{template_site.get_site_name}/ #{args.path}/#{@site_construct.get_site_name}/",true)
|
outputs = exec_ssh_command_for_copy(ssh,"sshpass -p \"#{server.password}\" rsync -ar -e 'ssh -o \"StrictHostKeyChecking=no\" -p 22' --info=progress2 --no-inc-recursive --delete --exclude={tmp/cache/,tmp/unicorn.sock,tmp/pids/*#{extra_exclude_path}} #{server.account}@#{server.ip}:#{template_site.path}/#{template_site.get_site_name}/ #{args.path}/#{@site_construct.get_site_name}/",true)
|
||||||
if outputs.join("\n").include?("Host key verification failed")
|
if outputs.join("\n").include?("Host key verification failed")
|
||||||
exec_ssh_command_by_sudo_for_copy(ssh,"ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{server.ip}")
|
exec_ssh_command_by_sudo_for_copy(ssh,"ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{server.ip}")
|
||||||
exec_ssh_command_by_sudo_for_copy(ssh,"ssh-keyscan -H #{server.ip} >> ~/.ssh/known_hosts")
|
exec_ssh_command_by_sudo_for_copy(ssh,"ssh-keyscan -H #{server.ip} >> ~/.ssh/known_hosts")
|
||||||
|
|
Loading…
Reference in New Issue