Update copy_site.rake.
This commit is contained in:
parent
071c349f06
commit
c2d298f14b
|
@ -51,14 +51,14 @@ namespace :create_site do
|
|||
ls_out = exec_ssh_command_for_copy(ssh, "ls #{@site_construct.full_site_path}/app").join("\n")
|
||||
if ls_out.include?("No such") || org_creating
|
||||
if @site_construct.server_type == template_site.server_type
|
||||
exec_ssh_command_for_copy(ssh,"rsync -arv --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 --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
|
||||
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 -arv --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 --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")
|
||||
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_for_copy(ssh,"sshpass -p \"#{server.password}\" rsync -arv --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)
|
||||
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)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -77,7 +77,7 @@ namespace :create_site do
|
|||
exec_ssh_command_by_sudo_for_copy(ssh,"rm -rf #{args.path}/#{@site_construct.get_site_name}/dump_xxxx")
|
||||
else
|
||||
exec_ssh_command_by_sudo_for_copy(ssh,"sshpass -p '#{server.password}' ssh #{server.account}@#{server.ip} 'mongodump -d #{template_site.db_name} -o #{template_site.path}/#{template_site.site_name}/dump_xxxx'")
|
||||
exec_ssh_command_for_copy(ssh,"sshpass -p \"#{server.password}\" rsync -arv --info=progress2 --no-inc-recursive --delete #{server.account}@#{server.ip}:#{template_site.path}/#{template_site.get_site_name}/dump_xxxx/ #{args.path}/#{args.site_name}/dump_xxxx/")
|
||||
exec_ssh_command_for_copy(ssh,"sshpass -p \"#{server.password}\" rsync -ar --info=progress2 --no-inc-recursive --delete #{server.account}@#{server.ip}:#{template_site.path}/#{template_site.get_site_name}/dump_xxxx/ #{args.path}/#{args.site_name}/dump_xxxx/")
|
||||
exec_ssh_command_by_sudo_for_copy(ssh,"mongorestore --drop -d #{args.db_name} #{args.path}/#{@site_construct.get_site_name}/dump_xxxx/#{template_site.db_name}")
|
||||
exec_ssh_command_by_sudo_for_copy(ssh,"rm -rf #{args.path}/#{@site_construct.get_site_name}/dump_xxxx")
|
||||
exec_ssh_command_by_sudo_for_copy(ssh,"sshpass -p '#{server.password}' ssh #{server.account}@#{server.ip} 'rm -rf #{template_site.path}/#{template_site.get_site_name}/dump_xxxx'")
|
||||
|
@ -97,10 +97,10 @@ namespace :create_site do
|
|||
absolute_path = (path[0] == "/") ? path : ("#{template_site.path}/#{template_site.get_site_name}/#{path}")
|
||||
absolute_path = (absolute_path[-1] == "/") ? absolute_path : (absolute_path + "/")
|
||||
if @site_construct.server_type == template_site.server_type
|
||||
exec_ssh_command_for_copy(ssh,"rsync -arv --info=progress2 --no-inc-recursive --delete #{absolute_path} #{args.path}/#{args.site_name}/#{Pathname.new(absolute_path).basename}/")
|
||||
exec_ssh_command_for_copy(ssh,"rsync -ar --info=progress2 --no-inc-recursive --delete #{absolute_path} #{args.path}/#{args.site_name}/#{Pathname.new(absolute_path).basename}/")
|
||||
else
|
||||
server = SiteServer.where(:server_name => template_site.server_type).first
|
||||
exec_ssh_command_for_copy(ssh,"sshpass -p \"#{server.password}\" rsync -arv --info=progress2 --no-inc-recursive --delete #{server.account}@#{server.ip}:#{absolute_path} #{args.path}/#{args.site_name}/#{Pathname.new(absolute_path).basename}/")
|
||||
exec_ssh_command_for_copy(ssh,"sshpass -p \"#{server.password}\" rsync -ar --info=progress2 --no-inc-recursive --delete #{server.account}@#{server.ip}:#{absolute_path} #{args.path}/#{args.site_name}/#{Pathname.new(absolute_path).basename}/")
|
||||
end
|
||||
outputs = outputs.gsub(path,"#{args.path}/#{args.site_name}/#{Pathname.new(absolute_path).basename}/")
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue