Add port setting.
This commit is contained in:
parent
2a62d9b5d4
commit
637ffdc327
|
@ -277,6 +277,7 @@ class Admin::SitePanelController < OrbitAdminController
|
||||||
git_extension_url = "http://gitlab.tp.rulingcom.com/core/default-modules.git"
|
git_extension_url = "http://gitlab.tp.rulingcom.com/core/default-modules.git"
|
||||||
site_server = SiteServer.where(:server_name=>site_construct.server_type).first
|
site_server = SiteServer.where(:server_name=>site_construct.server_type).first
|
||||||
ip = site_server.ip
|
ip = site_server.ip
|
||||||
|
server_port = site_server.port
|
||||||
user = site_server.account
|
user = site_server.account
|
||||||
password = site_server.password
|
password = site_server.password
|
||||||
site_name = site_construct.site_name
|
site_name = site_construct.site_name
|
||||||
|
@ -287,11 +288,11 @@ class Admin::SitePanelController < OrbitAdminController
|
||||||
site_construct_id = site_construct.id.to_s
|
site_construct_id = site_construct.id.to_s
|
||||||
if params[:site_construct][:copy_id].blank?
|
if params[:site_construct][:copy_id].blank?
|
||||||
Thread.new do
|
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}']")
|
system("bundle exec rake create_site: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}']")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Thread.new do
|
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}','#{params[:site_construct][:copy_id]}',#{site_construct.only_copy_installed_module}]")
|
system("bundle exec rake create_site:copy_site['#{ip}','#{server_port}', #{user}','#{password}','#{site_name}','#{domain_name}','#{port}','#{db_name}','#{path}','#{site_construct_id}','#{params[:site_construct][:copy_id]}',#{site_construct.only_copy_installed_module}]")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
redirect_to "#{admin_site_panel_sites_list_path}?id=#{site_construct_id}"
|
redirect_to "#{admin_site_panel_sites_list_path}?id=#{site_construct_id}"
|
||||||
|
@ -307,6 +308,7 @@ class Admin::SitePanelController < OrbitAdminController
|
||||||
git_extension_url = "http://gitlab.tp.rulingcom.com/core/default-modules.git"
|
git_extension_url = "http://gitlab.tp.rulingcom.com/core/default-modules.git"
|
||||||
site_server = SiteServer.where(:server_name=>site_construct.server_type).first
|
site_server = SiteServer.where(:server_name=>site_construct.server_type).first
|
||||||
ip = site_server.ip
|
ip = site_server.ip
|
||||||
|
server_port = site_server.port
|
||||||
user = site_server.account
|
user = site_server.account
|
||||||
password = site_server.password
|
password = site_server.password
|
||||||
site_name = site_construct.site_name
|
site_name = site_construct.site_name
|
||||||
|
@ -317,11 +319,11 @@ class Admin::SitePanelController < OrbitAdminController
|
||||||
site_construct_id = params[:id]
|
site_construct_id = params[:id]
|
||||||
if site_construct.copy_id
|
if site_construct.copy_id
|
||||||
Thread.new do
|
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}',#{site_construct.only_copy_installed_module}]")
|
system("bundle exec rake create_site:copy_site['#{ip}','#{server_port}','#{user}','#{password}','#{site_name}','#{domain_name}','#{port}','#{db_name}','#{path}','#{site_construct_id}','#{site_construct.copy_id}',#{site_construct.only_copy_installed_module}]")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Thread.new do
|
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}']")
|
system("bundle exec rake create_site: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}']")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
render :json =>{"success"=>true}
|
render :json =>{"success"=>true}
|
||||||
|
|
|
@ -10,6 +10,7 @@ class SiteServer
|
||||||
field :domain_name , type: String ,default: ''
|
field :domain_name , type: String ,default: ''
|
||||||
field :domain_names, type: Array, default: []
|
field :domain_names, type: Array, default: []
|
||||||
field :ip , type: String , default: ''
|
field :ip , type: String , default: ''
|
||||||
|
field :port, type: String, default: '22'
|
||||||
field :account , type: String ,default: ''
|
field :account , type: String ,default: ''
|
||||||
field :password , type: String ,default: ''
|
field :password , type: String ,default: ''
|
||||||
field :active , type: Boolean ,default: true
|
field :active , type: Boolean ,default: true
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
<th>Sites amount</th>
|
<th>Sites amount</th>
|
||||||
<th>Server name</th>
|
<th>Server name</th>
|
||||||
<th>IP</th>
|
<th>IP</th>
|
||||||
|
<th>Port</th>
|
||||||
<th>Certbot</th>
|
<th>Certbot</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -48,6 +49,7 @@
|
||||||
</td>
|
</td>
|
||||||
<td><%=site_server.server_name%><%= '<span class="inactive-serv" title="inactive">X</span>'.html_safe if !(site_server.active) %></td>
|
<td><%=site_server.server_name%><%= '<span class="inactive-serv" title="inactive">X</span>'.html_safe if !(site_server.active) %></td>
|
||||||
<td><%=site_server.ip%></td>
|
<td><%=site_server.ip%></td>
|
||||||
|
<td><%=site_server.port%></td>
|
||||||
<td>
|
<td>
|
||||||
<% if site_server.has_certbot%>
|
<% if site_server.has_certbot%>
|
||||||
<span class="green_text"><%= t("client_management.alreay_install") %></span>
|
<span class="green_text"><%= t("client_management.alreay_install") %></span>
|
||||||
|
|
|
@ -124,6 +124,12 @@
|
||||||
<%= f.text_field :ip,{:id=>'ip'} %>
|
<%= f.text_field :ip,{:id=>'ip'} %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted" for="port">Port:</label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.text_field :port,{:id=>'port'} %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label muted" for="account">Account:</label>
|
<label class="control-label muted" for="account">Account:</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace :create_site do
|
||||||
site_server = site_construct.site_server
|
site_server = site_construct.site_server
|
||||||
if !site_server.nil? && !site_construct.cert_ver_location_path.blank? && !site_construct.cert_ver_file_content.nil?
|
if !site_server.nil? && !site_construct.cert_ver_location_path.blank? && !site_construct.cert_ver_file_content.nil?
|
||||||
@password = site_server.password
|
@password = site_server.password
|
||||||
Net::SSH.start(site_server.ip , site_server.account , password: site_server.password) do |ssh|
|
Net::SSH.start(site_server.ip , site_server.account , { password: site_server.password, port: site_server.port}) do |ssh|
|
||||||
nginx_path = site_construct.nginx_file
|
nginx_path = site_construct.nginx_file
|
||||||
cert_ver_file_content = site_construct.cert_ver_file_content
|
cert_ver_file_content = site_construct.cert_ver_file_content
|
||||||
location_path = site_construct.cert_ver_location_path
|
location_path = site_construct.cert_ver_location_path
|
||||||
|
|
|
@ -19,18 +19,19 @@ namespace :exec_commands do
|
||||||
@thread.update(:status=>{"infos"=>[],"status"=>"execing"})
|
@thread.update(:status=>{"infos"=>[],"status"=>"execing"})
|
||||||
end
|
end
|
||||||
ip = site_server.ip
|
ip = site_server.ip
|
||||||
|
server_port = site_server.port
|
||||||
user = site_server.account
|
user = site_server.account
|
||||||
password = site_server.password
|
password = site_server.password
|
||||||
@password = password
|
@password = password
|
||||||
begin
|
begin
|
||||||
Net::SSH.start(ip , user , password: password) do |ssh|
|
Net::SSH.start(ip , user , { password: password, port: server_port}) do |ssh|
|
||||||
end
|
end
|
||||||
rescue Net::SSH::HostKeyMismatch
|
rescue Net::SSH::HostKeyMismatch
|
||||||
system("ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{ip}")
|
system("ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{ip}")
|
||||||
rescue Errno::ENOTTY
|
rescue Errno::ENOTTY
|
||||||
system("ssh-add \"$HOME/.ssh/id_rsa\"")
|
system("ssh-add \"$HOME/.ssh/id_rsa\"")
|
||||||
end
|
end
|
||||||
Net::SSH.start(ip , user , password: password) do |ssh|
|
Net::SSH.start(ip , user , { password: password, port: server_port}) do |ssh|
|
||||||
@no_stdout = true
|
@no_stdout = true
|
||||||
crontab_lines_str = exec_ssh_command_by_sudo_and_see_output(ssh,"sudo -p 'sudo password:' crontab -l", false, true)
|
crontab_lines_str = exec_ssh_command_by_sudo_and_see_output(ssh,"sudo -p 'sudo password:' crontab -l", false, true)
|
||||||
if site_server.site_server_file_backups.count != 0
|
if site_server.site_server_file_backups.count != 0
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace :create_site do
|
||||||
tmp_is_certbot = (args.is_certbot == "true")
|
tmp_is_certbot = (args.is_certbot == "true")
|
||||||
if !site_server.nil?
|
if !site_server.nil?
|
||||||
@password = site_server.password
|
@password = site_server.password
|
||||||
Net::SSH.start(site_server.ip , site_server.account , password: site_server.password) do |ssh|
|
Net::SSH.start(site_server.ip , site_server.account , { password: site_server.password, port: site_server.port}) do |ssh|
|
||||||
redirect_to_https = args.redirect_to_https ? true : (@site_construct.redirect_to_https rescue false)
|
redirect_to_https = args.redirect_to_https ? true : (@site_construct.redirect_to_https rescue false)
|
||||||
if tmp_is_certbot || (@site_cert.is_certbot rescue false)
|
if tmp_is_certbot || (@site_cert.is_certbot rescue false)
|
||||||
domain_names = site_constructs.flat_map{|site_construct| site_construct.domain_name.strip.split(" ")}.select{|d| d.present? && d.match(/^[\d\.]+$/).nil?}
|
domain_names = site_constructs.flat_map{|site_construct| site_construct.domain_name.strip.split(" ")}.select{|d| d.present? && d.match(/^[\d\.]+$/).nil?}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace :create_site do
|
||||||
if !site_server.nil?
|
if !site_server.nil?
|
||||||
@password = site_server.password
|
@password = site_server.password
|
||||||
update_infos("Starting change domain name and ports.")
|
update_infos("Starting change domain name and ports.")
|
||||||
Net::SSH.start(site_server.ip , site_server.account , password: site_server.password) do |ssh|
|
Net::SSH.start(site_server.ip , site_server.account , { password: site_server.password, port: site_server.port}) do |ssh|
|
||||||
@site_construct.update(:domain_name=>args.server_name)
|
@site_construct.update(:domain_name=>args.server_name)
|
||||||
if args.port.present?
|
if args.port.present?
|
||||||
all_ports = args.port.split('////')
|
all_ports = args.port.split('////')
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'net/ssh'
|
||||||
require 'pathname'
|
require 'pathname'
|
||||||
namespace :create_site do
|
namespace :create_site do
|
||||||
desc "Copy Site from another site"
|
desc "Copy Site from another site"
|
||||||
task :copy_site,[:ip,:user,:password,:site_name,:domain_name,:port,:db_name,:path,:site_construct_id,:template_site_construct_id,:only_copy_installed_module] => :environment do |task,args|
|
task :copy_site,[:ip, :server_port,:user,:password,:site_name,:domain_name,:port,:db_name,:path,:site_construct_id,:template_site_construct_id,:only_copy_installed_module] => :environment do |task,args|
|
||||||
@password = args.password
|
@password = args.password
|
||||||
template_site = SiteConstruct.find(args.template_site_construct_id)
|
template_site = SiteConstruct.find(args.template_site_construct_id)
|
||||||
if args.site_construct_id.blank?
|
if args.site_construct_id.blank?
|
||||||
|
@ -24,14 +24,14 @@ namespace :create_site do
|
||||||
@site_construct.update(:status=>"creating")
|
@site_construct.update(:status=>"creating")
|
||||||
@site_construct.update!(:infos=>[])
|
@site_construct.update!(:infos=>[])
|
||||||
begin
|
begin
|
||||||
Net::SSH.start(args.ip , args.user , password: args.password) do |ssh|
|
Net::SSH.start(args.ip , args.user , { password: args.password, port: args.server_port}) do |ssh|
|
||||||
end
|
end
|
||||||
rescue Net::SSH::HostKeyMismatch
|
rescue Net::SSH::HostKeyMismatch
|
||||||
system("ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{args.ip}")
|
system("ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{args.ip}")
|
||||||
rescue Errno::ENOTTY
|
rescue Errno::ENOTTY
|
||||||
system("ssh-add \"$HOME/.ssh/id_rsa\"")
|
system("ssh-add \"$HOME/.ssh/id_rsa\"")
|
||||||
end
|
end
|
||||||
Net::SSH.start(args.ip , args.user , password: args.password) do |ssh|
|
Net::SSH.start(args.ip , args.user , { password: args.password, port: args.server_port}) do |ssh|
|
||||||
update_infos("setting nginx for #{args.site_name}")
|
update_infos("setting nginx for #{args.site_name}")
|
||||||
nginx_setting_texts = @site_construct.generate_nginx_text
|
nginx_setting_texts = @site_construct.generate_nginx_text
|
||||||
exec_ssh_command_by_sudo_for_copy(ssh,"touch /etc/nginx/orbit_sites/#{@site_construct.get_site_name}")
|
exec_ssh_command_by_sudo_for_copy(ssh,"touch /etc/nginx/orbit_sites/#{@site_construct.get_site_name}")
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'net/ssh'
|
||||||
require 'pathname'
|
require 'pathname'
|
||||||
namespace :create_site do
|
namespace :create_site do
|
||||||
desc "Create Site Script"
|
desc "Create Site Script"
|
||||||
task :create_site,[:git_template_url,:git_extension_url,:git_url,:ip,:user,:password,:site_name,:domain_name,:port,:db_name,:path,:site_construct_id] => :environment do |task,args|
|
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|
|
||||||
@password = args.password
|
@password = args.password
|
||||||
if args.site_construct_id.blank?
|
if args.site_construct_id.blank?
|
||||||
@site_construct = SiteConstruct.new
|
@site_construct = SiteConstruct.new
|
||||||
|
@ -22,14 +22,14 @@ namespace :create_site do
|
||||||
@site_construct.update(:status=>"creating")
|
@site_construct.update(:status=>"creating")
|
||||||
@site_construct.update!(:infos=>[])
|
@site_construct.update!(:infos=>[])
|
||||||
begin
|
begin
|
||||||
Net::SSH.start(args.ip , args.user , password: args.password) do |ssh|
|
Net::SSH.start(args.ip , args.user , { password: args.password, port: args.server_port}) do |ssh|
|
||||||
end
|
end
|
||||||
rescue Net::SSH::HostKeyMismatch
|
rescue Net::SSH::HostKeyMismatch
|
||||||
system("ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{args.ip}")
|
system("ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{args.ip}")
|
||||||
rescue Errno::ENOTTY
|
rescue Errno::ENOTTY
|
||||||
system("ssh-add \"$HOME/.ssh/id_rsa\"")
|
system("ssh-add \"$HOME/.ssh/id_rsa\"")
|
||||||
end
|
end
|
||||||
Net::SSH.start(args.ip , args.user , password: args.password) do |ssh|
|
Net::SSH.start(args.ip , args.user , { password: args.password, port: args.server_port}) do |ssh|
|
||||||
update_infos("setting nginx for #{args.site_name}")
|
update_infos("setting nginx for #{args.site_name}")
|
||||||
nginx_setting_texts = @site_construct.generate_nginx_text
|
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,"touch /etc/nginx/orbit_sites/#{@site_construct.get_site_name}")
|
||||||
|
|
|
@ -5,19 +5,20 @@ namespace :create_site do
|
||||||
task :delete_dbs,[:server_name,:dbs] => :environment do |task,args|
|
task :delete_dbs,[:server_name,:dbs] => :environment do |task,args|
|
||||||
site_server = SiteServer.where(:server_name=>args.server_name).first
|
site_server = SiteServer.where(:server_name=>args.server_name).first
|
||||||
ip = site_server.ip
|
ip = site_server.ip
|
||||||
|
server_port = site_server.port
|
||||||
user = site_server.account
|
user = site_server.account
|
||||||
password = site_server.password
|
password = site_server.password
|
||||||
@password = password
|
@password = password
|
||||||
dbs = args.dbs.split
|
dbs = args.dbs.split
|
||||||
begin
|
begin
|
||||||
Net::SSH.start(ip , user , password: password) do |ssh|
|
Net::SSH.start(ip , user , { password: password, port: server_port}) do |ssh|
|
||||||
end
|
end
|
||||||
rescue Net::SSH::HostKeyMismatch
|
rescue Net::SSH::HostKeyMismatch
|
||||||
system("ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{ip}")
|
system("ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{ip}")
|
||||||
rescue Errno::ENOTTY
|
rescue Errno::ENOTTY
|
||||||
system("ssh-add \"$HOME/.ssh/id_rsa\"")
|
system("ssh-add \"$HOME/.ssh/id_rsa\"")
|
||||||
end
|
end
|
||||||
Net::SSH.start(ip , user , password: password) do |ssh|
|
Net::SSH.start(ip , user , { password: password, port: server_port}) do |ssh|
|
||||||
dbs.each do |db|
|
dbs.each do |db|
|
||||||
puts "deleting database #{db}"
|
puts "deleting database #{db}"
|
||||||
exec_ssh_command_by_sudo(ssh,"bash -l -c 'echo \"db.dropDatabase()\" | mongo --shell \'#{db}\''")
|
exec_ssh_command_by_sudo(ssh,"bash -l -c 'echo \"db.dropDatabase()\" | mongo --shell \'#{db}\''")
|
||||||
|
|
|
@ -6,19 +6,20 @@ namespace :create_site do
|
||||||
@site_construct = SiteConstruct.find(args.site_construct_id)
|
@site_construct = SiteConstruct.find(args.site_construct_id)
|
||||||
site_server = SiteServer.where(:server_name=>@site_construct.server_type).first
|
site_server = SiteServer.where(:server_name=>@site_construct.server_type).first
|
||||||
ip = site_server.ip
|
ip = site_server.ip
|
||||||
|
server_port = site_server.port
|
||||||
user = site_server.account
|
user = site_server.account
|
||||||
password = site_server.password
|
password = site_server.password
|
||||||
@password = password
|
@password = password
|
||||||
begin
|
begin
|
||||||
begin
|
begin
|
||||||
Net::SSH.start(ip , user , password: password) do |ssh|
|
Net::SSH.start(ip , user , { password: password, port: server_port}) do |ssh|
|
||||||
end
|
end
|
||||||
rescue Net::SSH::HostKeyMismatch
|
rescue Net::SSH::HostKeyMismatch
|
||||||
system("ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{ip}")
|
system("ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{ip}")
|
||||||
rescue Errno::ENOTTY
|
rescue Errno::ENOTTY
|
||||||
system("ssh-add \"$HOME/.ssh/id_rsa\"")
|
system("ssh-add \"$HOME/.ssh/id_rsa\"")
|
||||||
end
|
end
|
||||||
Net::SSH.start(ip , user , password: password) do |ssh|
|
Net::SSH.start(ip , user , { password: password, port: server_port}) do |ssh|
|
||||||
@site_construct.update!(:infos=>[])
|
@site_construct.update!(:infos=>[])
|
||||||
if @site_construct.status != "closed"
|
if @site_construct.status != "closed"
|
||||||
update_infos("Closing site #{@site_construct.site_name}...")
|
update_infos("Closing site #{@site_construct.site_name}...")
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace :create_site do
|
||||||
@password = @site_server.password
|
@password = @site_server.password
|
||||||
begin
|
begin
|
||||||
begin
|
begin
|
||||||
Net::SSH.start(@site_server.ip , @site_server.account , password: @site_server.password) do |ssh|
|
Net::SSH.start(@site_server.ip , @site_server.account , { password: @site_server.password, port: @site_server.port}) do |ssh|
|
||||||
end
|
end
|
||||||
rescue Net::SSH::HostKeyMismatch
|
rescue Net::SSH::HostKeyMismatch
|
||||||
system("ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{@site_server.ip}")
|
system("ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{@site_server.ip}")
|
||||||
|
@ -34,7 +34,7 @@ namespace :create_site do
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
@no_stdout = true
|
@no_stdout = true
|
||||||
Net::SSH.start(@site_server.ip , @site_server.account , password: @site_server.password) do |ssh|
|
Net::SSH.start(@site_server.ip , @site_server.account , { password: @site_server.password, port: @site_server.port}) do |ssh|
|
||||||
certbot_path = exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'which certbot certbot-auto'",false,true).strip.split("\n")[0]
|
certbot_path = exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'which certbot certbot-auto'",false,true).strip.split("\n")[0]
|
||||||
@site_server.has_certbot = certbot_path.present?
|
@site_server.has_certbot = certbot_path.present?
|
||||||
@site_server.save
|
@site_server.save
|
||||||
|
|
|
@ -56,18 +56,19 @@ namespace :exec_commands do
|
||||||
end
|
end
|
||||||
site_servers.each do |site_server|
|
site_servers.each do |site_server|
|
||||||
ip = site_server.ip
|
ip = site_server.ip
|
||||||
|
server_port = site_server.port
|
||||||
user = site_server.account
|
user = site_server.account
|
||||||
password = site_server.password
|
password = site_server.password
|
||||||
@password = password
|
@password = password
|
||||||
begin
|
begin
|
||||||
Net::SSH.start(ip , user , password: password) do |ssh|
|
Net::SSH.start(ip , user , { password: password, port: server_port}) do |ssh|
|
||||||
end
|
end
|
||||||
rescue Net::SSH::HostKeyMismatch
|
rescue Net::SSH::HostKeyMismatch
|
||||||
system("ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{ip}")
|
system("ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{ip}")
|
||||||
rescue Errno::ENOTTY
|
rescue Errno::ENOTTY
|
||||||
system("ssh-add \"$HOME/.ssh/id_rsa\"")
|
system("ssh-add \"$HOME/.ssh/id_rsa\"")
|
||||||
end
|
end
|
||||||
Net::SSH.start(ip , user , password: password) do |ssh|
|
Net::SSH.start(ip , user , { password: password, port: server_port}) do |ssh|
|
||||||
@site_construct.update!(:infos=>[]) rescue nil
|
@site_construct.update!(:infos=>[]) rescue nil
|
||||||
if args.type == 'close_site'
|
if args.type == 'close_site'
|
||||||
exec_ssh_command_by_sudo_and_see_output(ssh,"chmod 777 #{@site_construct.path}/#{@site_construct.site_name} -R",false)
|
exec_ssh_command_by_sudo_and_see_output(ssh,"chmod 777 #{@site_construct.path}/#{@site_construct.site_name} -R",false)
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace :create_site do
|
||||||
@password = @site_server.password
|
@password = @site_server.password
|
||||||
begin
|
begin
|
||||||
begin
|
begin
|
||||||
Net::SSH.start(@site_server.ip , @site_server.account , password: @site_server.password) do |ssh|
|
Net::SSH.start(@site_server.ip , @site_server.account , { password: @site_server.password, port: @site_server.port}) do |ssh|
|
||||||
end
|
end
|
||||||
rescue Net::SSH::HostKeyMismatch
|
rescue Net::SSH::HostKeyMismatch
|
||||||
system("ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{@site_server.ip}")
|
system("ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{@site_server.ip}")
|
||||||
|
@ -33,7 +33,7 @@ namespace :create_site do
|
||||||
update_thread_infos(e.to_s)
|
update_thread_infos(e.to_s)
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
Net::SSH.start(@site_server.ip , @site_server.account , password: @site_server.password) do |ssh|
|
Net::SSH.start(@site_server.ip , @site_server.account , { password: @site_server.password, port: @site_server.port}) do |ssh|
|
||||||
certbot_path = exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'which certbot'",false,true).strip
|
certbot_path = exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'which certbot'",false,true).strip
|
||||||
snap_path = exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'which snap'",false,true).strip
|
snap_path = exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'which snap'",false,true).strip
|
||||||
already_apt_update = false
|
already_apt_update = false
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace :create_site do
|
||||||
desc "Test ssh"
|
desc "Test ssh"
|
||||||
task :test_ssh,[] => :environment do |task,args|
|
task :test_ssh,[] => :environment do |task,args|
|
||||||
@site_server = SiteServer.where(:server_name=>'dev').first
|
@site_server = SiteServer.where(:server_name=>'dev').first
|
||||||
Net::SSH.start(@site_server.ip , @site_server.account , password: @site_server.password) do |ssh|
|
Net::SSH.start(@site_server.ip , @site_server.account , { password: @site_server.password, port: @site_server.port}) do |ssh|
|
||||||
exec_ssh_command_by_sudo_and_see_output_for_test(ssh,"bash -l -c 'cd orbit_sites/design3;bundle update'")
|
exec_ssh_command_by_sudo_and_see_output_for_test(ssh,"bash -l -c 'cd orbit_sites/design3;bundle update'")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace :create_site do
|
||||||
@site_server = SiteServer.where(:server_name=>"rulingcom.com").first
|
@site_server = SiteServer.where(:server_name=>"rulingcom.com").first
|
||||||
proxy = Net::SSH::Proxy::HTTP.new(args.ip, args.port.to_i,
|
proxy = Net::SSH::Proxy::HTTP.new(args.ip, args.port.to_i,
|
||||||
:user => args.username, :password => args.password)
|
:user => args.username, :password => args.password)
|
||||||
Net::SSH.start(@site_server.ip , @site_server.account , password: @site_server.password, proxy: proxy) do |ssh|
|
Net::SSH.start(@site_server.ip , @site_server.account , { password: @site_server.password, port: @site_server.port, proxy: proxy}) do |ssh|
|
||||||
exec_ssh_command_by_sudo("echo 'abc'")
|
exec_ssh_command_by_sudo("echo 'abc'")
|
||||||
end
|
end
|
||||||
#rescue Errno::ETIMEDOUT , Net::SSH::ConnectionTimeout => e
|
#rescue Errno::ETIMEDOUT , Net::SSH::ConnectionTimeout => e
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace :create_site do
|
||||||
@password = @site_server.password
|
@password = @site_server.password
|
||||||
begin
|
begin
|
||||||
begin
|
begin
|
||||||
Net::SSH.start(@site_server.ip , @site_server.account , password: @site_server.password) do |ssh|
|
Net::SSH.start(@site_server.ip , @site_server.account , { password: @site_server.password, port: @site_server.port}) do |ssh|
|
||||||
end
|
end
|
||||||
rescue Net::SSH::HostKeyMismatch
|
rescue Net::SSH::HostKeyMismatch
|
||||||
system("ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{@site_server.ip}")
|
system("ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{@site_server.ip}")
|
||||||
|
@ -33,7 +33,7 @@ namespace :create_site do
|
||||||
update_thread_infos(e.to_s)
|
update_thread_infos(e.to_s)
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
Net::SSH.start(@site_server.ip , @site_server.account , password: @site_server.password) do |ssh|
|
Net::SSH.start(@site_server.ip , @site_server.account , { password: @site_server.password, port: @site_server.port}) do |ssh|
|
||||||
need_update_sites = SiteConstruct.where(:id.in=>@site_server.need_update_site_ids).to_a
|
need_update_sites = SiteConstruct.where(:id.in=>@site_server.need_update_site_ids).to_a
|
||||||
need_update_sites.each do |site_construct|
|
need_update_sites.each do |site_construct|
|
||||||
update_thread_infos("<span style='color: blueviolet;'>Changing "+site_construct.site_name+" nginx...</span>")
|
update_thread_infos("<span style='color: blueviolet;'>Changing "+site_construct.site_name+" nginx...</span>")
|
||||||
|
|
Loading…
Reference in New Issue