diff --git a/src/Tasks/Implementations/Deploy/Balancer/Factories/XDeployBalancerTaskFactoryImpl.pas b/src/Tasks/Implementations/Deploy/Balancer/Factories/XDeployBalancerTaskFactoryImpl.pas index 6a1edf4..2f7c75d 100644 --- a/src/Tasks/Implementations/Deploy/Balancer/Factories/XDeployBalancerTaskFactoryImpl.pas +++ b/src/Tasks/Implementations/Deploy/Balancer/Factories/XDeployBalancerTaskFactoryImpl.pas @@ -62,6 +62,7 @@ implementation ApacheReloadWebServerTaskImpl, NginxReloadWebServerTaskImpl, AddDomainToEtcHostTaskImpl, + WithSkipEtcHostTaskImpl, RootCheckTaskImpl, InFanoProjectDirCheckTaskImpl, WebServerTaskImpl, @@ -190,7 +191,12 @@ implementation //so it automatically enabled TNullTask.create() ), - TAddDomainToEtcHostTask.create(fReader, fWriter), + //wrap to allow skip domain name creation in /etc/host with + //--skip-etc-hosts parameter + TWithSkipEtcHostTask.create( + TNullTask.create(), + TAddDomainToEtcHostTask.create(fReader, fWriter) + ), TWebServerTask.create( TApacheReloadWebServerTask.create(), TNginxReloadWebServerTask.create() diff --git a/src/Tasks/Implementations/Deploy/Cgi/Factories/XDeployCgiTaskFactoryImpl.pas b/src/Tasks/Implementations/Deploy/Cgi/Factories/XDeployCgiTaskFactoryImpl.pas index ed79d85..26f39de 100644 --- a/src/Tasks/Implementations/Deploy/Cgi/Factories/XDeployCgiTaskFactoryImpl.pas +++ b/src/Tasks/Implementations/Deploy/Cgi/Factories/XDeployCgiTaskFactoryImpl.pas @@ -49,6 +49,7 @@ implementation ApacheEnableVhostTaskImpl, ApacheReloadWebServerTaskImpl, AddDomainToEtcHostTaskImpl, + WithSkipEtcHostTaskImpl, RootCheckTaskImpl, InFanoProjectDirCheckTaskImpl, WebServerTaskImpl, @@ -123,7 +124,12 @@ implementation //do nothing as nginx does not support CGI TNullTask.create() ), - TAddDomainToEtcHostTask.create(fReader, fWriter), + //wrap to allow skip domain name creation in /etc/host with + //--skip-etc-hosts parameter + TWithSkipEtcHostTask.create( + TNullTask.create(), + TAddDomainToEtcHostTask.create(fReader, fWriter) + ), TWebServerTask.create( TApacheReloadWebServerTask.create(), //do nothing as nginx does not support CGI diff --git a/src/Tasks/Implementations/Deploy/Core/WithSkipEtcHostTaskImpl.pas b/src/Tasks/Implementations/Deploy/Core/WithSkipEtcHostTaskImpl.pas new file mode 100644 index 0000000..ed22b54 --- /dev/null +++ b/src/Tasks/Implementations/Deploy/Core/WithSkipEtcHostTaskImpl.pas @@ -0,0 +1,52 @@ +(*!------------------------------------------------------------ + * Fano CLI Application (https://fanoframework.github.io) + * + * @link https://github.com/fanoframework/fano-cli + * @copyright Copyright (c) 2018 - 2020 Zamrony P. Juhara + * @license https://github.com/fanoframework/fano-cli/blob/master/LICENSE (MIT) + *------------------------------------------------------------- *) +unit WithSkipEtcHostTaskImpl; + +interface + +{$MODE OBJFPC} +{$H+} + +uses + + TaskOptionsIntf, + TaskIntf, + ConditionalCompositeTaskImpl; + +type + + (*!-------------------------------------- + * Task that run first task if --skip-etc-hosts + * parameter to skip domain entry creation + * in /etc/hosts or second task if default behavior + *---------------------------------------- + * @author Zamrony P. Juhara + *---------------------------------------*) + TWithSkipEtcHostTask = class(TConditionalCompositeTask) + protected + function condition( + const opt : ITaskOptions; + const longOpt : shortstring + ) : boolean; override; + end; + +implementation + +uses + + sysutils; + + function TWithSkipEtcHostTask.condition( + const opt : ITaskOptions; + const longOpt : shortstring + ) : boolean; + var routeMethods : TStringArray; + begin + result := opt.hasOption('skip-etc-hosts'); + end; +end. diff --git a/src/Tasks/Implementations/Deploy/Fcgi/Factories/XDeployFcgiTaskFactoryImpl.pas b/src/Tasks/Implementations/Deploy/Fcgi/Factories/XDeployFcgiTaskFactoryImpl.pas index 0a886cd..bbcf7ba 100644 --- a/src/Tasks/Implementations/Deploy/Fcgi/Factories/XDeployFcgiTaskFactoryImpl.pas +++ b/src/Tasks/Implementations/Deploy/Fcgi/Factories/XDeployFcgiTaskFactoryImpl.pas @@ -56,6 +56,7 @@ implementation ApacheReloadWebServerTaskImpl, NginxReloadWebServerTaskImpl, AddDomainToEtcHostTaskImpl, + WithSkipEtcHostTaskImpl, RootCheckTaskImpl, InFanoProjectDirCheckTaskImpl, WebServerTaskImpl, @@ -167,7 +168,12 @@ implementation //so it automatically enabled TNullTask.create() ), - TAddDomainToEtcHostTask.create(fReader, fWriter), + //wrap to allow skip domain name creation in /etc/host with + //--skip-etc-hosts parameter + TWithSkipEtcHostTask.create( + TNullTask.create(), + TAddDomainToEtcHostTask.create(fReader, fWriter) + ), TWebServerTask.create( TApacheReloadWebServerTask.create(), TNginxReloadWebServerTask.create() diff --git a/src/Tasks/Implementations/Deploy/Fcgid/Factories/XDeployFcgidTaskFactoryImpl.pas b/src/Tasks/Implementations/Deploy/Fcgid/Factories/XDeployFcgidTaskFactoryImpl.pas index 85517f8..f4fc0ce 100644 --- a/src/Tasks/Implementations/Deploy/Fcgid/Factories/XDeployFcgidTaskFactoryImpl.pas +++ b/src/Tasks/Implementations/Deploy/Fcgid/Factories/XDeployFcgidTaskFactoryImpl.pas @@ -50,6 +50,7 @@ implementation ApacheEnableVhostTaskImpl, ApacheReloadWebServerTaskImpl, AddDomainToEtcHostTaskImpl, + WithSkipEtcHostTaskImpl, RootCheckTaskImpl, InFanoProjectDirCheckTaskImpl, WebServerTaskImpl, @@ -125,7 +126,12 @@ implementation //nginx does not support so do nothing TNullTask.create() ), - TAddDomainToEtcHostTask.create(fReader, fWriter), + //wrap to allow skip domain name creation in /etc/host with + //--skip-etc-hosts parameter + TWithSkipEtcHostTask.create( + TNullTask.create(), + TAddDomainToEtcHostTask.create(fReader, fWriter) + ), TWebServerTask.create( TApacheReloadWebServerTask.create(), //nginx does not support so do nothing diff --git a/src/Tasks/Implementations/Deploy/Http/Factories/XDeployHttpTaskFactoryImpl.pas b/src/Tasks/Implementations/Deploy/Http/Factories/XDeployHttpTaskFactoryImpl.pas index 378bb6d..79f140c 100644 --- a/src/Tasks/Implementations/Deploy/Http/Factories/XDeployHttpTaskFactoryImpl.pas +++ b/src/Tasks/Implementations/Deploy/Http/Factories/XDeployHttpTaskFactoryImpl.pas @@ -57,6 +57,7 @@ implementation ApacheReloadWebServerTaskImpl, NginxReloadWebServerTaskImpl, AddDomainToEtcHostTaskImpl, + WithSkipEtcHostTaskImpl, RootCheckTaskImpl, InFanoProjectDirCheckTaskImpl, WebServerTaskImpl, @@ -168,7 +169,12 @@ implementation //so it automatically enabled TNullTask.create() ), - TAddDomainToEtcHostTask.create(fReader, fWriter), + //wrap to allow skip domain name creation in /etc/host with + //--skip-etc-hosts parameter + TWithSkipEtcHostTask.create( + TNullTask.create(), + TAddDomainToEtcHostTask.create(fReader, fWriter) + ), TWebServerTask.create( TApacheReloadWebServerTask.create(), TNginxReloadWebServerTask.create() diff --git a/src/Tasks/Implementations/Deploy/Scgi/Factories/XDeployScgiTaskFactoryImpl.pas b/src/Tasks/Implementations/Deploy/Scgi/Factories/XDeployScgiTaskFactoryImpl.pas index 88271f5..3318508 100644 --- a/src/Tasks/Implementations/Deploy/Scgi/Factories/XDeployScgiTaskFactoryImpl.pas +++ b/src/Tasks/Implementations/Deploy/Scgi/Factories/XDeployScgiTaskFactoryImpl.pas @@ -57,6 +57,7 @@ implementation ApacheReloadWebServerTaskImpl, NginxReloadWebServerTaskImpl, AddDomainToEtcHostTaskImpl, + WithSkipEtcHostTaskImpl, RootCheckTaskImpl, InFanoProjectDirCheckTaskImpl, WebServerTaskImpl, @@ -170,7 +171,12 @@ implementation //so it automatically enabled TNullTask.create() ), - TAddDomainToEtcHostTask.create(fReader, fWriter), + //wrap to allow skip domain name creation in /etc/host with + //--skip-etc-hosts parameter + TWithSkipEtcHostTask.create( + TNullTask.create(), + TAddDomainToEtcHostTask.create(fReader, fWriter) + ), TWebServerTask.create( TApacheReloadWebServerTask.create(), TNginxReloadWebServerTask.create() diff --git a/src/Tasks/Implementations/Deploy/Uwsgi/Factories/XDeployUwsgiTaskFactoryImpl.pas b/src/Tasks/Implementations/Deploy/Uwsgi/Factories/XDeployUwsgiTaskFactoryImpl.pas index 21735ed..7ff68f7 100644 --- a/src/Tasks/Implementations/Deploy/Uwsgi/Factories/XDeployUwsgiTaskFactoryImpl.pas +++ b/src/Tasks/Implementations/Deploy/Uwsgi/Factories/XDeployUwsgiTaskFactoryImpl.pas @@ -56,6 +56,7 @@ implementation ApacheReloadWebServerTaskImpl, NginxReloadWebServerTaskImpl, AddDomainToEtcHostTaskImpl, + WithSkipEtcHostTaskImpl, RootCheckTaskImpl, InFanoProjectDirCheckTaskImpl, WebServerTaskImpl, @@ -167,7 +168,12 @@ implementation //so it automatically enabled TNullTask.create() ), - TAddDomainToEtcHostTask.create(fReader, fWriter), + //wrap to allow skip domain name creation in /etc/host with + //--skip-etc-hosts parameter + TWithSkipEtcHostTask.create( + TNullTask.create(), + TAddDomainToEtcHostTask.create(fReader, fWriter) + ), TWebServerTask.create( TApacheReloadWebServerTask.create(), TNginxReloadWebServerTask.create()