4 Commits

Author SHA1 Message Date
John Crisp
2a99a49c7b Remove formatting from controller 2025-06-17 15:08:19 +02:00
3cc63a7890 * Wed Jun 11 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0-5.sme
- open esmith using UTF8 [SME: 13036]
  rewrite smartmatches to grep
2025-06-11 18:17:28 -04:00
38cd36bd70 Add open db locally to check one domain sub 2025-02-20 11:05:31 +00:00
444fc11ead * Mon Feb 17 2025 Brian Read <brianr@koozali.org> 11.0-3.sme
- Change status in template to use helper script to pre-set dropdown value  [SME: 12923]
- Update Custom routines to openb DB when required, not relying on global open [SME: 12695]
2025-02-17 11:45:04 +00:00
4 changed files with 66 additions and 42 deletions

View File

@@ -7,20 +7,15 @@
#
use esmith::util;
use esmith::util::network;
use esmith::ConfigDB;
use esmith::HostsDB;
use esmith::AccountsDB;
use esmith::NetworksDB;
use esmith::DomainsDB;
use esmith::ConfigDB::UTF8;
use esmith::HostsDB::UTF8;
use esmith::AccountsDB::UTF8;
use esmith::NetworksDB::UTF8;
use esmith::DomainsDB::UTF8;
use constant FALSE => 0;
use constant TRUE => 1;
#The most common ones
our $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
our $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
our $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
our ($cdb,$adb,$ndb,$hdb,$ddb);
# Validation routines - parameters for each panel
sub validate_LIST {
@@ -161,6 +156,7 @@ sub validate_CHECKONEDOMAIN {
# Get singleton data for each panel
sub get_data_for_panel_LIST {
$cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
# Return a hash with the fields required which will be loaded into the shared data
my $c = shift;
@@ -185,6 +181,7 @@ sub get_data_for_panel_PARAMS {
# Return a hash with the fields required which will be loaded into the shared data
my $c = shift;
$cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
my %ret = (
'Data1' => 'Data for PARAMS', #Example
# fields from Inputs in PARAMS $fields['PARAMS']
@@ -240,6 +237,7 @@ sub get_data_for_panel_CHECKONEDOMAIN {
# Get control data for table(s)
# Define a constant hash for field name mapping
use constant DomainList_FIELD_MAPPING => (
'Table1-TYPE' => 'Type',
'Table1-Domain name / HOSTNAME' => 'Domain',
'Table1-Brief description' => 'Description',
'Table1-Content' => 'Content',
@@ -249,6 +247,7 @@ use constant DomainList_FIELD_MAPPING => (
'Table1-IS_IN_CERT' => 'isincert',
'Table1-CHECK' => 'Check'
#'target_field2' => 'source_field2',
# Add more mappings as needed
);
@@ -272,6 +271,8 @@ sub actual_DomainList {
# #print $element . "\n";
# push @list, $element;
# }
$ddb = esmith::DomainsDB::UTF8->open() || die("Couldn't open Domains db");
$hdb = esmith::HostsDB::UTF8->open() || die("Couldn't open Hosts db");
my @data = ();
my $check = $c->l('Check Domain');
@@ -281,14 +282,15 @@ sub actual_DomainList {
my $dname = $_->key;
my $isincert = "N";
my $link = $c->create_link("letsencryptd", "CHECKONEDOMAIN", "");
my $checklink = "<a href='" . $link . "&CHECKONEDOMAIN=" . $_->key . "'>" . $check . "</a>";
my $checklink = $link . "&CHECKONEDOMAIN=" . $_->key;
#my $checklink = "<a href=''>check</a>";
$isincert = "Y" if ($dname ~~ @list);
$isincert = "Y" if (grep(/^$dname$/, @list));
# domain
push @data,
{
Type => "Domain",
Domain => $_->key,
$_->props,
letsencryptSSLcert => $le,
@@ -299,13 +301,15 @@ sub actual_DomainList {
#and hosts
for my $h ($hdb->get_hosts_by_domain($dname)) {
next if $ddb->get($h->key);
my $hname = $h->key;
next if $ddb->get($hname);
next unless ($h->prop('HostType') eq "Self" || $h->prop('HostType') eq "Local");
$le = $h->prop('letsencryptSSLcert') || 'disabled'; #letsencrypt configure all
$isincert = "N";
$isincert = "Y" if ($h->key ~~ @list);
$isincert = "Y" if (grep(/^$hname$/, @list));
push @data, {
Domain => "--> " . $h->key,
Type => "Host",
Domain => $hname,
$h->props,
Description => $h->prop('ExternalIP') || $h->prop('InternalIP') || "",
Content => $h->prop('HostType'),
@@ -440,6 +444,7 @@ sub perform_PARAMS {
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = "";
$cdb = esmith::ConfigDB::UTF8->open() || die("Couldn't open config db");
my $db = $cdb; #maybe one of the others
my $dbkey = 'letsencrypt';
@@ -480,6 +485,7 @@ sub perform_CHECKALLDOMAINS {
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = "";
$cdb = esmith::ConfigDB::UTF8->open() || die("Couldn't open config db");
my $db = $cdb; #maybe one of the others
my $dbkey = 'ChangeThis';
@@ -496,6 +502,7 @@ sub perform_CHECKALLENABLEDDOMAINS {
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = "";
$cdb = esmith::ConfigDB::UTF8->open() || die("Couldn't open config db");
my $db = $cdb; #maybe one of the others
my $dbkey = 'ChangeThis';
@@ -546,6 +553,7 @@ sub get_my_ip {
sub update_one_domain {
my ($self, $domain) = @_;
$ddb = esmith::DomainsDB::UTF8->open() || die("Couldn't open Domains db");
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 `;
@@ -563,4 +571,4 @@ sub update_enabled_domains {
my $output = `/etc/e-smith/events/actions/letsencrypt-setdomains "" "" enabled `;
return $output || "-empty-";
} ## end sub update_enabled_domains
1;
1;

View File

@@ -30,11 +30,11 @@ 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;
use esmith::HostsDB;
use esmith::DomainsDB;
use esmith::ConfigDB::UTF8;
use esmith::AccountsDB::UTF8;
use esmith::NetworksDB::UTF8;
use esmith::HostsDB::UTF8;
use esmith::DomainsDB::UTF8;
require
'/usr/share/smanager/lib/SrvMngr/Controller/Letsencrypt-Custom.pm'; #The code that is to be added by the developer
@@ -53,11 +53,11 @@ sub main {
$c->app->log->info($c->log_req);
#The most common ones
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
my $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
my $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
my $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
my $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
my $cdb = esmith::ConfigDB::UTF8->open() || die("Couldn't open config db");
my $adb = esmith::AccountsDB::UTF8->open() || die("Couldn't open Accounts db");
my $ndb = esmith::NetworksDB::UTF8->open() || die("Couldn't open Network db");
my $hdb = esmith::HostsDB::UTF8->open() || die("Couldn't open Hosts db");
my $ddb = esmith::DomainsDB::UTF8->open() || die("Couldn't open Domains db");
my %lets_data = ();
my $title = $c->l('lets_Letsencrypt_certificate');
my $modul = '';
@@ -98,11 +98,11 @@ sub do_update {
my $modul = '';
#The most common ones - you might want to comment out any not used.
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
my $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
my $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
my $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
my $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
my $cdb = esmith::ConfigDB::UTF8->open() || die("Couldn't open config db");
my $adb = esmith::AccountsDB::UTF8->open() || die("Couldn't open Accounts db");
my $ndb = esmith::NetworksDB::UTF8->open() || die("Couldn't open Network db");
my $hdb = esmith::HostsDB::UTF8->open() || die("Couldn't open Hosts db");
my $ddb = esmith::DomainsDB::UTF8->open() || die("Couldn't open Domains db");
my %lets_data = ();
my $title = $c->l('lets_Letsencrypt_certificate');
@@ -295,11 +295,11 @@ sub do_display {
$c->app->log->info($c->log_req);
#The most common ones - you might want to comment out any not used.
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
my $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
my $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
my $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
my $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
my $cdb = esmith::ConfigDB::UTF8->open() || die("Couldn't open config db");
my $adb = esmith::AccountsDB::UTF8->open() || die("Couldn't open Accounts db");
my $ndb = esmith::NetworksDB::UTF8->open() || die("Couldn't open Network db");
my $hdb = esmith::HostsDB::UTF8->open() || die("Couldn't open Hosts db");
my $ddb = esmith::DomainsDB::UTF8->open() || die("Couldn't open Domains db");
my %lets_data = ();
my $title = $c->l('lets_Letsencrypt_certificate');
my $modul = "";
@@ -445,4 +445,4 @@ sub do_display {
);
$c->render(template => "letsencrypt");
} ## end sub do_display
1;
1;

View File

@@ -27,8 +27,9 @@
<p><span class=label>
%=l('lets_SERVICE_STATUS')
</span><span class=data>
% my @status_options = [['Disabled' => 'disabled'], ['Enabled' => 'enabled'], ['TEST' => 'test']];
% param 'status' => $lets_data->{status} unless param 'status';
%# my @status_options = [['Disabled' => 'disabled'], ['Enabled' => 'enabled'], ['TEST' => 'test']];
% my @status_options = selected_field([['Disabled' => 'disabled'], ['Enabled' => 'enabled'], ['TEST' => 'test']], $lets_data->{status});
%# param 'status' => $lets_data->{status} unless param 'status';
%= select_field 'status' => @status_options, class => 'input'
<br></span> </p>
@@ -94,4 +95,4 @@
%# Probably finally by a submit.
%end
</div>
</div>

View File

@@ -1,6 +1,6 @@
%define name smeserver-certificates
%define version 11.0
%define release 2
%define release 6
Summary: This is what smeserver-certificates does.
Name: %{name}
Version: %{version}
@@ -25,6 +25,21 @@ AutoReqProv: no
%changelog
* Tue Jun 17 2025 John Crisp <jcrisp@safeandsoundit.co.uk> 11.0-6.sme
- Remove formatting from controller file [SME: 13045]
- Add Domain/Host as Types for template checking [SME: 13045]
* Wed Jun 11 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0-5.sme
- open esmith using UTF8 [SME: 13036]
rewrite smartmatches to grep
* Thu Feb 20 2025 Brian Read <brianr@koozali.org> 11.0-4.sme
- Add local open DB in check on domain sub [SME: 12932]
* Mon Feb 17 2025 Brian Read <brianr@koozali.org> 11.0-3.sme
- Change status in template to use helper script to pre-set dropdown value [SME: 12923]
- Update Custom routines to openb DB when required, not relying on global open [SME: 12695]
* Wed Feb 12 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0-2.sme
- move smanager panel in package [SME: 12916]
- add Requires