add feature that adding cert verify for site
This commit is contained in:
parent
8feba06a13
commit
febca7bf1b
|
@ -5,6 +5,22 @@ class Admin::SitePanelController < OrbitAdminController
|
||||||
@app_title = "client_management"
|
@app_title = "client_management"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_cert_setting
|
||||||
|
site_params = params.require('site').permit!
|
||||||
|
if !site_params['cert_ver_file_content'].blank?
|
||||||
|
site_params['cert_ver_file_content'] = Nokogiri::HTML.parse(site_params['cert_ver_file_content'].gsub(/\r\n|\n/,'').gsub(/<br[ \/]*>/, "\n")).inner_text
|
||||||
|
end
|
||||||
|
if !site_params['cert_ver_location_path'].blank? && site_params['cert_ver_location_path'].start_with?('h')
|
||||||
|
site_params['cert_ver_location_path'] = URI(site_params['cert_ver_location_path']).path
|
||||||
|
end
|
||||||
|
site = SiteConstruct.where(id: site_params[:id]).first
|
||||||
|
site.update_attributes(site_params)
|
||||||
|
Thread.new do
|
||||||
|
system("bundle exec rake create_site:add_cert_ver_for_site['#{site_params[:id]}']")
|
||||||
|
end
|
||||||
|
redirect_to "/#{I18n.locale}/admin/site_panel/sites_list?server_name=#{site.server_type}"
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@site_construct = SiteConstruct.new
|
@site_construct = SiteConstruct.new
|
||||||
@module_app = ModuleApp.where(:title=>@app_title).first
|
@module_app = ModuleApp.where(:title=>@app_title).first
|
||||||
|
|
|
@ -42,6 +42,21 @@
|
||||||
<a href="<%=admin_site_panel_edit_site_path+"?id=#{site.id}&type=delete_from_list"%>" title="Delete <%=site.domain_name%> from list" class="btn btn-primary" data-id="<%=site.id.to_s%>">Delete from list</a>
|
<a href="<%=admin_site_panel_edit_site_path+"?id=#{site.id}&type=delete_from_list"%>" title="Delete <%=site.domain_name%> from list" class="btn btn-primary" data-id="<%=site.id.to_s%>">Delete from list</a>
|
||||||
<% if site.status == "finish" || site.status == "closed" %>
|
<% if site.status == "finish" || site.status == "closed" %>
|
||||||
<a href="<%=admin_site_panel_path+"?copy_id=#{site.id}"%>" title="Copy site to another site." class="btn btn-primary">Copy site</a>
|
<a href="<%=admin_site_panel_path+"?copy_id=#{site.id}"%>" title="Copy site to another site." class="btn btn-primary">Copy site</a>
|
||||||
|
<a data-id="<%= site.id %>" title="edit cert setting." class="btn btn-primary open-cert-form">Edit cert Setting</a>
|
||||||
|
<div id="<%= "cert-form-#{site.id}" %>" class="cert-form" style="display: none;">
|
||||||
|
<%= form_for site, as: 'site', url: "/#{I18n.locale}/admin/site_panel/update_cert_setting",method: "post" do |f| %>
|
||||||
|
<div>
|
||||||
|
CSR txt path:
|
||||||
|
<%= f.text_field 'cert_ver_location_path',style: 'width: calc(100% - 8em);margin: 0;' %>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
CSR txt content:
|
||||||
|
<%= f.text_area 'cert_ver_file_content',class: 'ckeditor',value: site.cert_ver_file_content.to_s.gsub("\n",'<br>') %>
|
||||||
|
</div>
|
||||||
|
<%= f.hidden_field 'id' %>
|
||||||
|
<%= f.submit 'edit',class: 'btn btn-primary' %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -249,5 +264,18 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
<% end %>
|
<% end %>
|
||||||
|
$(".cert-form").dialog({
|
||||||
|
autoOpen: false,
|
||||||
|
show: "blind",
|
||||||
|
modal: true,
|
||||||
|
width: '90vw',
|
||||||
|
maxHeight: '80vh',
|
||||||
|
open: function() {
|
||||||
|
$(this).css("max-height", '80vh');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('.open-cert-form').click(function(){
|
||||||
|
$('#cert-form-'+$(this).data('id')).dialog('open')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
|
@ -48,6 +48,7 @@ Rails.application.routes.draw do
|
||||||
get "site_panel/server_manager" => "site_panel#server_manager"
|
get "site_panel/server_manager" => "site_panel#server_manager"
|
||||||
get "site_panel/edit_server_info" => "site_panel#edit_server_info"
|
get "site_panel/edit_server_info" => "site_panel#edit_server_info"
|
||||||
post "site_panel/edit_server_info" => "site_panel#edit_server_info"
|
post "site_panel/edit_server_info" => "site_panel#edit_server_info"
|
||||||
|
post "site_panel/update_cert_setting" => "site_panel#update_cert_setting"
|
||||||
resources :site_panel
|
resources :site_panel
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,11 +18,11 @@ namespace :create_site do
|
||||||
end
|
end
|
||||||
file_name = location_path.split('/')[-1]
|
file_name = location_path.split('/')[-1]
|
||||||
file_path = "#{site_construct.path}/#{site_construct.site_name}/tmp/#{file_name}"
|
file_path = "#{site_construct.path}/#{site_construct.site_name}/tmp/#{file_name}"
|
||||||
site_construct.cert_ver_added_text = " location #{location_path}{\n alias #{file_path};\n }"
|
site_construct.cert_ver_added_text = " location #{location_path}{#add_by_site_module\n alias #{file_path};\n }"
|
||||||
site_construct.save
|
site_construct.save
|
||||||
server_array = nginx_config.scan(/^[ \t]*server[ \t]{(?:(?!server[ \t]*{).)+}/m)
|
server_array = nginx_config.scan(/^[ \t]*server[ \t]{(?:(?!server[ \t]*{).)+}/m)
|
||||||
server_array.each do |server|
|
server_array.each do |server|
|
||||||
tmp = server[0...-1] + site_construct.cert_ver_added_text + "\n }"
|
tmp = server[0...-1] + site_construct.cert_ver_added_text + "\n}"
|
||||||
nginx_config = nginx_config.sub(server,tmp)
|
nginx_config = nginx_config.sub(server,tmp)
|
||||||
end
|
end
|
||||||
cmd = "x='#{cert_ver_file_content}'; echo '#{@password}' | sudo -S sh -c \"echo '$x' > #{file_path}\"; unset x"
|
cmd = "x='#{cert_ver_file_content}'; echo '#{@password}' | sudo -S sh -c \"echo '$x' > #{file_path}\"; unset x"
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace :create_site do
|
||||||
end
|
end
|
||||||
def exec_command_by_user(session,command)
|
def exec_command_by_user(session,command)
|
||||||
output = session.exec!(command)
|
output = session.exec!(command)
|
||||||
return output
|
return output[0..-1]
|
||||||
end
|
end
|
||||||
def exec_ssh_command_by_sudo(session,command)
|
def exec_ssh_command_by_sudo(session,command)
|
||||||
output = session.exec!("echo '#{@password}' | sudo -S #{command}")
|
output = session.exec!("echo '#{@password}' | sudo -S #{command}")
|
||||||
|
|
Loading…
Reference in New Issue