diff --git a/Targets/Letsencrypt/Letsencrypt-Custom.pm b/Targets/Letsencrypt/Letsencrypt-Custom.pm index b6c9ae8..0e2adc4 100644 --- a/Targets/Letsencrypt/Letsencrypt-Custom.pm +++ b/Targets/Letsencrypt/Letsencrypt-Custom.pm @@ -435,4 +435,33 @@ sub get_my_ip my $output = `/usr/sbin/e-smith/getmyip`; return $output || "IP"; } -1; \ No newline at end of file + +sub update_one_domain +{ + my $self = shift; + my $q = $self->{cgi}; + my $domain = $q->param('Domain'); + return "$domain not domain" unless ($ddb->get($domain) || $hdb->get($domain)); + ($domain) = ($domain =~ /([\w\p{L}.]+)/); + my $output = `/etc/e-smith/events/actions/letsencrypt-setdomains " " $domain `; + return $output || "-empty-"; +} + +sub update_all_domains +{ + my $self = shift; + my $q = $self->{cgi}; + my $output = `/etc/e-smith/events/actions/letsencrypt-setdomains "" "" all `; + return $output || "-empty-"; +} + +sub update_enabled_domains +{ + my $self = shift; + my $q = $self->{cgi}; + my $output = `/etc/e-smith/events/actions/letsencrypt-setdomains "" "" enabled `; + return $output || "-empty-"; +} + + +1; diff --git a/Targets/Letsencrypt/Letsencrypt.pm b/Targets/Letsencrypt/Letsencrypt.pm index 06890bd..7ffe1f2 100644 --- a/Targets/Letsencrypt/Letsencrypt.pm +++ b/Targets/Letsencrypt/Letsencrypt.pm @@ -1,6 +1,6 @@ package SrvMngr::Controller::Letsencrypt; # -# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-13 16:29:07 +# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-17 14:48:52 # #---------------------------------------------------------------------- # heading : Network @@ -35,6 +35,7 @@ use SrvMngr qw(theme_list init_session); use Data::Dumper; use esmith::util; +use esmith::util::network; use esmith::ConfigDB; use esmith::AccountsDB; use esmith::NetworksDB; @@ -80,16 +81,15 @@ sub main { #pickup any other contents needed and load them into hash shared with panel my %returned_hash; # subroutine returns a hash directly - %returned_hash = get_data_for_panel_LIST(); + %returned_hash = $c->get_data_for_panel_LIST(); # Copy each key-value pair from the returned hash to the prefix data hash while (my ($key, $value) = each %returned_hash) { $lets_data{$key} = $value; } # and table control fields + $c->stash(DomainList=>$c->get_DomainList()); - $c->stash(DomainList=>$c->get_DomainList()); - $c->stash( title => $title, @@ -173,10 +173,10 @@ sub do_update { $thispanel = 'CHECKALLENABLEDDOMAINS'; } - if ($trt eq 'CHECKONEDDOMAIN'){ - #Validate form parameters for panel CHECKONEDDOMAIN - $ret = $c->validate_CHECKONEDDOMAIN(\%lets_data); - $thispanel = 'CHECKONEDDOMAIN'; + if ($trt eq 'CHECKONEDOMAIN'){ + #Validate form parameters for panel CHECKONEDOMAIN + $ret = $c->validate_CHECKONEDOMAIN(\%lets_data); + $thispanel = 'CHECKONEDOMAIN'; } @@ -235,15 +235,15 @@ sub do_update { } } - if ($trt eq 'CHECKONEDDOMAIN'){ + if ($trt eq 'CHECKONEDOMAIN'){ #do whatever is required ... - $ret = $c->perform_CHECKONEDDOMAIN(\%lets_data); + $ret = $c->perform_CHECKONEDOMAIN(\%lets_data); if ($ret ne "ok") { # return to the panel with error message $c->stash(error => $c->l($ret)); $c->render("letsencrypt"); } else { - $c->stash( success => $c->l('lets_CHECKONEDDOMAIN_panel_action_was_successful')); #A bit bland - edit it in the lex file + $c->stash( success => $c->l('lets_CHECKONEDOMAIN_panel_action_was_successful')); #A bit bland - edit it in the lex file } } @@ -323,9 +323,9 @@ sub do_display { %selectedrow = $c->get_selected_CHECKALLENABLEDDOMAINS($lets_data{'Selected'},$is_new_record); } - if ($trt eq 'CHECKONEDDOMAIN'){ - #Validate form parameters for panel CHECKONEDDOMAIN - %selectedrow = $c->get_selected_CHECKONEDDOMAIN($lets_data{'Selected'},$is_new_record); + if ($trt eq 'CHECKONEDOMAIN'){ + #Validate form parameters for panel CHECKONEDOMAIN + %selectedrow = $c->get_selected_CHECKONEDOMAIN($lets_data{'Selected'},$is_new_record); } @@ -342,7 +342,7 @@ sub do_display { # pickup any other contents needed and load them into hash shared with panel my %returned_hash; # subroutine returns a hash directly - %returned_hash = get_data_for_panel_LIST(); + %returned_hash = $c->get_data_for_panel_LIST(); # Copy each key-value pair from the returned hash to the prefix data hash while (my ($key, $value) = each %returned_hash) { $lets_data{$key} = $value; @@ -353,7 +353,7 @@ sub do_display { # pickup any other contents needed and load them into hash shared with panel my %returned_hash; # subroutine returns a hash directly - %returned_hash = get_data_for_panel_PARAMS(); + %returned_hash = $c->get_data_for_panel_PARAMS(); # Copy each key-value pair from the returned hash to the prefix data hash while (my ($key, $value) = each %returned_hash) { $lets_data{$key} = $value; @@ -364,7 +364,7 @@ sub do_display { # pickup any other contents needed and load them into hash shared with panel my %returned_hash; # subroutine returns a hash directly - %returned_hash = get_data_for_panel_CHECKALLDOMAINS(); + %returned_hash = $c->get_data_for_panel_CHECKALLDOMAINS(); # Copy each key-value pair from the returned hash to the prefix data hash while (my ($key, $value) = each %returned_hash) { $lets_data{$key} = $value; @@ -375,18 +375,18 @@ sub do_display { # pickup any other contents needed and load them into hash shared with panel my %returned_hash; # subroutine returns a hash directly - %returned_hash = get_data_for_panel_CHECKALLENABLEDDOMAINS(); + %returned_hash = $c->get_data_for_panel_CHECKALLENABLEDDOMAINS(); # Copy each key-value pair from the returned hash to the prefix data hash while (my ($key, $value) = each %returned_hash) { $lets_data{$key} = $value; } } - if ($trt eq 'CHECKONEDDOMAIN'){ + if ($trt eq 'CHECKONEDOMAIN'){ # pickup any other contents needed and load them into hash shared with panel my %returned_hash; # subroutine returns a hash directly - %returned_hash = get_data_for_panel_CHECKONEDDOMAIN(); + %returned_hash = $c->get_data_for_panel_CHECKONEDOMAIN(); # Copy each key-value pair from the returned hash to the prefix data hash while (my ($key, $value) = each %returned_hash) { $lets_data{$key} = $value; @@ -395,9 +395,8 @@ sub do_display { # and table control fields - - $c->stash(DomainList=>$c->get_DomainList()); - + $c->stash(DomainList=>$c->get_DomainList()); + # Data for panel $c->stash( diff --git a/Targets/Letsencrypt/_lets_CHECKALLDOMAINS.html.ep b/Targets/Letsencrypt/_lets_CHECKALLDOMAINS.html.ep index d2449b3..cd9862b 100644 --- a/Targets/Letsencrypt/_lets_CHECKALLDOMAINS.html.ep +++ b/Targets/Letsencrypt/_lets_CHECKALLDOMAINS.html.ep @@ -1,5 +1,5 @@ %# -%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-06 11:09:38 +%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-17 14:48:52 %#
+ % if ($config->{debug} == 1) {
 			%= dumper $lets_data
 		
% } - % my $btn = l('lets_APPLY'); - %= form_for "letsencryptu" => (method => 'POST') => begin - - % param 'trt' => $lets_data->{trt} unless param 'trt'; + % my $btn = l('lets_APPLY'); + %= form_for "letsencryptu" => (method => 'POST') => begin + % param 'trt' => $lets_data->{trt} unless param 'trt'; %= hidden_field 'trt' => $lets_data->{trt} %# Inputs etc in here. -

