Commit Diff


commit - ecd8ede0168e19cdd076be1d3dc29b538db36ab5
commit + fc937c40bfe1e133f4cbe986ee5573b0625c9856
blob - 6a06fb052ae8c67b865bdd47cb4b1102e20aefbc
blob + b6ef931db04dd3f3d8b46f37afcd1280d6edaa1a
--- bin/configNow.pl
+++ bin/configNow.pl
@@ -10,6 +10,7 @@ use File::Path qw(make_path);
 my $shellname = shift || 'blacklock';
 my @users = qw( izzyb nathan ashley );
 my $domain = 'user.planetofnix.com';
+my $custDomain = 'bnsnet.ca';
 my %config=(
 	type=>'shell',
 	shellname => $shellname,
@@ -20,6 +21,7 @@ my %config=(
 	ipv4 => '38.87.162.191',
 	ipv6 => '2602:fccf:1:1191::',
 	domain => $domain,
+	custDomain => $custDomain,
 );
 my $shellConfig = new IRCNOW::ConfigNow( %config );
 #use Data::Dumper;
blob - 85a6741b472c420bba08903374d9d07528282bba
blob + 353311442c58b050666e1e4c40df60192da1100e
--- lib/IRCNOW/ConfigNow/Module/AcmeClient.pm
+++ lib/IRCNOW/ConfigNow/Module/AcmeClient.pm
@@ -1,15 +1,40 @@
-acme_client => qq{
+package IRCNOW::ConfigNow::Module::AcmeClient;
+use base qw{IRCNOW::ConfigNow::Module};
+use strict;
+use warnings;
+use Carp;
+
+sub new {
+	my $class = shift;
+	my $options = {@_};
+	my $domain = $options->{vars}->{domain} || die "{domain} is a reqired option for IRCNOW::ConfigNow::Module::Prosody";
+	return $class->SUPER::new( vars => $options->{vars}, files=>{
+		acme_client => {
+			filename => "/etc/acme-config.conf",
+			varlist => [qw(shellname domain)],
+			type => 'shell',
+			template => sub {
+				my ($shellname, $domain) = @_;
+				return qq{
 domain $shellname.$domain {
 	domain key "/etc/ssl/private/$shellname.$domain.key"
 	domain full chain certificate "/etc/ssl/$shellname.$domain.fullchain.pem"
 	sign with letsencrypt
 }
-
-dns => {
-	filename => "/var/nsd/zones/master/$shellname
-	varlist => [qw(shellname ipv4 ipv6)],
-	template => qq{
+};
+			},
+		},
+		dns => {
+			filename => "/var/nsd/zones/master/$domain",
+			varlist => [qw(shellname ipv4 ipv6)],
+			type => 'shell',
+			template => qq{
 %s				3600	IN		A		%s
 				3600	IN		AAAA		%s
 },
+		},
+	});
+}
 
+1;
+
blob - /dev/null
blob + c183b6611386b7a91bbb2afce49e8ad7f37e6d61 (mode 644)
--- /dev/null
+++ lib/IRCNOW/ConfigNow/Module/CustDomain.pm
@@ -0,0 +1,65 @@
+package IRCNOW::ConfigNow::Module::CustDomain;
+use base qw{IRCNOW::ConfigNow::Module};
+use strict;
+use warnings;
+use Carp;
+
+sub new {
+	my $class = shift;
+	my $options = {@_};
+	my $domain = $options->{vars}->{custDomain} || die "{custDomain} is a reqired option for IRCNOW::ConfigNow::Module::CustDomain";
+	return $class->SUPER::new( vars => $options->{vars}, files=>{
+		dns_soa => {
+			filename =>	"/var/nsd/zones/master/$domain",
+			varlist => [qw{custDomain ipv4 ipv6}],
+			type => 'custDomain',
+			template => sub {
+				my ($custDomain,$ip4,$ip6) = @_;
+warn "writing custdomain";
+				return qq{
+\$ORIGIN $custDomain.
+$custDomain.      86400   IN      SOA     ns1.$custDomain. admin.$custDomain. (
+    2023030501 1800 7200 1209600 3600 )
+        3600    IN      MX      10 mail
+		3600	IN		A		$ip4
+		3600	IN		AAAA	$ip6
+        3600    IN      NS      ns1
+        3600    IN      NS      ns2
+ns1     3600    IN      A       $ip4
+        3600    IN      AAAA    $ip6
+ns2     3600    IN      A       $ip4
+        3600    IN      AAAA    $ip6
+mail	3600	IN		A		$ip4
+		3600	IN		AAAA	$ip6
+imap	3600	IN		A		$ip4
+		3600	IN		AAAA	$ip6
+smtp	3600	IN		A		$ip4
+		3600	IN		AAAA	$ip6
+www		3600	IN		A		$ip4
+		3600	IN		AAAA	$ip6
+xmpp	3600	IN		A		$ip4
+		3600	IN		AAAA	$ip6
+};
+			},
+		},
+		acme_client => {
+			filename => "/etc/acme-config.conf",
+			varlist => [qw(custDomain)],
+			type => 'custDomain',
+			template => sub {
+				my ($domain) = @_;
+				return qq{
+domain $domain {
+	alternative names {mail.$domain imap.$domain smtp.$domain www.$domain xmpp.$domain}
+	domain key "/etc/ssl/private/$domain.key"
+	domain full chain certificate "/etc/ssl/$domain.fullchain.pem"
+	sign with letsencrypt
+}
+};
+			},
+		},
+	});
+}
+
+1;
+
blob - 8313c0351fb7e61e41288518e9203c12969db67b
blob + 7b0e6b8c69c6a167232339aa6f1569d7357224b8
--- lib/IRCNOW/ConfigNow.pm
+++ lib/IRCNOW/ConfigNow.pm
@@ -43,6 +43,8 @@ sub new {
 	if (exists $options->{type} and (lc( $options->{type} ) eq 'shell')) {
 		$self->mod_load('mail','IRCNOW::ConfigNow::Module::SmtpDove');
 		$self->mod_load('xmpp','IRCNOW::ConfigNow::Module::Prosody');
+		$self->mod_load('acme','IRCNOW::ConfigNow::Module::AcmeClient');
+		$self->mod_load('custDomain','IRCNOW::ConfigNow::Module::CustDomain');
 	}
 	return $self;
 }
@@ -147,8 +149,17 @@ sub write_config {
 					delete $self->{vars}->{username};
 				}
 			}
+			# Output for $type = "custDomain"
+			if (exists $self->{vars}->{custDomain}) {
+warn "custDomain: $filename";
+				# generate output for type = 'custDomain'
+				my $out = $obj->output($filename, 'custDomain');
+				$output .= $out if defined $out;
+			}
 		}
-		$self->write_file($filename,$output);
+		if (length($output)>0) {	# Should we support empty files?
+			$self->write_file($filename,$output);
+		}
 	}
 	return 1;
 }