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,11 +206,19 @@ 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
|
||||||
"#{self.full_site_path}/ssl_certs/#{site_cert.id}/#{site_cert["cert_file"]}"
|
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"]}"
|
||||||
|
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
|
||||||
"#{self.full_site_path}/ssl_certs/#{site_cert.id}/#{site_cert["private_key"]}"
|
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"]}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
def get_path
|
def get_path
|
||||||
return self.path.to_s.gsub(" ","\\ ")
|
return self.path.to_s.gsub(" ","\\ ")
|
||||||
|
|
|
@ -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>
|
||||||
|
@ -100,10 +103,10 @@
|
||||||
})
|
})
|
||||||
built_in_commands += "</ul></div>"
|
built_in_commands += "</ul></div>"
|
||||||
$("#main-wrap").before("<div id='exec-commands-dialog-confirm' title='Commands to Exec'>"+
|
$("#main-wrap").before("<div id='exec-commands-dialog-confirm' title='Commands to Exec'>"+
|
||||||
"<div style='clear:both;'></div><div id='server_names_block'></div>"+
|
"<div style='clear:both;'></div><div id='server_names_block'></div>"+
|
||||||
built_in_commands+
|
built_in_commands+
|
||||||
"<div style=\"display: none;\" id=\"super_manager_div\"><input type=\"text\" placeholder=\"account\" name=\"account\"><br><input type=\"password\" placeholder=\"password\" name=\"password\"></div>"+"<textarea style='height: 200px;width: 100%;' id='commands_area'></textarea>"+
|
"<div style=\"display: none;\" id=\"super_manager_div\"><input type=\"text\" placeholder=\"account\" name=\"account\"><br><input type=\"password\" placeholder=\"password\" name=\"password\"></div>"+"<textarea style='height: 200px;width: 100%;' id='commands_area'></textarea>"+
|
||||||
"</div>");
|
"</div>");
|
||||||
};
|
};
|
||||||
$( "#exec-commands-dialog-confirm" ).dialog({
|
$( "#exec-commands-dialog-confirm" ).dialog({
|
||||||
resizable: true,
|
resizable: true,
|
||||||
|
@ -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,13 +105,23 @@ 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
|
||||||
cert_file_store_path = @site_construct.cert_file_remote_store_path
|
if is_certbot && @site_cert.source_paths.present? && @site_cert.source_paths.count == 2
|
||||||
exec_ssh_command_by_sudo(ssh,"mkdir -p #{File.dirname(cert_file_store_path)}")
|
source_paths = @site_cert.source_paths
|
||||||
exec_command_by_user(ssh,"x='#{cert_file_content}'; echo '#{@password}' | sudo -S sh -c \"echo '$x' > #{cert_file_store_path}\"")
|
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"
|
||||||
private_key_store_path = @site_construct.private_key_remote_store_path
|
else
|
||||||
exec_ssh_command_by_sudo(ssh,"mkdir -p #{File.dirname(private_key_store_path)}")
|
is_exist = false
|
||||||
exec_command_by_user(ssh,"x='#{private_key_content}'; echo '#{@password}' | sudo -S sh -c \"echo '$x' > #{private_key_store_path}\"")
|
end
|
||||||
auto_update_infos("Finish copy.")
|
if is_exist
|
||||||
|
auto_update_infos("Cert already exist.")
|
||||||
|
else
|
||||||
|
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_command_by_user(ssh,"x='#{cert_file_content}'; echo '#{@password}' | sudo -S sh -c \"echo '$x' > #{cert_file_store_path}\"")
|
||||||
|
private_key_store_path = @site_construct.private_key_remote_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}\"")
|
||||||
|
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