Fix bug.
This commit is contained in:
parent
1ca691dd4d
commit
37fafc48e6
|
@ -1,6 +1,7 @@
|
||||||
require 'net/ssh'
|
require 'net/ssh'
|
||||||
require 'pathname'
|
require 'pathname'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
require "resolv"
|
||||||
namespace :create_site do
|
namespace :create_site do
|
||||||
desc "Detect sites"
|
desc "Detect sites"
|
||||||
task :detect_sites,[:detect_name] => :environment do |task,args|
|
task :detect_sites,[:detect_name] => :environment do |task,args|
|
||||||
|
@ -55,14 +56,23 @@ namespace :create_site do
|
||||||
server_names_array = server_names_array.group_by{|v| v[0]}
|
server_names_array = server_names_array.group_by{|v| v[0]}
|
||||||
|
|
||||||
server_names_array.each do |nginx_file, server_name_with_file|
|
server_names_array.each do |nginx_file, server_name_with_file|
|
||||||
server_names_for_site = server_name_with_file.map{|v| v[1].split(/[ |\t]+/)}.flatten.uniq - ["localhost","127.0.0.1"]
|
org_server_names_for_site = server_name_with_file.map{|v| v[1].split(/[ |\t]+/)}.flatten.uniq
|
||||||
|
server_names_for_site = org_server_names_for_site - ["localhost","127.0.0.1"]
|
||||||
server_name_list = []
|
server_name_list = []
|
||||||
server_names_for_site.each do |server_name_for_site|
|
server_names_for_site.each do |server_name_for_site|
|
||||||
if !server_name_for_site.include?(domain_name)
|
if !server_name_for_site.include?(domain_name)
|
||||||
|
if server_name_for_site.match(Regexp.union(Resolv::IPv4::Regex, Resolv::IPv6::Regex)).nil? #Not filter IP address
|
||||||
next if !`nslookup "#{server_name_for_site}"`.include?(@site_server.ip)
|
next if !`nslookup "#{server_name_for_site}"`.include?(@site_server.ip)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
server_name_list << server_name_for_site
|
server_name_list << server_name_for_site
|
||||||
end
|
end
|
||||||
|
if server_name_list.blank?
|
||||||
|
tmp = org_server_names_for_site & ["localhost","127.0.0.1"]
|
||||||
|
if (tmp).length != 0
|
||||||
|
server_name_list = tmp + [@site_server.ip]
|
||||||
|
end
|
||||||
|
end
|
||||||
server_name = server_name_list.join(' ')
|
server_name = server_name_list.join(' ')
|
||||||
nginx_file_content = exec_ssh_command_by_sudo_and_see_output(ssh,"cat #{nginx_file}",false,true)
|
nginx_file_content = exec_ssh_command_by_sudo_and_see_output(ssh,"cat #{nginx_file}",false,true)
|
||||||
site_path = Pathname.new(exec_ssh_command_by_sudo_and_see_output(ssh,"echo `grep root #{nginx_file} | grep -v -e '#.*root'`",false,true).to_s.split("\n").first.to_s.strip.split(";").select{|s| s.present? && s.include?("root")}.first.split("root").last.to_s.strip).dirname.to_s rescue nil
|
site_path = Pathname.new(exec_ssh_command_by_sudo_and_see_output(ssh,"echo `grep root #{nginx_file} | grep -v -e '#.*root'`",false,true).to_s.split("\n").first.to_s.strip.split(";").select{|s| s.present? && s.include?("root")}.first.split("root").last.to_s.strip).dirname.to_s rescue nil
|
||||||
|
|
Loading…
Reference in New Issue