Automatically replace the current domain when copying.
This commit is contained in:
parent
1478a3f10e
commit
c54876f439
|
|
@ -109,6 +109,32 @@ namespace :create_site do
|
|||
end
|
||||
update_infos("Finish checking extensions!")
|
||||
|
||||
# === 新增:網域自動更換 ===
|
||||
begin
|
||||
_target_path = File.join(args.path.to_s, @site_construct.get_site_name.to_s)
|
||||
|
||||
_exclude = "--exclude-dir={log,tmp,public/system,public/uploads,.git,node_modules,dump_xxxx}"
|
||||
|
||||
_dns_pairs = {
|
||||
"ruling.digital" => "orbithub.cloud",
|
||||
"gitlab.tp.rulingcom.com" => "orbitgit.cloud"
|
||||
}
|
||||
|
||||
_dns_pairs.each do |old_dns, new_dns|
|
||||
_esc_old = old_dns.gsub('.', '\.')
|
||||
|
||||
_grep_base = "grep -rIil #{_exclude} '#{old_dns}' #{_target_path}"
|
||||
_safe_cmd = "#{_grep_base} | xargs -rI {} sh -c \"echo '#{@password}' | sudo -S sed -i 's/#{_esc_old}/#{new_dns}/g' {}\""
|
||||
|
||||
update_infos("Replacing domain: #{old_dns} -> #{new_dns}")
|
||||
exec_ssh_command_by_sudo_for_copy(ssh, _safe_cmd)
|
||||
end
|
||||
|
||||
update_infos("Finish cleaning source code domains!")
|
||||
rescue => e
|
||||
update_infos("Domain cleaning skipped or failed: #{e.message}")
|
||||
end
|
||||
# === 修改結束 ===
|
||||
update_infos("Execing bundle install...")
|
||||
exec_ssh_command_by_sudo_for_copy(ssh,"bash -l -c 'cd #{args.path}/#{@site_construct.get_site_name}\nrm -f Gemfile.lock tmp/unicorn_rails.sock tmp/unicorn_roda.sock tmp/unicorn.sock\nbundle install'",true)
|
||||
exec_ssh_command_by_sudo_for_copy(ssh,"bash -l -c 'cd #{args.path}/#{@site_construct.get_site_name}\nrm -f Gemfile.lock tmp/unicorn_rails.sock tmp/unicorn_roda.sock tmp/unicorn.sock\nbundle install'")
|
||||
|
|
|
|||
Loading…
Reference in New Issue