Repairing NGINX errors caused by changing the domain name
This commit is contained in:
parent
3c3a73840f
commit
ee4cdedb56
|
|
@ -1,5 +1,6 @@
|
|||
require 'net/ssh'
|
||||
require 'pathname'
|
||||
require 'base64'
|
||||
namespace :create_site do
|
||||
desc "Create Site Script"
|
||||
task :create_site,[:git_template_url,:git_extension_url,:git_url,:ip, :server_port,:user,:password,:site_name,:domain_name,:port,:db_name,:path,:site_construct_id] => :environment do |task,args|
|
||||
|
|
@ -32,8 +33,8 @@ namespace :create_site do
|
|||
Net::SSH.start(args.ip , args.user , { password: args.password, port: args.server_port}) do |ssh|
|
||||
update_infos("Setting nginx for #{args.site_name}")
|
||||
nginx_setting_texts = @site_construct.generate_nginx_text
|
||||
exec_ssh_command_by_sudo_for_create(ssh,"touch /etc/nginx/orbit_sites/#{@site_construct.get_site_name}")
|
||||
exec_ssh_command_by_sudo_for_create(ssh,"x='#{nginx_setting_texts.gsub(/'{1,3}/,"\"\'\"")}'; echo '#{@password}' | sudo -S sh -c \"echo '$x' > /etc/nginx/orbit_sites/#{@site_construct.get_site_name}\"")
|
||||
base64_config = Base64.strict_encode64(nginx_setting_texts)
|
||||
exec_ssh_command_by_sudo_for_create(ssh, "echo '#{base64_config}' | base64 --decode | sudo -p 'sudo password:' tee /etc/nginx/orbit_sites/#{@site_construct.get_site_name}")
|
||||
update_infos("Restarting nginx")
|
||||
exec_ssh_command_by_sudo_for_create(ssh,"sudo -p 'sudo password:' service nginx restart")
|
||||
update_infos("Finish restarting nginx")
|
||||
|
|
|
|||
Loading…
Reference in New Issue