<%=l('lets_Configuration_for_Letsencrypt')%>

-

<%=l('lets_Manage_letsencrypt-config_settings:')%>

@@ -83,6 +80,14 @@ %= select_field 'configure' => @configure_options, class => 'input'

+

+ %=l('lets_EMAIL') + + % param 'Email' => $lets_data->{Email} unless param 'Email'; + %=email_field 'Email', class => 'emai8' + span>

+ + %= submit_button l('lets_Save'), class => 'action subm9' @@ -90,7 +95,8 @@ %= submit_button l('lets_Back'), class => 'action back', onclick =>'history.back()' - + + %# Probably finally by a submit. %end
\ No newline at end of file diff --git a/Targets/Letsencrypt/letsencrypt.css b/Targets/Letsencrypt/letsencrypt.css index 8d4bcbb..b0dcb01 100644 --- a/Targets/Letsencrypt/letsencrypt.css +++ b/Targets/Letsencrypt/letsencrypt.css @@ -1,12 +1,14 @@ /* - Generated by SM2Gen version: SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-05 13:20:33 +Generated by SM2Gen version: SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-17 14:48:52 */ .Letsencrypt-panel {} .name {} .rout {} -.butt2 {} -.butt3 {} -.butt4 {} +.grou {} +.link2 {} +.link3 {} +.link4 {} +.endg {} .subh2 {} .read4 {} .read5 {} @@ -21,7 +23,6 @@ thead .tabl1 {} tbody .tabl1 {} .name {} .rout {} -.head {} .subh {} .para1 {} .sele1 {} @@ -33,21 +34,28 @@ tbody .tabl1 {} .sele7 {} .emai8 {} .subm9 {} +.back10 {} .name {} .rout {} .head {} .subh {} .text1 {} -.subm2 {} +.back2 {} .name {} .rout {} .head {} .subh {} .text1 {} -.subm2 {} +.back2 {} +.name {} +.rout {} +.head {} +.subh {} +.read1 {} +.text2 {} +.back3 {} - - .inline-buttons { + .inline-buttons { display: flex; /* Use flexbox to arrange items horizontally */ gap: 10px; /* Optional: Add space between buttons */ } diff --git a/Targets/Letsencrypt/letsencrypt.html.ep b/Targets/Letsencrypt/letsencrypt.html.ep index c9342f5..ef3d035 100644 --- a/Targets/Letsencrypt/letsencrypt.html.ep +++ b/Targets/Letsencrypt/letsencrypt.html.ep @@ -1,5 +1,5 @@ %# -%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-13 16:40:01 +%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-17 14:48:52 %# % layout 'default', title => "Sme server 2 - Letsencrypt certificate", share_dir => './'; %# css specific to this panel: @@ -8,9 +8,10 @@
% if ($config->{debug} == 1) { -

+

 		%= dumper $c->current_route
-	

+ %# dumper $lets_data->{trt} +
% }

<%=$title%>

diff --git a/Targets/Letsencrypt/letsencrypt_en.lex b/Targets/Letsencrypt/letsencrypt_en.lex index 6ea432f..5bb375f 100644 --- a/Targets/Letsencrypt/letsencrypt_en.lex +++ b/Targets/Letsencrypt/letsencrypt_en.lex @@ -1,52 +1,52 @@ # -# Generated by SM2Gen version: SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-14 12:01:28 +# Generated by SM2Gen version: SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-17 14:48:52 # -'lets_Check_all_domains' => 'Check all domains', -'lets_API_STATUS' => 'ape Status', -'lets_Loop_through_checking_the_letsencrypt' => 'Loop through checking the letsencrypt status for each configured domain', -'lets_Save' => 'Save', -'lets_Back' => 'Back', -'lets_LABEL_LECERT' => 'Label secret', 'lets_Loop_through_checking_the_letsencrypt' => 'Loop through checking the letsencrypt status for a specific domain', -'lets_Content' => 'Content', -'lets_Enabled_domains_check_result' => 'Enabled domains check result', -'lets_For_this_Server:' => 'For this server', -'lets_CHECK_ENABLED_DOMAINS' => 'Check Enabled Domains', -'lets_EMAIL' => 'Email', -'lets_CHECKALLDOMAINS_panel_action_was_successful' => 'CHECKALLDOMAINS panel action was successful', -'lets_CONFIG' => 'Config', -'lets_CHECKONEDOMAIN_panel_action_was_successful' => 'CHECKONEDOMAIN panel action was successful', -'lets_Domains_name' => 'Domains name', -'lets_Expiry' => 'Expiry', -'lets_Internet_IP' => 'Internet IP', -'lets_List_of_Domains_and_Hosts:' => 'List of Domains and hosts', -'lets_CHECKALLENABLEDDOMAINS_panel_action_was_successful' => 'CHECKALLENABLEDDOMAINS panel action was successful', -'lets_One_domain_check_result' => 'One domain check result', -'lets_Check_all_enabled_domains' => 'Check all enabled domains', -'lets_APPLY' => 'Apply', -'lets_All_domains_check_result' => 'All domains check result', -'lets_KEYSIZE_STATUS' => 'Keysize Status', -'lets_SERVICE_STATUS' => 'Service Status', -'lets_CHECK_ALL_DOMAINS' => 'Check All Domains', -'lets_Internal_IP' => 'Internal IP', -'lets_LABEL_NAMESERVERS' => 'Label timeservers', -'lets_CHECK' => 'Check', -'lets_Loop_through_checking_the_letsencrypt' => 'Loop through checking the letsencrypt status for each configured domain which is enabled', -'lets_CONFIGUREMODE_STATUS' => 'Configuremode Status', -'lets_External_Interface_IP' => 'External Interface IP', -'lets_Manage_letsencrypt-config_settings:' => 'Manage letsencrypt-config settings', -'lets_Not_Before' => 'Not Before', -'lets_Current_certificate_details:' => 'Current certificate details', -'lets_Letsencrypt_certificate' => 'Letsencrypt certificate', -'lets_HOOKSCRIPT_STATUS' => 'Hookscript Status', -'lets_CONFIG_LETSENCRYPT' => 'confirm Letsencrypt', -'lets_HOSTOVERRIDE_STATUS' => 'Hostoverride Status', 'lets_Brief_description' => 'Brief description', -'lets_IS_IN_CERT' => 'Is In cart', -'lets_LIST_panel_action_was_successful' => 'LIST panel action was successful', +'lets_Expiry' => 'Expiry', +'lets_EMAIL' => 'Email', +'lets_One_domain_check_result' => 'One domain check result', +'lets_Current_certificate_details' => 'Current certificate details', 'lets_LABEL_POINT' => 'Label Point', -'lets_ACCEPT_TERMS_STATUS' => 'Accept Terms Status', +'lets_IS_IN_CERT' => 'Is In cart', +'lets_LABEL_LECERT' => 'Label secret', +'lets_Enabled_domains_check_result' => 'Enabled domains check result', +'lets_Letsencrypt_certificate' => 'Letsencrypt certificate', +'lets_Check_all_domains' => 'Check all domains', 'lets_Domain_name_/_HOSTNAME' => 'Domain name / HOSTNAME', +'lets_Loop_through_checking_the_letsencrypt' => 'Loop through checking the letsencrypt status for each configured domain which is enabled', +'lets_CHECK_ALL_ENABLED_DOMAINS' => 'Check All Enabled Domains', +'lets_PARAMS_panel_action_was_successful' => 'PARAMS panel action was successful', +'lets_CHECKALLENABLEDDOMAINS_panel_action_was_successful' => 'CHECKALLENABLEDDOMAINS panel action was successful', +'lets_HOOKSCRIPT_STATUS' => 'Hookscript Status', +'lets_List_of_Domains_and_Hosts' => 'List of Domains and Hosts', +'lets_Save' => 'Save', +'lets_Internal_IP' => 'Internal IP', +'lets_Loop_through_checking_the_letsencrypt' => 'Loop through checking the letsencrypt status for each configured domain', +'lets_Internet_IP' => 'Internet IP', +'lets_SERVICE_STATUS' => 'Service Status', +'lets_ACCEPT_TERMS_STATUS' => 'Accept Terms Status', +'lets_CHECK' => 'Check', 'lets_Check_just_one_domain' => 'Check just one domain', +'lets_External_Interface_IP' => 'External Interface IP', +'lets_Not_Before' => 'Not Before', +'lets_Content' => 'Content', +'lets_All_domains_check_result' => 'All domains check result', +'lets_LIST_panel_action_was_successful' => 'LIST panel action was successful', +'lets_CONFIGUREMODE_STATUS' => 'Configuremode Status', +'lets_CONFIG_LETSENCRYPT' => 'confirm Letsencrypt', +'lets_CHECKONEDOMAIN_panel_action_was_successful' => 'CHECKONEDOMAIN panel action was successful', +'lets_LABEL_NAMESERVERS' => 'Label timeservers', +'lets_CHECK_ALL_DOMAINS' => 'Check All Domains', +'lets_HOSTOVERRIDE_STATUS' => 'Hostoverride Status', +'lets_API_STATUS' => 'ape Status', +'lets_APPLY' => 'Apply', +'lets_Check_all_enabled_domains' => 'Check all enabled domains', +'lets_KEYSIZE_STATUS' => 'Keysize Status', 'lets_Issuer' => 'Issuer', -'lets_PARAMS_panel_action_was_successful' => 'PARAMS panel action was successful', \ No newline at end of file +'lets_Domains_name' => 'Domains name', +'lets_CONFIG' => 'Config', +'lets_CHECKALLDOMAINS_panel_action_was_successful' => 'CHECKALLDOMAINS panel action was successful', +'lets_Back' => 'Back', +'lets_For_this_Server' => 'For this Server', +'lets_Manage_letsencrypt-config_settings:' => 'Manage letsencrypt-config settings', diff --git a/Templates/controller.pm.tem b/Templates/controller.pm.tem index 5739ca7..1f6ed80 100644 --- a/Templates/controller.pm.tem +++ b/Templates/controller.pm.tem @@ -129,7 +129,8 @@ sub do_update { my $c = shift; $c->app->log->info($c->log_req); - + my $modul = ''; + my %${prefix}_data = (); my $title = $c->l('${prefix}_${MenuDescription}'); @@ -159,9 +160,14 @@ sub do_update { if ($ret ne "ok") { - # return to the panel with error message + ${prefix}_data{trt} = $thispanel; $c->stash(error => $c->l($ret)); - $c->render("${lcPackageName}"); + $c->stash( + title => $title, + modul => $modul, + ${prefix}_data => \%${prefix}_data + ); + $c->render( template => "${lcPackageName}" ); } else { #Do whatever is needed, including writing values to the DB diff --git a/Templates/html_controls.html.ep.xml b/Templates/html_controls.html.ep.xml index c39ddce..ff327b9 100644 --- a/Templates/html_controls.html.ep.xml +++ b/Templates/html_controls.html.ep.xml @@ -112,7 +112,7 @@ % param '${Name}' => $$${prefix}_data->{${Name}} unless param '${Name}'; %=email_field '${Name}', class => 'emai${type_serial}' - span>

+

]]> diff --git a/sm2gen.py b/sm2gen.py index f5f6ed2..d267f94 100644 --- a/sm2gen.py +++ b/sm2gen.py @@ -29,7 +29,7 @@ ini_file_path = os.path.expanduser("~/.smegit/conf") OPENAI_API_KEY = "" # Configure the basic logging system -logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') +logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') # Create a logger logger = logging.getLogger(__name__)