Fix bug.
This commit is contained in:
parent
cc104e83ba
commit
644aa05ee4
|
@ -120,7 +120,14 @@ class SiteConstruct
|
||||||
domain_name_str = ((domain_name_str.split(/\s+/) - [default_domain]) + [default_domain]).join(" ")
|
domain_name_str = ((domain_name_str.split(/\s+/) - [default_domain]) + [default_domain]).join(" ")
|
||||||
end
|
end
|
||||||
if old_server_block.present?
|
if old_server_block.present?
|
||||||
new_server_block = old_server_block.gsub(/(listen\s+)[^;]+/){|ff| "#{$1}#{port_text}"}
|
new_server_block = old_server_block.gsub('\n',"\n").gsub(/(listen\s+)[^;]+/){|ff| "#{$1}#{port_text}"}
|
||||||
|
if port_text == "80"
|
||||||
|
new_server_block = new_server_block.gsub(/^.*#\s*managed by Certbot(\n|$)/,'')
|
||||||
|
else
|
||||||
|
if self.site_cert && !(self.site_cert.is_certbot)
|
||||||
|
new_server_block = new_server_block.gsub(/#\s*managed by Certbot/,'')
|
||||||
|
end
|
||||||
|
end
|
||||||
new_server_block = new_server_block.gsub(/(server_name\s+)[^;]+/m){|ff| "#{$1}#{domain_name_str}"}
|
new_server_block = new_server_block.gsub(/(server_name\s+)[^;]+/m){|ff| "#{$1}#{domain_name_str}"}
|
||||||
new_server_block = new_server_block.gsub(/\s*ssl_certificate[^;]+;/,'')
|
new_server_block = new_server_block.gsub(/\s*ssl_certificate[^;]+;/,'')
|
||||||
level_2_block = parse_nginx_text_to_server_blocks(old_server_block,true,2)
|
level_2_block = parse_nginx_text_to_server_blocks(old_server_block,true,2)
|
||||||
|
@ -199,12 +206,20 @@ class SiteConstruct
|
||||||
end
|
end
|
||||||
def cert_file_remote_store_path
|
def cert_file_remote_store_path
|
||||||
site_cert = self.site_cert
|
site_cert = self.site_cert
|
||||||
|
if site_cert.source_paths.present? && site_cert.source_paths.count == 2
|
||||||
|
site_cert.source_paths[0]
|
||||||
|
else
|
||||||
"#{self.full_site_path}/ssl_certs/#{site_cert.id}/#{site_cert["cert_file"]}"
|
"#{self.full_site_path}/ssl_certs/#{site_cert.id}/#{site_cert["cert_file"]}"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
def private_key_remote_store_path
|
def private_key_remote_store_path
|
||||||
site_cert = self.site_cert
|
site_cert = self.site_cert
|
||||||
|
if site_cert.source_paths.present? && site_cert.source_paths.count == 2
|
||||||
|
site_cert.source_paths[1]
|
||||||
|
else
|
||||||
"#{self.full_site_path}/ssl_certs/#{site_cert.id}/#{site_cert["private_key"]}"
|
"#{self.full_site_path}/ssl_certs/#{site_cert.id}/#{site_cert["private_key"]}"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
def get_path
|
def get_path
|
||||||
return self.path.to_s.gsub(" ","\\ ")
|
return self.path.to_s.gsub(" ","\\ ")
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,6 +20,9 @@
|
||||||
ul.no_list_style li label {
|
ul.no_list_style li label {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
#info_texts{
|
||||||
|
white-space: pre;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<table class="table main-list default footable-loaded">
|
<table class="table main-list default footable-loaded">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -63,7 +66,7 @@
|
||||||
<a class="btn btn-primary update_nginx_settings" href="#" data-key="<%=site_server.server_name%>" style="background: blueviolet;"><%=t("client_management.update_nginx_settings")%></a>
|
<a class="btn btn-primary update_nginx_settings" href="#" data-key="<%=site_server.server_name%>" style="background: blueviolet;"><%=t("client_management.update_nginx_settings")%></a>
|
||||||
<% end %>
|
<% end %>
|
||||||
<a class="btn btn-primary" href = "<%= admin_site_panel_edit_server_info_path+"?id=#{site_server.id.to_s}" %>"><%=t(:edit)%></a>
|
<a class="btn btn-primary" href = "<%= admin_site_panel_edit_server_info_path+"?id=#{site_server.id.to_s}" %>"><%=t(:edit)%></a>
|
||||||
<a class="btn btn-primary" href = "#" onclick="if(window.confirm('Do you really want to delete <%=site_server.server_name%>?')) { window.location.href = '<%= admin_site_panel_edit_server_info_path+"?id=#{site_server.id.to_s}&type=delete" %>';}"><%=t(:remove)%></a>
|
<a class="btn btn-danger" href = "#" onclick="if(window.confirm('Do you really want to delete <%=site_server.server_name%>?')) { window.location.href = '<%= admin_site_panel_edit_server_info_path+"?id=#{site_server.id.to_s}&type=delete" %>';}"><%=t(:remove)%></a>
|
||||||
<a class="btn btn-primary" href = "<%= admin_site_panel_sites_list_path+"?server_name=#{site_server.server_name}" %>"><%= t('client_management.see_sites') %></a>
|
<a class="btn btn-primary" href = "<%= admin_site_panel_sites_list_path+"?server_name=#{site_server.server_name}" %>"><%= t('client_management.see_sites') %></a>
|
||||||
<a class="btn btn-primary detect_sites" href="#" data-key="<%=site_server.server_name%>">Detect sites</a>
|
<a class="btn btn-primary detect_sites" href="#" data-key="<%=site_server.server_name%>">Detect sites</a>
|
||||||
</td>
|
</td>
|
||||||
|
@ -151,7 +154,7 @@
|
||||||
var infos = request.responseJSON.infos;
|
var infos = request.responseJSON.infos;
|
||||||
var status = request.responseJSON.status;
|
var status = request.responseJSON.status;
|
||||||
if($("#info_texts").length == 0)
|
if($("#info_texts").length == 0)
|
||||||
return infos.join("<br>")
|
return infos.join("\n")
|
||||||
else{
|
else{
|
||||||
if(status == "")
|
if(status == "")
|
||||||
var status_text = "not yet create";
|
var status_text = "not yet create";
|
||||||
|
@ -160,7 +163,7 @@
|
||||||
if(!status_text){
|
if(!status_text){
|
||||||
status_text = "<span style=\"color: skyblue;\">"+status+"</span>";
|
status_text = "<span style=\"color: skyblue;\">"+status+"</span>";
|
||||||
}
|
}
|
||||||
$("#info_texts").html(status_text+"<div style='clear:both;'></div>"+infos.join("<br>"));
|
$("#info_texts").html(status_text+"<div style='clear:both;'></div>"+infos.join("\n"));
|
||||||
msg_end.scrollIntoView();
|
msg_end.scrollIntoView();
|
||||||
timeout_id = window.setTimeout(see_infos(key),1000);
|
timeout_id = window.setTimeout(see_infos(key),1000);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
ul.no_list_style li label {
|
ul.no_list_style li label {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
#info_texts{
|
||||||
|
white-space: pre;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<table class="table main-list default footable-loaded">
|
<table class="table main-list default footable-loaded">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -106,9 +109,9 @@
|
||||||
var infos = request.responseJSON.infos;
|
var infos = request.responseJSON.infos;
|
||||||
var status = request.responseJSON.status;
|
var status = request.responseJSON.status;
|
||||||
if($("#info_texts").length == 0)
|
if($("#info_texts").length == 0)
|
||||||
return infos.join("<br>")
|
return infos.join("\n")
|
||||||
else{
|
else{
|
||||||
$("#info_texts").html(infos.join("<br>"));
|
$("#info_texts").html(infos.join("\n"));
|
||||||
if(status == "")
|
if(status == "")
|
||||||
var status_text = "not yet create";
|
var status_text = "not yet create";
|
||||||
else
|
else
|
||||||
|
|
|
@ -105,6 +105,15 @@ namespace :create_site do
|
||||||
auto_update_infos("Installing Cert on #{valid_domain_names.join(" , ")}")
|
auto_update_infos("Installing Cert on #{valid_domain_names.join(" , ")}")
|
||||||
cert_file_content = [(@site_cert.cert_file.file.read.strip rescue ""),(@site_cert.ca_bundle.file.read.strip rescue "")].join("\n").strip
|
cert_file_content = [(@site_cert.cert_file.file.read.strip rescue ""),(@site_cert.ca_bundle.file.read.strip rescue "")].join("\n").strip
|
||||||
private_key_content = @site_cert.private_key.file.read
|
private_key_content = @site_cert.private_key.file.read
|
||||||
|
if is_certbot && @site_cert.source_paths.present? && @site_cert.source_paths.count == 2
|
||||||
|
source_paths = @site_cert.source_paths
|
||||||
|
is_exist = exec_command_by_user(ssh, "echo '#{@password}'|sudo -S bash -c 'if [ -e \"#{source_paths[0]}\" ] && [ -e \"#{source_paths[1]}\" ] ; then echo 1; else echo 0; fi'").strip() == "1"
|
||||||
|
else
|
||||||
|
is_exist = false
|
||||||
|
end
|
||||||
|
if is_exist
|
||||||
|
auto_update_infos("Cert already exist.")
|
||||||
|
else
|
||||||
cert_file_store_path = @site_construct.cert_file_remote_store_path
|
cert_file_store_path = @site_construct.cert_file_remote_store_path
|
||||||
exec_ssh_command_by_sudo(ssh,"mkdir -p #{File.dirname(cert_file_store_path)}")
|
exec_ssh_command_by_sudo(ssh,"mkdir -p #{File.dirname(cert_file_store_path)}")
|
||||||
exec_command_by_user(ssh,"x='#{cert_file_content}'; echo '#{@password}' | sudo -S sh -c \"echo '$x' > #{cert_file_store_path}\"")
|
exec_command_by_user(ssh,"x='#{cert_file_content}'; echo '#{@password}' | sudo -S sh -c \"echo '$x' > #{cert_file_store_path}\"")
|
||||||
|
@ -112,6 +121,7 @@ namespace :create_site do
|
||||||
exec_ssh_command_by_sudo(ssh,"mkdir -p #{File.dirname(private_key_store_path)}")
|
exec_ssh_command_by_sudo(ssh,"mkdir -p #{File.dirname(private_key_store_path)}")
|
||||||
exec_command_by_user(ssh,"x='#{private_key_content}'; echo '#{@password}' | sudo -S sh -c \"echo '$x' > #{private_key_store_path}\"")
|
exec_command_by_user(ssh,"x='#{private_key_content}'; echo '#{@password}' | sudo -S sh -c \"echo '$x' > #{private_key_store_path}\"")
|
||||||
auto_update_infos("Finish copy.")
|
auto_update_infos("Finish copy.")
|
||||||
|
end
|
||||||
auto_update_infos("Setting Cert...")
|
auto_update_infos("Setting Cert...")
|
||||||
nginx_file_content = exec_command_by_user(ssh,"cat #{@site_construct.nginx_file}")
|
nginx_file_content = exec_command_by_user(ssh,"cat #{@site_construct.nginx_file}")
|
||||||
all_ports = (@site_construct.port + ["443"]).uniq
|
all_ports = (@site_construct.port + ["443"]).uniq
|
||||||
|
|
Loading…
Reference in New Issue