Skip to content

Commit

Permalink
Item14409: Document CLI wizard operation
Browse files Browse the repository at this point in the history
And add validations, since CLI doesn't have benefit of dropdown lists.
  • Loading branch information
gac410 committed May 29, 2017
1 parent b4acaf1 commit cb119db
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
16 changes: 16 additions & 0 deletions data/System/VirtualHostingContrib.txt
Expand Up @@ -213,6 +213,22 @@ the master site's configured names, then a custom =virtualhost.conf= *must* be
used.
</div>

---++++ Running the wizard with =tools/configure=

The =CreateVHost= wizard can be run from the CLI as well. The arguments are:

| *Parameter* | *Description* | *default* | *Example* |
| =name= | virtual hostname to create | (required) | =-args name=foo.mysite.com= |
| =createpasswd= | Create the =.htpasswd= file. | no password file created | =-args createpasswd=1= |
| =template= | Template host to copy | host will be copied from master webs | =-args template=_templateweb= |
| =templatecfg= | Template file to copy into configuration | no config created | =-args templatecfg=_template.conf= |

*Caution:* Always run this wizard using the web server's userid
<verbatim>
sudo -u www-data tools/configure -wizard CreateVHost -method create_vhost_2 -args name=foo.site.com -args createpasswd=1
sudo -u www-data tools/configure -wizard CreateVHost -method create_vhost_2 -args name=foo2.site.com -args template=_template templatecfg=_template.conf
</verbatim>


---++++ Managing virtual hosts

Expand Down
14 changes: 12 additions & 2 deletions lib/Foswiki/Configure/Wizards/CreateVHost.pm
Expand Up @@ -83,7 +83,7 @@ sub create_vhost_1 {
$reporter->NOTE($form);
my %data = (
wizard => 'CreateVHost',
method => 'create_vhost_2',
method => 'run_create',
form => '#create_vhost',
args => {

Expand All @@ -100,7 +100,7 @@ sub create_vhost_1 {
=cut

sub create_vhost_2 {
sub run_create {
my ( $this, $reporter ) = @_;

my $args = $this->param('args');
Expand Down Expand Up @@ -146,6 +146,16 @@ sub _create_vhost {
return 0;
}

# Validate input
if ( $template && ! -d "$vdir/$template" ) {
$reporter->ERROR("Requested template host =$template= does not exist in =$vdir=!");
return 0;
}
if ( $cfgtemplate && ! -f "$vdir/$cfgtemplate" ) {
$reporter->ERROR("Requested template configuration =$cfgtemplate= does not exist in =$vdir=!");
return 0;
}

if ( $template && -d "$vdir/$template" ) {
$this->_createFromTemplate($reporter);
}
Expand Down

0 comments on commit cb119db

Please sign in to comment.