Update letsencrypt and take out spurious chars in html cxontrols

This commit is contained in:
Brian Read 2024-11-27 16:18:56 +00:00
parent edb245df07
commit 1c275912e3
9 changed files with 100 additions and 89 deletions

View File

@ -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;

View File

@ -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,6 +127,7 @@ 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');
@ -181,9 +182,15 @@ sub do_update {
if ($ret ne "ok"){
# return to the panel with error message
$c->stash(error => $c->l($ret));
$c->render("letsencrypt");
# 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;
@ -297,34 +330,36 @@ sub do_display {
#}
# 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;

View File

@ -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
%#
<div id="Letsencrypt-CHECKALLDOMAINS" class="partial Letsencrypt-CHECKALLDOMAINS">
<script>

View File

@ -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
%#
<div id="Letsencrypt-CHECKALLENABLEDDOMAINS" class="partial Letsencrypt-CHECKALLENABLEDDOMAINS">
<script>

View File

@ -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
%#
<div id="Letsencrypt-CHECKONEDOMAIN" class="partial Letsencrypt-CHECKONEDOMAIN">
<script>

View File

@ -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
%#
<div id="Letsencrypt-LIST" class="partial Letsencrypt-LIST">
<script>

View File

@ -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
%#
<div id="Letsencrypt-PARAMS" class="partial Letsencrypt-PARAMS">
<script>
@ -85,7 +85,7 @@
</span><span class=data>
% param 'Email' => $lets_data->{Email} unless param 'Email';
%=email_field 'Email', class => 'emai8'
</span>span></p>
</span></p>
<span class='data'>

View File

@ -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
%#
% layout 'default', title => "Sme server 2 - Letsencrypt certificate", share_dir => './';
%# css specific to this panel:
@ -10,7 +10,7 @@
% if ($config->{debug} == 1) {
<pre>
%= dumper $c->current_route
%# dumper $lets_data->{trt}
%= dumper $lets_data->{trt}
</pre>
% }
@ -20,22 +20,22 @@
%= $c->render_to_string(inline => stash('modul') );
% }
%if ($lets_data->{first}) {
%if ($c->stash('first')) {
<br><p>
%=$c->render_to_string(inline =>$c->l($lets_data->{first}))
%=$c->render_to_string(inline =>$c->l($c->stash('first')))
</p>
%} elsif ($lets_data->{success}) {
%} elsif ($c->stash('success')) {
<div class='sme-border'>
<h2> Operation Status Report</h2><p>
%= $c->l($lets_data->{success});
<h2><%=$c->l('lets_Status_Report') %></h2><p>
%= $c->l($c->stash('success'));
</p>
</div>
%} elsif ($lets_data->{error}) {
%} elsif ($c->stash('error')) {
<div class='sme-error'>
<h2> Operation Status Report - error</h2><p>
%= $c->l($lets_data->{error});
<h2><%=$c->l('lets_Error_Status_Report') %></h2><p>
%= $c->l($c->stash('error'));
</p>
</div>
%}

View File

@ -160,14 +160,15 @@ sub do_update {
</tal:block>
if ($ret ne "ok"){
${prefix}_data{'trt'} = $thispanel;
$c->stash(error => $c->l($ret));
$c->stash(
title => $title,
modul => $modul,
${prefix}_data => \%${prefix}_data
);
$c->render( template => "${lcPackageName}" );
# ${prefix}_data{'trt'} = $thispanel;
# $c->stash(error => $c->l($ret));
# $c->stash(
# title => $title,
# modul => $modul,
# ${prefix}_data => \%${prefix}_data
# );
# $c->render( template => "${lcPackageName}" );
$c->do_display($thispanel);
} else {
#Do whatever is needed, including writing values to the DB
<tal:block tal:repeat="panel panels">
@ -217,11 +218,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 %${prefix}_data = ();
my $title = $c->l('${prefix}_${MenuDescription}');
my $modul = "";
# Accessing all parameters
my %params = $c->req->params->to_hash;
@ -238,14 +240,16 @@ sub do_display {
#}
# the value of trt will tell you which panel has returned
if (! $trt){
my $trt = $c->param('trt') || '${firstPanel}'; #Indicates where to go now
}
# Now add in the params from the selected row from the table
my %selectedrow;
<tal:block tal:repeat="panel panels">
if ($trt eq '${panel}'){
#Validate form parameters for panel ${panel}
#Validate Get selected row (if applicable) ${panel}
%selectedrow = $c->get_selected_${panel}($$${prefix}_data{'Selected'},$is_new_record);
}
</tal:block>
@ -278,6 +282,7 @@ sub do_display {
# Data for panel
$c->stash(
title => $title,
modul => $modul,
${prefix}_data => \%${prefix}_data
);
$c->render(template => "${lcPackageName}");