From 1c275912e30205e0eb5b55d77021408690026650 Mon Sep 17 00:00:00 2001 From: Brian Read Date: Wed, 27 Nov 2024 16:18:56 +0000 Subject: [PATCH] Update letsencrypt and take out spurious chars in html cxontrols --- Targets/Letsencrypt/Letsencrypt-Custom.pm | 34 +------ Targets/Letsencrypt/Letsencrypt.pm | 90 +++++++++++++------ .../Letsencrypt/_lets_CHECKALLDOMAINS.html.ep | 2 +- .../_lets_CHECKALLENABLEDDOMAINS.html.ep | 2 +- .../Letsencrypt/_lets_CHECKONEDOMAIN.html.ep | 2 +- Targets/Letsencrypt/_lets_LIST.html.ep | 2 +- Targets/Letsencrypt/_lets_PARAMS.html.ep | 4 +- Targets/Letsencrypt/letsencrypt.html.ep | 22 ++--- Templates/controller.pm.tem | 31 ++++--- 9 files changed, 100 insertions(+), 89 deletions(-) diff --git a/Targets/Letsencrypt/Letsencrypt-Custom.pm b/Targets/Letsencrypt/Letsencrypt-Custom.pm index 0e2adc4..574c2c1 100644 --- a/Targets/Letsencrypt/Letsencrypt-Custom.pm +++ b/Targets/Letsencrypt/Letsencrypt-Custom.pm @@ -52,8 +52,7 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db"); my $c = shift; my $prefix_data = shift; #Data hash as parameter # Validation for each field - my $ret = ""; - + my $ret = "Error from params"; if (! TRUE) #validate $c->param('status') {$ret .= 'Validation for status failed';} if (! TRUE) #validate $c->param('hookScript') @@ -435,33 +434,4 @@ sub get_my_ip my $output = `/usr/sbin/e-smith/getmyip`; return $output || "IP"; } - -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; +1; \ No newline at end of file diff --git a/Targets/Letsencrypt/Letsencrypt.pm b/Targets/Letsencrypt/Letsencrypt.pm index 7ffe1f2..b96a77f 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-17 14:48:52 +# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-27 16:15:50 # #---------------------------------------------------------------------- # heading : Network @@ -127,7 +127,8 @@ sub do_update { my $c = shift; $c->app->log->info($c->log_req); - + my $modul = ''; + my %lets_data = (); my $title = $c->l('lets_Letsencrypt_certificate'); @@ -180,10 +181,16 @@ sub do_update { } - if ($ret ne "ok") { - # return to the panel with error message - $c->stash(error => $c->l($ret)); - $c->render("letsencrypt"); + if ($ret ne "ok"){ +# lets_data{'trt'} = $thispanel; +# $c->stash(error => $c->l($ret)); +# $c->stash( +# title => $title, +# modul => $modul, +# lets_data => \%lets_data +# ); +# $c->render( template => "letsencrypt" ); + $c->do_display($thispanel); } else { #Do whatever is needed, including writing values to the DB @@ -193,7 +200,12 @@ sub do_update { if ($ret ne "ok") { # return to the panel with error message $c->stash(error => $c->l($ret)); - $c->render("letsencrypt"); + $c->stash( + title => $title, + modul => $modul, + lets_data => \%lets_data + ); + $c->render(template => "letsencrypt"); } else { $c->stash( success => $c->l('lets_LIST_panel_action_was_successful')); #A bit bland - edit it in the lex file } @@ -205,7 +217,12 @@ sub do_update { if ($ret ne "ok") { # return to the panel with error message $c->stash(error => $c->l($ret)); - $c->render("letsencrypt"); + $c->stash( + title => $title, + modul => $modul, + lets_data => \%lets_data + ); + $c->render(template => "letsencrypt"); } else { $c->stash( success => $c->l('lets_PARAMS_panel_action_was_successful')); #A bit bland - edit it in the lex file } @@ -217,7 +234,12 @@ sub do_update { if ($ret ne "ok") { # return to the panel with error message $c->stash(error => $c->l($ret)); - $c->render("letsencrypt"); + $c->stash( + title => $title, + modul => $modul, + lets_data => \%lets_data + ); + $c->render(template => "letsencrypt"); } else { $c->stash( success => $c->l('lets_CHECKALLDOMAINS_panel_action_was_successful')); #A bit bland - edit it in the lex file } @@ -229,7 +251,12 @@ sub do_update { if ($ret ne "ok") { # return to the panel with error message $c->stash(error => $c->l($ret)); - $c->render("letsencrypt"); + $c->stash( + title => $title, + modul => $modul, + lets_data => \%lets_data + ); + $c->render(template => "letsencrypt"); } else { $c->stash( success => $c->l('lets_CHECKALLENABLEDDOMAINS_panel_action_was_successful')); #A bit bland - edit it in the lex file } @@ -241,26 +268,31 @@ sub do_update { if ($ret ne "ok") { # return to the panel with error message $c->stash(error => $c->l($ret)); - $c->render("letsencrypt"); + $c->stash( + title => $title, + modul => $modul, + lets_data => \%lets_data + ); + $c->render(template => "letsencrypt"); } else { $c->stash( success => $c->l('lets_CHECKONEDOMAIN_panel_action_was_successful')); #A bit bland - edit it in the lex file } } # and call any signal-events needed - - + #TBD # Setup shared data and call panel - $c->stash( - title => $title, - lets_data => \%lets_data - ); if ('none' eq 'none') { $lets_data{'trt'} = 'LIST'; } else { $lets_data{'trt'} = 'none'; } - $c->do_display() + $c->stash( + title => $title, + modul => $modul, + lets_data => \%lets_data + ); + $c->render( template => "letsencrypt" ); } } @@ -276,11 +308,12 @@ sub do_display { #load up returned hash into prefix_data #render - to called panel - my $c = shift; + my ($c,$trt) = @_; $c->app->log->info($c->log_req); my %lets_data = (); my $title = $c->l('lets_Letsencrypt_certificate'); + my $modul = ""; # Accessing all parameters my %params = $c->req->params->to_hash; @@ -296,35 +329,37 @@ sub do_display { # $lets_data{$key} = $value; #} - # the value of trt will tell you which panel has returned - my $trt = $c->param('trt') || 'LIST'; #Indicates where to go now + # the value of trt will tell you which panel has returned + if (! $trt){ + my $trt = $c->param('trt') || 'LIST'; #Indicates where to go now + } # Now add in the params from the selected row from the table my %selectedrow; if ($trt eq 'LIST'){ - #Validate form parameters for panel LIST + #Validate Get selected row (if applicable) LIST %selectedrow = $c->get_selected_LIST($lets_data{'Selected'},$is_new_record); } if ($trt eq 'PARAMS'){ - #Validate form parameters for panel PARAMS + #Validate Get selected row (if applicable) PARAMS %selectedrow = $c->get_selected_PARAMS($lets_data{'Selected'},$is_new_record); } if ($trt eq 'CHECKALLDOMAINS'){ - #Validate form parameters for panel CHECKALLDOMAINS + #Validate Get selected row (if applicable) CHECKALLDOMAINS %selectedrow = $c->get_selected_CHECKALLDOMAINS($lets_data{'Selected'},$is_new_record); } if ($trt eq 'CHECKALLENABLEDDOMAINS'){ - #Validate form parameters for panel CHECKALLENABLEDDOMAINS + #Validate Get selected row (if applicable) CHECKALLENABLEDDOMAINS %selectedrow = $c->get_selected_CHECKALLENABLEDDOMAINS($lets_data{'Selected'},$is_new_record); } if ($trt eq 'CHECKONEDOMAIN'){ - #Validate form parameters for panel CHECKONEDOMAIN + #Validate Get selected row (if applicable) CHECKONEDOMAIN %selectedrow = $c->get_selected_CHECKONEDOMAIN($lets_data{'Selected'},$is_new_record); } @@ -401,8 +436,9 @@ sub do_display { # Data for panel $c->stash( title => $title, + modul => $modul, lets_data => \%lets_data ); - $c->render("letsencrypt"); + $c->render(template => "letsencrypt"); } 1; \ No newline at end of file diff --git a/Targets/Letsencrypt/_lets_CHECKALLDOMAINS.html.ep b/Targets/Letsencrypt/_lets_CHECKALLDOMAINS.html.ep index cd9862b..d106344 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-17 14:48:52 +%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-27 16:15:50 %#