Skip to content

Commit 1f34a6a

Browse files
committed
Add ability to control default website page from templates 4/4
* Consider template options when creating domain using CLI
1 parent 22da13e commit 1f34a6a

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

Diff for: api-create-domain-lib.pl

+17-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
no warnings 'uninitialized';
55

66
our (%config, %text, @features, @aliasmail_features, @alias_features,
7-
@opt_subdom_features, @banned_usernames, $first_print, $second_print);
7+
@opt_subdom_features, @banned_usernames, $first_print, $second_print,
8+
$virtualmin_pro);
89

910
# create_domain_cli(domain-name, &opts)
1011
# This sub is fully compatible with the ‘create-domain.pl’ API. Returns an error
@@ -948,6 +949,21 @@ sub create_domain_cli
948949
}
949950
}
950951

952+
# Content can come from template
953+
if (!defined($content)) {
954+
my $content_web_tmpl = $tmpl->{'content_web'};
955+
my $content_web_tmpl_html_file = $tmpl->{'content_web_html'};
956+
# Default HTML page
957+
if ($content_web_tmpl == 2) {
958+
$content = "";
959+
}
960+
# Want to set content to the given from file
961+
elsif (!$content_web_tmpl && $virtualmin_pro &&
962+
-r $content_web_tmpl_html_file) {
963+
$content = &read_file_contents($content_web_tmpl_html_file);
964+
}
965+
}
966+
951967
# Do it
952968
&lock_domain(\%dom);
953969
$config{'pre_command'} = $precommand if ($precommand);

Diff for: create-domain.pl

+15
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,21 @@ package virtual_server;
10171017
}
10181018
}
10191019

1020+
# Content can come from template
1021+
if (!defined($content)) {
1022+
my $content_web_tmpl = $tmpl->{'content_web'};
1023+
my $content_web_tmpl_html_file = $tmpl->{'content_web_html'};
1024+
# Default HTML page
1025+
if ($content_web_tmpl == 2) {
1026+
$content = "";
1027+
}
1028+
# Want to set content to the given from file
1029+
elsif (!$content_web_tmpl && $virtualmin_pro &&
1030+
-r $content_web_tmpl_html_file) {
1031+
$content = &read_file_contents($content_web_tmpl_html_file);
1032+
}
1033+
}
1034+
10201035
# Do it
10211036
print "Beginning server creation ..\n\n";
10221037
&lock_domain(\%dom);

0 commit comments

Comments
 (0)