| 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 | 8 | ▶ | use strict qw(vars); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 20 | 8 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 21 | 8 | ▶ | use warnings; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 22 | |||||||||||||||||||||||
| 23 | |||||||||||||||||||||||
| 24 | # External modules | ||||||||||||||||||||||
| 25 | # | ||||||||||||||||||||||
| 26 | 8 | ▶ | use Cwd qw(realpath); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 27 | 8 | ▶ | use WebDyne::Util; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 28 | 8 | ▶ | use Getopt::Long; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 29 | 8 | ▶ | use Pod::Usage; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 30 | 8 | ▶ | use FindBin qw($RealBin $Script); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 31 | 8 | ▶ | use Data::Dumper; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 32 | |||||||||||||||||||||||
| 33 | |||||||||||||||||||||||
| 34 | # Local customisation | ||||||||||||||||||||||
| 35 | # | ||||||||||||||||||||||
| 36 | 8 | local $Data::Dumper::Indent=1; | |||||||||||||||||||||
| 37 | 8 | local $Data::Dumper::Sortkeys=1; | |||||||||||||||||||||
| 38 | |||||||||||||||||||||||
| 39 | |||||||||||||||||||||||
| 40 | # Version info | ||||||||||||||||||||||
| 41 | # | ||||||||||||||||||||||
| 42 | 8 | $VERSION='3.029'; | |||||||||||||||||||||
| 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 | 8 | my %opt; | |||||||||||||||||||||
| 49 | 8 | ▶ | 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 | 8 | ▶ | if $opt{'help'}; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 76 | 8 | ▶ | pod2usage(-verbose => 2) if $opt{'man'}; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 77 | 8 | ▶ | $opt{'version'} && do {print "$Script version: $VERSION\n"; exit 0}; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 78 | |||||||||||||||||||||||
| 79 | |||||||||||||||||||||||
| 80 | # Dump options for debugging | ||||||||||||||||||||||
| 81 | # | ||||||||||||||||||||||
| 82 | 7 | ▶ | die Dumper(\%opt) if $opt{'dump_opt'}; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 83 | |||||||||||||||||||||||
| 84 | ## no critic (Variables::RequireLocalizedPunctuationVars) | ||||||||||||||||||||||
| 85 | 6 | 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 | 2 | ▶ | local $SIG{'__WARN__'}=sub { | ||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||
| 93 | 2 | my $warn=shift(); | |||||||||||||||||||||
| 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 | 5 | ▶ | last if $warn=~s/(.*)$env.*/$1$param option./; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||
| 108 | 2 | pod2usage(-verbose => 99, -sections => 'Options', -message => "ERROR: " . ucfirst($warn)) | |||||||||||||||||||||
| 109 | 6 | }; | |||||||||||||||||||||
| 110 | 6 | require WebDyne::Install::Apache; | |||||||||||||||||||||
| 111 | 4 | ▶ | if ($opt{'dump_config'}) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 112 | 8 | ▶ | 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 | 4 | my $prefix_dn=realpath(File::Spec->rel2abs(File::Spec->updir(), $RealBin)); | |||||||||||||||||||||
| 120 | 4 | debug("about to call install/uninstall with prefix_dn: $prefix_dn, RealBin: $RealBin, opt: %s", Dumper(\%opt)); | |||||||||||||||||||||
| 121 | 4 | my $rc; | |||||||||||||||||||||
| 122 | 4 | ▶ | if ($opt{'uninstall'}) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 123 | 2 | ▶ | $rc=${WebDyne::Install::Apache->uninstall($prefix_dn, $RealBin, \%opt) || die errstr()} || 0; | ||||||||||||||||||||
|
Condition50%2/4
${'WebDyne::Install::Apache'->uninstall($prefix_dn, $main::RealBin, \%opt) or die errstr();} || 0
'WebDyne::Install::Apache'->uninstall($prefix_dn, $main::RealBin, \%opt) || die(errstr())
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();}
MC/DC0%0/1
'WebDyne::Install::Apache'->uninstall($prefix_dn, $main::RealBin, \%opt) || die(errstr())
'WebDyne::Install::Apache'->uninstall($prefix_dn, $main::RealBin, \%opt)
Truth table50%1/2
A
A= ${'WebDyne::Install::Apache'->uninstall($prefix_dn, $main::RealBin, \%opt) or die errstr();}
Truth table50%1/2
A
A= 'WebDyne::Install::Apache'->uninstall($prefix_dn, $main::RealBin, \%opt)
| |||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||
| 125 | else { | ||||||||||||||||||||||
| 126 | 2 | ▶ | $rc=${WebDyne::Install::Apache->install($prefix_dn, $RealBin, \%opt) || die errstr()} || 0; | ||||||||||||||||||||
|
Condition50%2/4
${'WebDyne::Install::Apache'->install($prefix_dn, $main::RealBin, \%opt) or die errstr();} || 0
'WebDyne::Install::Apache'->install($prefix_dn, $main::RealBin, \%opt) || die(errstr())
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();}
MC/DC0%0/1
'WebDyne::Install::Apache'->install($prefix_dn, $main::RealBin, \%opt) || die(errstr())
'WebDyne::Install::Apache'->install($prefix_dn, $main::RealBin, \%opt)
Truth table50%1/2
A
A= ${'WebDyne::Install::Apache'->install($prefix_dn, $main::RealBin, \%opt) or die errstr();}
Truth table50%1/2
A
A= 'WebDyne::Install::Apache'->install($prefix_dn, $main::RealBin, \%opt)
| |||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||
| 128 | 4 | exit $rc; | |||||||||||||||||||||
| 129 | |||||||||||||||||||||||
| 130 | __END__ | ||||||||||||||||||||||