| 1 | #!/bin/perl | ||||||||||||||||||||
| 2 | # | ||||||||||||||||||||
| 3 | # This file is part of WebDyne. | ||||||||||||||||||||
| 4 | # | ||||||||||||||||||||
| 5 | # This software is copyright (c) 2026 by Andrew Speer <andrew.speer@isolutions.com.au>. | ||||||||||||||||||||
| 6 | # | ||||||||||||||||||||
| 7 | # This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||
| 8 | # the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||
| 9 | # | ||||||||||||||||||||
| 10 | # Full license text is available at: | ||||||||||||||||||||
| 11 | # | ||||||||||||||||||||
| 12 | # <http://dev.perl.org/licenses/> | ||||||||||||||||||||
| 13 | # | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | # Init Apache config files | ||||||||||||||||||||
| 18 | # | ||||||||||||||||||||
| 19 | 4 | ▶ | use strict qw(vars); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 20 | 4 | ▶ | use vars qw($VERSION); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 21 | 4 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | # External modules | ||||||||||||||||||||
| 25 | # | ||||||||||||||||||||
| 26 | 4 | ▶ | use Cwd qw(realpath); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 27 | 4 | ▶ | use WebDyne::Util; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 28 | 4 | ▶ | use Getopt::Long; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 29 | 4 | ▶ | use Pod::Usage; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 30 | 4 | ▶ | use FindBin qw($RealBin $Script); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 31 | 4 | ▶ | use Data::Dumper; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | # Local customisation | ||||||||||||||||||||
| 35 | # | ||||||||||||||||||||
| 36 | 4 | local $Data::Dumper::Indent=1; | |||||||||||||||||||
| 37 | 4 | local $Data::Dumper::Sortkeys=1; | |||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | # Version info | ||||||||||||||||||||
| 41 | # | ||||||||||||||||||||
| 42 | 4 | $VERSION='3.028'; | |||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | # Get command line options, add them to environment so picked up | ||||||||||||||||||||
| 46 | # by WebDyne::Install::Apache::Constant module when loaded | ||||||||||||||||||||
| 47 | # | ||||||||||||||||||||
| 48 | 4 | my %opt; | |||||||||||||||||||
| 49 | 4 | ▶ | GetOptions( | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 50 | \%opt, | ||||||||||||||||||||
| 51 | my @opt=( | ||||||||||||||||||||
| 52 | 'help|?', | ||||||||||||||||||||
| 53 | 'man', | ||||||||||||||||||||
| 54 | 'apache_uname|apache-uname|uname=s', | ||||||||||||||||||||
| 55 | 'apache_gname|apache-gname|gname=s', | ||||||||||||||||||||
| 56 | 'httpd_bin|httpd-bin|httpd=s', | ||||||||||||||||||||
| 57 | 'apachectl_bin|apachectl-bin|apachectl=s', | ||||||||||||||||||||
| 58 | 'apxs_bin|apxs-bin|apxs=s', | ||||||||||||||||||||
| 59 | 'dir_apache_conf|dir-apache-conf|apache_conf|apache-conf|conf=s', | ||||||||||||||||||||
| 60 | 'dir_apache_modules|dir-apache-modules|apache_modules|apache-modules|modules=s', | ||||||||||||||||||||
| 61 | 'file_mod_perl_lib|file-mod-perl-lib|mod_perl_lib|mod-perl-lib|mod_perl|mod-perl=s', | ||||||||||||||||||||
| 62 | 'mp2', | ||||||||||||||||||||
| 63 | 'webdyne_cache_dn|webdyne-cache-dn|webdyne_cache|webdyne-cache|cache_dn|cache-dn|cache|dir_webdyne_cache|dir-webdyne-cache=s', | ||||||||||||||||||||
| 64 | 'silent', | ||||||||||||||||||||
| 65 | 'setcontext', | ||||||||||||||||||||
| 66 | 'uninstall', | ||||||||||||||||||||
| 67 | 'text|print', | ||||||||||||||||||||
| 68 | 'dry_run|dry-run', | ||||||||||||||||||||
| 69 | 'dump_opt|dump-opt|opt', | ||||||||||||||||||||
| 70 | 'dump_config|dump-config|config', | ||||||||||||||||||||
| 71 | 'version' | ||||||||||||||||||||
| 72 | ) | ||||||||||||||||||||
| 73 | ) || pod2usage(2); | ||||||||||||||||||||
| 74 | pod2usage(-verbose => 99, -sections => 'SYNOPSIS|OPTIONS', -exitval => 1) | ||||||||||||||||||||
| 75 | 4 | ▶ | if $opt{'help'}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 76 | 4 | ▶ | pod2usage(-verbose => 2) if $opt{'man'}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 77 | 4 | ▶ | $opt{'version'} && do {print "$Script version: $VERSION\n"; exit 0}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | # Dump options for debugging | ||||||||||||||||||||
| 81 | # | ||||||||||||||||||||
| 82 | 3 | ▶ | die Dumper(\%opt) if $opt{'dump_opt'}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | ## no critic (Variables::RequireLocalizedPunctuationVars) | ||||||||||||||||||||
| 85 | 2 | map {$ENV{uc($_)}=$opt{$_}} keys %opt; | |||||||||||||||||||
| 86 | ## use critic | ||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | # By default the WebDyne::Install::Apache::Constant module will issue a | ||||||||||||||||||||
| 89 | # warning if something not found, but will continue. In this case we want | ||||||||||||||||||||
| 90 | # to consider any warning fatal. | ||||||||||||||||||||
| 91 | # | ||||||||||||||||||||
| 92 | local $SIG{'__WARN__'}=sub { | ||||||||||||||||||||
| 93 | 2 | ▶ | my $warn=shift(); | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||
| 94 | 2 | my %warn=( | |||||||||||||||||||
| 95 | APACHE_UNAME => '--uname', | ||||||||||||||||||||
| 96 | APACHE_GNAME => '--gname', | ||||||||||||||||||||
| 97 | HTTPD_BIN => '--httpd_bin', | ||||||||||||||||||||
| 98 | DIR_APACHE_CONF => '--dir_apache_conf', | ||||||||||||||||||||
| 99 | FILE_MOD_PERL_LIB => '--mod_perl_lib', | ||||||||||||||||||||
| 100 | ); | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | # Translate warning messages from Contants module about setting env vars into | ||||||||||||||||||||
| 103 | # messages about setting command line options. Crude, but will do for now. | ||||||||||||||||||||
| 104 | # | ||||||||||||||||||||
| 105 | 2 | ▶ | while (my ($env, $param)=each %warn) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 106 | 3 | ▶ | last if $warn=~s/(.*)$env.*/$1$param option./; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 107 | } | ||||||||||||||||||||
| 108 | 2 | pod2usage(-verbose => 99, -sections => 'Options', -message => "ERROR: " . ucfirst($warn)) | |||||||||||||||||||
| 109 | 2 | }; | |||||||||||||||||||
| 110 | 2 | require WebDyne::Install::Apache; | |||||||||||||||||||
| 111 | 0 | ▶ | if ($opt{'dump_config'}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 112 | 4 | ▶ | no warnings qw(once); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 113 | 0 | die Dumper(\%WebDyne::Install::Apache::Constant::Constant); | |||||||||||||||||||
| 114 | } | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | |||||||||||||||||||||
| 117 | # Get location prefile, call install/uninstall routine | ||||||||||||||||||||
| 118 | # | ||||||||||||||||||||
| 119 | 0 | my $prefix_dn=realpath(File::Spec->rel2abs(File::Spec->updir(), $RealBin)); | |||||||||||||||||||
| 120 | 0 | debug("about to call install/uninstall with prefix_dn: $prefix_dn, RealBin: $RealBin, opt: %s", Dumper(\%opt)); | |||||||||||||||||||
| 121 | 0 | my $rc; | |||||||||||||||||||
| 122 | 0 | ▶ | if ($opt{'uninstall'}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 123 | 0 | ▶ | $rc=${WebDyne::Install::Apache->uninstall($prefix_dn, $RealBin, \%opt) || die errstr()} || 0; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
${'WebDyne::Install::Apache'->uninstall($prefix_dn, $main::RealBin, \%opt) or die errstr();} || 0
MC/DC0%0/1
${'WebDyne::Install::Apache'->uninstall($prefix_dn, $main::RealBin, \%opt) or die errstr();} || 0
${'WebDyne::Install::Apache'->uninstall($prefix_dn, $main::RealBin, \%opt) or die errstr();}
Truth table0%0/2
A
A= ${'WebDyne::Install::Apache'->uninstall($prefix_dn, $main::RealBin, \%opt) or die errstr();}
| |||||||||||||||||||||
| 124 | } | ||||||||||||||||||||
| 125 | else { | ||||||||||||||||||||
| 126 | 0 | ▶ | $rc=${WebDyne::Install::Apache->install($prefix_dn, $RealBin, \%opt) || die errstr()} || 0; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
${'WebDyne::Install::Apache'->install($prefix_dn, $main::RealBin, \%opt) or die errstr();} || 0
MC/DC0%0/1
${'WebDyne::Install::Apache'->install($prefix_dn, $main::RealBin, \%opt) or die errstr();} || 0
${'WebDyne::Install::Apache'->install($prefix_dn, $main::RealBin, \%opt) or die errstr();}
Truth table0%0/2
A
A= ${'WebDyne::Install::Apache'->install($prefix_dn, $main::RealBin, \%opt) or die errstr();}
| |||||||||||||||||||||
| 127 | } | ||||||||||||||||||||
| 128 | 0 | exit $rc; | |||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | __END__ | ||||||||||||||||||||