Fix bug.
This commit is contained in:
parent
f40b9bd3f3
commit
a543d6be8f
|
@ -110,8 +110,14 @@ class Admin::SitePanelController < OrbitAdminController
|
|||
db_name = site_construct.db_name
|
||||
path = site_construct.path
|
||||
site_construct_id = params[:id]
|
||||
Thread.new do
|
||||
system("bundle exec rake create_site:create_site['#{git_template_url}','#{git_extension_url}','#{git_url}','#{ip}','#{user}','#{password}','#{site_name}','#{domain_name}','#{port}','#{db_name}','#{path}','#{site_construct_id}']")
|
||||
if site_construct.copy_id
|
||||
Thread.new do
|
||||
system("bundle exec rake create_site:copy_site['#{ip}','#{user}','#{password}','#{site_name}','#{domain_name}','#{port}','#{db_name}','#{path}','#{site_construct_id}','#{site_construct.copy_id}']")
|
||||
end
|
||||
else
|
||||
Thread.new do
|
||||
system("bundle exec rake create_site:create_site['#{git_template_url}','#{git_extension_url}','#{git_url}','#{ip}','#{user}','#{password}','#{site_name}','#{domain_name}','#{port}','#{db_name}','#{path}','#{site_construct_id}']")
|
||||
end
|
||||
end
|
||||
render :json =>{"success"=>true}
|
||||
end
|
||||
|
@ -173,8 +179,6 @@ class Admin::SitePanelController < OrbitAdminController
|
|||
|
||||
def site_construct_params
|
||||
site_construct_params = params.require(:site_construct).permit!
|
||||
site_construct_params = site_construct_params.except(:copy_id)
|
||||
return site_construct_params
|
||||
end
|
||||
def site_server_params
|
||||
params.require(:site_server).permit!
|
||||
|
|
|
@ -20,6 +20,7 @@ class SiteConstruct
|
|||
field :status, type: String, :default => ""
|
||||
field :infos, type: Array, :default => []
|
||||
field :hidden, type: Boolean, :default => false
|
||||
field :copy_id
|
||||
after_initialize do |record|
|
||||
if record.status.nil?
|
||||
record.status = ""
|
||||
|
|
|
@ -94,6 +94,32 @@ namespace :create_site do
|
|||
end
|
||||
update_infos("Finish copying database!")
|
||||
|
||||
update_infos("Checking extensions!")
|
||||
extensions = ["downloaded_extensions.rb","built_in_extensions.rb"]
|
||||
extensions.each do |extension_file|
|
||||
outputs = exec_ssh_command_by_sudo_for_create(ssh,"cat #{args.path}/#{@site_construct.get_site_name}/#{extension_file}")
|
||||
if !outputs.include?("No such file or directory")
|
||||
read_lines = outputs.split("\n").map{|l| l.split('#').first}
|
||||
include_path_lines = read_lines.select{|l| l.include?("path")}
|
||||
include_path_lines.each do |line|
|
||||
path = line.split(/[:>]/).last.gsub(/[\'\"]/,"").strip
|
||||
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_create(ssh,"rsync -arv --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_create(ssh,"sshpass -p \"#{server.password}\" rsync -arv --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
|
||||
if include_path_lines.count != 0
|
||||
exec_ssh_command_by_sudo_for_create(ssh,"sh -c \"echo '#{outputs.gsub("'","\\\"")}' > #{args.path}/#{@site_construct.get_site_name}/#{extension_file}\"")
|
||||
end
|
||||
end
|
||||
end
|
||||
update_infos("Finish checking extensions!")
|
||||
|
||||
update_infos("execing bundle install...")
|
||||
exec_ssh_command_by_sudo_for_create(ssh,"bash -l -c 'cd #{args.path}/#{@site_construct.get_site_name}\nbundle install'",true)
|
||||
exec_ssh_command_by_sudo_for_create(ssh,"bash -l -c 'cd #{args.path}/#{@site_construct.get_site_name}\nbundle install'")
|
||||
|
|
Loading…
Reference in New Issue