From ed30f2a619fb13515e3f446fe3f526db25cdd9a6 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Fri, 11 Sep 2020 16:18:45 -0700 Subject: [PATCH] cgi/html.cgi: allow running from command line There's really no reason to run the html.cgi script every time such a page is requested. The values being substituted are known at install time and do not change. Make it possible to easily run the cgi/html.cgi script from the command line by passing 2 (docroot template) or 3 (docroot template basedir) arguments in which case the response headers are also omitted from the output. Signed-off-by: Kyle J. McKay --- cgi/html.cgi | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cgi/html.cgi b/cgi/html.cgi index 7e9e8f0..9f3a67d 100755 --- a/cgi/html.cgi +++ b/cgi/html.cgi @@ -50,8 +50,17 @@ BEGIN { # /@@ifcustom@@...@@end@@/ remove if pretrustedroot defined (i.e. not custom root) # /@@ctr()@@/ replace with 1-based up-counting value -my $pathinfo = $ENV{PATH_INFO} || ''; -my $docroot = $ENV{DOCUMENT_ROOT} || ''; +my ($pathinfo, $docroot); +# Allow running from the command line +if (@ARGV == 2 || @ARGV == 3 and !defined($ENV{REQUEST_METHOD})) { + Girocco::CGI::enableHeader(0); + $pathinfo = $ARGV[1] || ''; + $docroot = $ARGV[0] || ''; + $Girocco::Config::basedir = $ARGV[2] if @ARGV == 3 && -d $ARGV[2]; +} else { + $pathinfo = $ENV{PATH_INFO} || ''; + $docroot = $ENV{DOCUMENT_ROOT} || ''; +} $pathinfo =~ s,^/,,; unless ($pathinfo) { my $gcgi = Girocco::CGI->new('HTML Templater'); -- 2.11.4.GIT