| 1 | =head1 NAME | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | MKDoc::Setup::Site - Installs a new MKDoc site somewhere on the system | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | perl -MMKDoc::Setup -e install_site /var/www/example.com | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 SUMMARY | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | L<MKDoc::Core> is an application framework which aims at supporting easy-ish | ||||||||||||||||||||||||||||
| 14 | installation of multiple products onto multiple virtual hosts / websites. | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | Once you have installed the MKDoc master directory using L<MKDoc::Setup::Core>, | ||||||||||||||||||||||||||||
| 17 | you can add additional sites using this setup module. | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | =head1 PRE-REQUISITES | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | First, you need to make sure that you have deployed the L<MKDoc::Core> master | ||||||||||||||||||||||||||||
| 23 | repository using L<MKDoc::Setup::Core>. | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | Then, you need a domain name which points to the IP address of the machine on | ||||||||||||||||||||||||||||
| 26 | which you are setting up the new site. If you have no domain name, you can add | ||||||||||||||||||||||||||||
| 27 | one temporarily in your /etc/hosts file. | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | Finally, you need to choose a directory in which your L<MKDoc::Core> site is | ||||||||||||||||||||||||||||
| 30 | going to live. | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | For the sake of the example, we'll assume that we are using a domain called | ||||||||||||||||||||||||||||
| 33 | 'www.example.com' which will live in /var/www/example.com. | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | Note that you do not need to be root to install a new site. It would be best if | ||||||||||||||||||||||||||||
| 36 | you created /var/www/example.com as root and then changed the ownership to an | ||||||||||||||||||||||||||||
| 37 | unprivileged user. | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | =head1 SETTING UP | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | First there is a file in your mkdoc-core directory called 'mksetenv.sh'. You | ||||||||||||||||||||||||||||
| 43 | need to source this file. | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | source /usr/local/mkdoc-core/mksetenv.sh | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | Then run the following command: | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | perl -MMKDoc::Setup -e install_site /var/www/example.com | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | You should see the following screen: | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 1. MKDoc Directory /usr/local/mkdoc | ||||||||||||||||||||||||||||
| 54 | 2. Site Directory /var/www/mkdoc/example.com | ||||||||||||||||||||||||||||
| 55 | 3. Server Name www.example.com | ||||||||||||||||||||||||||||
| 56 | 4. Log Directory /var/www/mkdoc/example.com/log | ||||||||||||||||||||||||||||
| 57 | 5. Domain Admin Email tech@example.com | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | D. Delete an option | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | I. Install with the options above | ||||||||||||||||||||||||||||
| 62 | C. Cancel installation | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | Input your choice: | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | Make sure that everything's OK and press 'i' to install the site. | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | Restart Apache: | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | /usr/local/apache/bin/apachectl restart | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | Point your web browser to http://www.example.com/. If you see a page | ||||||||||||||||||||||||||||
| 73 | which says 'it worked!' then congratulations, you have installed a | ||||||||||||||||||||||||||||
| 74 | minimal L<MKDoc::Core> site. | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | If you so wish, you can now install more interesting modules such as | ||||||||||||||||||||||||||||
| 77 | L<MKDoc::Auth> or L<MKDoc::Forum>. | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | =cut | ||||||||||||||||||||||||||||
| 80 | package MKDoc::Setup::Site; | ||||||||||||||||||||||||||||
| 81 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 82 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 83 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 84 | 1 | ▶ | use File::Touch; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 85 | 1 | ▶ | use base qw /MKDoc::Setup/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | sub main::install_site | ||||||||||||||||||||||||||||
| 89 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
install_site: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 90 | 0 | $::SITE_DIR = shift (@ARGV); | |||||||||||||||||||||||||||
| 91 | 0 | __PACKAGE__->new()->process(); | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub keys { qw /MKDOC_DIR SITE_DIR SERVER_NAME LOG_DIR ADMIN/ } | ||||||||||||||||||||||||||
|
Subroutine
keys: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | sub label | ||||||||||||||||||||||||||||
| 99 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
label: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 100 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 101 | 0 | $_ = shift; | |||||||||||||||||||||||||||
| 102 | 0 | ▶ | /SERVER_NAME/ and return "Server Name"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | 0 | ▶ | /ADMIN/ and return "Domain Admin Email"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | 0 | ▶ | /MKDOC_DIR/ and return "MKDoc Directory"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | 0 | ▶ | /SITE_DIR/ and return "Site Directory"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 0 | ▶ | /LOG_DIR/ and return "Log Directory"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | 0 | return; | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | sub initialize | ||||||||||||||||||||||||||||
| 112 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
initialize: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 113 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 0 | ▶ | my $MKDOC_DIR = $ENV{MKDOC_DIR} || '/usr/local/mkdoc'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{'MKDOC_DIR'} || '/usr/local/mkdoc'
MC/DC0%0/1
$ENV{'MKDOC_DIR'} || '/usr/local/mkdoc'
$ENV{'MKDOC_DIR'}
Truth table0%0/2
A
A= $ENV{'MKDOC_DIR'}
| |||||||||||||||||||||||||||||
| 116 | 0 | ▶ | my $SITE_DIR = File::Spec->rel2abs ( $::SITE_DIR || $ENV{SITE_DIR} || '.' ); | ||||||||||||||||||||||||||
|
Condition0%0/5
$main::SITE_DIR || $ENV{'SITE_DIR'} || '.'
$main::SITE_DIR or $ENV{"SITE_DIR"}
MC/DC0%0/2
$main::SITE_DIR || $ENV{'SITE_DIR'} || '.'
$main::SITE_DIR
$ENV{"SITE_DIR"}
Truth table0%0/3
A or B
A= $main::SITE_DIRB= $ENV{"SITE_DIR"}
| |||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 0 | $MKDOC_DIR =~ s/\/$//; | |||||||||||||||||||||||||||
| 119 | 0 | $SITE_DIR =~ s/\/$//; | |||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 0 | my $name = $SITE_DIR; | |||||||||||||||||||||||||||
| 122 | 0 | $name =~ s/^.*\///; | |||||||||||||||||||||||||||
| 123 | 0 | $name =~ s/^www\.//; | |||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 0 | my $SERVER_NAME = "www.$name"; | |||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 0 | $self->{MKDOC_DIR} = $MKDOC_DIR; | |||||||||||||||||||||||||||
| 128 | 0 | $self->{SITE_DIR} = $SITE_DIR; | |||||||||||||||||||||||||||
| 129 | 0 | $self->{SERVER_NAME} = $SERVER_NAME; | |||||||||||||||||||||||||||
| 130 | 0 | $self->{ADMIN} = "tech\@$name"; | |||||||||||||||||||||||||||
| 131 | 0 | ▶ | $self->{LOG_DIR} = $ENV{LOG_SDIR} || $ENV{LOG_PREFIX} || "$SITE_DIR/log"; | ||||||||||||||||||||||||||
|
Condition0%0/5
$ENV{'LOG_SDIR'} || $ENV{'LOG_PREFIX'} || "$SITE_DIR/log"
$ENV{"LOG_SDIR"} or $ENV{"LOG_PREFIX"}
MC/DC0%0/2
$ENV{'LOG_SDIR'} || $ENV{'LOG_PREFIX'} || "$SITE_DIR/log"
$ENV{"LOG_SDIR"}
$ENV{"LOG_PREFIX"}
Truth table0%0/3
A or B
A= $ENV{"LOG_SDIR"}B= $ENV{"LOG_PREFIX"}
| |||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | sub validate | ||||||||||||||||||||||||||||
| 136 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
validate: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 137 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 0 | $self->validate_mkdoc_dir() & | |||||||||||||||||||||||||||
| 140 | $self->validate_site_dir() & | ||||||||||||||||||||||||||||
| 141 | $self->validate_server_name() & | ||||||||||||||||||||||||||||
| 142 | $self->validate_admin() & | ||||||||||||||||||||||||||||
| 143 | $self->validate_log_dir(); | ||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | sub validate_mkdoc_dir | ||||||||||||||||||||||||||||
| 148 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
validate_mkdoc_dir: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 149 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 150 | 0 | my $MKDOC_DIR = $self->{MKDOC_DIR}; | |||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 0 | ▶ | $MKDOC_DIR || do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 153 | 0 | print $self->label ('MKDOC_DIR') . " cannot be undefined\n"; | |||||||||||||||||||||||||||
| 154 | 0 | return 0; | |||||||||||||||||||||||||||
| 155 | }; | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 0 | ▶ | -e "$MKDOC_DIR/conf/httpd.conf" && -f "$MKDOC_DIR/conf/httpd.conf" || do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-e "$MKDOC_DIR/conf/httpd.conf" and -f "$MKDOC_DIR/conf/httpd.conf"
MC/DC0%0/2
-e "$MKDOC_DIR/conf/httpd.conf" and -f "$MKDOC_DIR/conf/httpd.conf"
-e "$MKDOC_DIR/conf/httpd.conf"
-f "$MKDOC_DIR/conf/httpd.conf"
Truth table0%0/3
A and B
A= -e "$MKDOC_DIR/conf/httpd.conf"B= -f "$MKDOC_DIR/conf/httpd.conf"
| |||||||||||||||||||||||||||||
| 158 | 0 | print <<EOF; | |||||||||||||||||||||||||||
| 159 | $MKDOC_DIR/conf/httpd.conf does not seem to exist. | ||||||||||||||||||||||||||||
| 160 | It seems that the MKDoc directory you specified is incorrect. | ||||||||||||||||||||||||||||
| 161 | EOF | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 0 | return 0; | |||||||||||||||||||||||||||
| 164 | }; | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 0 | return 1; | |||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | sub validate_site_dir | ||||||||||||||||||||||||||||
| 171 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
validate_site_dir: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 172 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 173 | 0 | my $SITE_DIR = $self->{SITE_DIR}; | |||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 0 | ▶ | $SITE_DIR || do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 176 | 0 | print $self->label ('SITE_DIR') . " cannot be undefined\n"; | |||||||||||||||||||||||||||
| 177 | 0 | return 0; | |||||||||||||||||||||||||||
| 178 | }; | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 0 | return 1; | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | sub validate_server_name | ||||||||||||||||||||||||||||
| 185 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
validate_server_name: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 186 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 187 | 0 | my $SERVER_NAME = $self->{SERVER_NAME}; | |||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 0 | ▶ | $SERVER_NAME || do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | 0 | print $self->label ('SERVER_NAME') . " cannot be undefined\n"; | |||||||||||||||||||||||||||
| 191 | 0 | return 0; | |||||||||||||||||||||||||||
| 192 | }; | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 0 | return 1; | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | sub validate_admin | ||||||||||||||||||||||||||||
| 199 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
validate_admin: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 200 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 201 | 0 | my $ADMIN = $self->{ADMIN}; | |||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 0 | ▶ | $ADMIN || do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 204 | 0 | print $self->label ('ADMIN') . " cannot be undefined\n"; | |||||||||||||||||||||||||||
| 205 | 0 | return 0; | |||||||||||||||||||||||||||
| 206 | }; | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 0 | return 1; | |||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | sub validate_log_dir | ||||||||||||||||||||||||||||
| 213 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
validate_log_dir: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 214 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 215 | 0 | my $LOG_DIR = $self->{LOG_DIR}; | |||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 0 | ▶ | $LOG_DIR || do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | 0 | print $self->label ('LOG_DIR') . " cannot be undefined\n"; | |||||||||||||||||||||||||||
| 219 | 0 | return 0; | |||||||||||||||||||||||||||
| 220 | }; | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 0 | return 1; | |||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | sub install | ||||||||||||||||||||||||||||
| 227 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
install: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 228 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 229 | 0 | $self->install_directories(); | |||||||||||||||||||||||||||
| 230 | 0 | $self->install_mksetenv(); | |||||||||||||||||||||||||||
| 231 | 0 | $self->install_httpd_conf(); | |||||||||||||||||||||||||||
| 232 | 0 | $self->install_httpd2_conf(); | |||||||||||||||||||||||||||
| 233 | 0 | $self->install_plugins(); | |||||||||||||||||||||||||||
| 234 | 0 | $self->install_register_site(); | |||||||||||||||||||||||||||
| 235 | 0 | $self->install_register2_site(); | |||||||||||||||||||||||||||
| 236 | 0 | exit (0); | |||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | sub install_directories | ||||||||||||||||||||||||||||
| 241 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
install_directories: not called CC=15 SCAR=54.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 242 | 0 | print "Installing directories... "; | |||||||||||||||||||||||||||
| 243 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 244 | 0 | my $SITE_DIR = $self->{SITE_DIR}; | |||||||||||||||||||||||||||
| 245 | 0 | my $LOG_DIR = $self->{LOG_DIR}; | |||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | 0 | ▶ | -d $SITE_DIR or mkdir $SITE_DIR or die "Cannot create $SITE_DIR"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-d $SITE_DIR or mkdir $SITE_DIR
MC/DC0%0/2
-d $SITE_DIR or mkdir $SITE_DIR
-d $SITE_DIR
mkdir $SITE_DIR
Truth table0%0/3
A or B
A= -d $SITE_DIRB= mkdir $SITE_DIR
| |||||||||||||||||||||||||||||
| 248 | 0 | ▶ | -d "$SITE_DIR/httpd" or mkdir "$SITE_DIR/httpd" or die "Cannot create $SITE_DIR/httpd"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-d "$SITE_DIR/httpd" or mkdir "$SITE_DIR/httpd"
MC/DC0%0/2
-d "$SITE_DIR/httpd" or mkdir "$SITE_DIR/httpd"
-d "$SITE_DIR/httpd"
mkdir "$SITE_DIR/httpd"
Truth table0%0/3
A or B
A= -d "$SITE_DIR/httpd"B= mkdir "$SITE_DIR/httpd"
| |||||||||||||||||||||||||||||
| 249 | 0 | ▶ | -d "$SITE_DIR/httpd2" or mkdir "$SITE_DIR/httpd2" or die "Cannot create $SITE_DIR/httpd2"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-d "$SITE_DIR/httpd2" or mkdir "$SITE_DIR/httpd2"
MC/DC0%0/2
-d "$SITE_DIR/httpd2" or mkdir "$SITE_DIR/httpd2"
-d "$SITE_DIR/httpd2"
mkdir "$SITE_DIR/httpd2"
Truth table0%0/3
A or B
A= -d "$SITE_DIR/httpd2"B= mkdir "$SITE_DIR/httpd2"
| |||||||||||||||||||||||||||||
| 250 | 0 | ▶ | -d "$SITE_DIR/init" or mkdir "$SITE_DIR/init" or die "Cannot create $SITE_DIR/init"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-d "$SITE_DIR/init" or mkdir "$SITE_DIR/init"
MC/DC0%0/2
-d "$SITE_DIR/init" or mkdir "$SITE_DIR/init"
-d "$SITE_DIR/init"
mkdir "$SITE_DIR/init"
Truth table0%0/3
A or B
A= -d "$SITE_DIR/init"B= mkdir "$SITE_DIR/init"
| |||||||||||||||||||||||||||||
| 251 | 0 | ▶ | -d "$SITE_DIR/plugin" or mkdir "$SITE_DIR/plugin" or die "Cannot create $SITE_DIR/plugin"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-d "$SITE_DIR/plugin" or mkdir "$SITE_DIR/plugin"
MC/DC0%0/2
-d "$SITE_DIR/plugin" or mkdir "$SITE_DIR/plugin"
-d "$SITE_DIR/plugin"
mkdir "$SITE_DIR/plugin"
Truth table0%0/3
A or B
A= -d "$SITE_DIR/plugin"B= mkdir "$SITE_DIR/plugin"
| |||||||||||||||||||||||||||||
| 252 | 0 | ▶ | -d "$SITE_DIR/cache" or mkdir "$SITE_DIR/cache" or die "Cannot create $SITE_DIR/plugin"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-d "$SITE_DIR/cache" or mkdir "$SITE_DIR/cache"
MC/DC0%0/2
-d "$SITE_DIR/cache" or mkdir "$SITE_DIR/cache"
-d "$SITE_DIR/cache"
mkdir "$SITE_DIR/cache"
Truth table0%0/3
A or B
A= -d "$SITE_DIR/cache"B= mkdir "$SITE_DIR/cache"
| |||||||||||||||||||||||||||||
| 253 | 0 | ▶ | -d $LOG_DIR or mkdir $LOG_DIR or die "Cannot create $LOG_DIR"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-d $LOG_DIR or mkdir $LOG_DIR
MC/DC0%0/2
-d $LOG_DIR or mkdir $LOG_DIR
-d $LOG_DIR
mkdir $LOG_DIR
Truth table0%0/3
A or B
A= -d $LOG_DIRB= mkdir $LOG_DIR
| |||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | 0 | chmod 0755, $SITE_DIR; | |||||||||||||||||||||||||||
| 256 | 0 | chmod 0755, "$SITE_DIR/httpd"; | |||||||||||||||||||||||||||
| 257 | 0 | chmod 0755, "$SITE_DIR/httpd2"; | |||||||||||||||||||||||||||
| 258 | 0 | chmod 0755, $LOG_DIR; | |||||||||||||||||||||||||||
| 259 | 0 | chmod 0777, "$SITE_DIR/cache"; | |||||||||||||||||||||||||||
| 260 | 0 | print "OK\n"; | |||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | sub install_mksetenv | ||||||||||||||||||||||||||||
| 265 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
install_mksetenv: not called CC=2 SCAR=14.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 266 | 0 | print "Creating mksetenv.sh... "; | |||||||||||||||||||||||||||
| 267 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 268 | 0 | my $MKDOC_DIR = $self->{MKDOC_DIR}; | |||||||||||||||||||||||||||
| 269 | 0 | my $SITE_DIR = $self->{SITE_DIR}; | |||||||||||||||||||||||||||
| 270 | 0 | my $ADMIN = $self->{ADMIN}; | |||||||||||||||||||||||||||
| 271 | 0 | my $SERVER_NAME = $self->{SERVER_NAME}; | |||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 0 | ▶ | open FP, ">$SITE_DIR/mksetenv.sh" or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 274 | 0 | warn "Cannot open-write $SITE_DIR/mksetenv.sh - skipping"; | |||||||||||||||||||||||||||
| 275 | 1 | ▶ | no warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 276 | 0 | close FP; | |||||||||||||||||||||||||||
| 277 | 0 | return; | |||||||||||||||||||||||||||
| 278 | }; | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 0 | print FP <<EOF; | |||||||||||||||||||||||||||
| 281 | source $MKDOC_DIR/mksetenv.sh | ||||||||||||||||||||||||||||
| 282 | export SITE_DIR="$SITE_DIR" | ||||||||||||||||||||||||||||
| 283 | export SERVER_ADMIN="$ADMIN" | ||||||||||||||||||||||||||||
| 284 | export SERVER_NAME="$SERVER_NAME" | ||||||||||||||||||||||||||||
| 285 | EOF | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | 0 | close FP; | |||||||||||||||||||||||||||
| 288 | 0 | chmod 0644, "$SITE_DIR/mksetenv.sh"; | |||||||||||||||||||||||||||
| 289 | 0 | print "OK\n"; | |||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | sub install_httpd_conf | ||||||||||||||||||||||||||||
| 294 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
install_httpd_conf: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 295 | 0 | print "Installing httpd.conf files... "; | |||||||||||||||||||||||||||
| 296 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 297 | 0 | my $SITE_DIR = $self->{SITE_DIR}; | |||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | # base httpd.conf file, for backwards compatibility | ||||||||||||||||||||||||||||
| 300 | 0 | open FP, ">$SITE_DIR/httpd.conf"; | |||||||||||||||||||||||||||
| 301 | 0 | print FP "Include $SITE_DIR/httpd/httpd.conf\n"; | |||||||||||||||||||||||||||
| 302 | 0 | close FP; | |||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | 0 | my $to_dir = "$SITE_DIR/httpd"; | |||||||||||||||||||||||||||
| 305 | 0 | for (@INC) | |||||||||||||||||||||||||||
| 306 | { | ||||||||||||||||||||||||||||
| 307 | 0 | my $from_dir = "$_/MKDoc/Core/Site/httpd_conf"; | |||||||||||||||||||||||||||
| 308 | 0 | ▶ | -d $from_dir || next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | 0 | ▶ | opendir DD, $from_dir or die "Cannot read-open $from_dir. Reason: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 311 | 0 | my @files = grep /\.conf$/, readdir (DD); | |||||||||||||||||||||||||||
| 312 | 0 | close DD; | |||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | 0 | for (@files) { $self->install_httpd_conf_file ("$from_dir/$_", "$to_dir/$_") } | |||||||||||||||||||||||||||
| 315 | 0 | last; | |||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 0 | print "OK\n"; | |||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | sub install_httpd2_conf | ||||||||||||||||||||||||||||
| 323 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
install_httpd2_conf: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 324 | 0 | print "Installing httpd2.conf files... "; | |||||||||||||||||||||||||||
| 325 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 326 | 0 | my $SITE_DIR = $self->{SITE_DIR}; | |||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 0 | my $to_dir = "$SITE_DIR/httpd2"; | |||||||||||||||||||||||||||
| 329 | 0 | for (@INC) | |||||||||||||||||||||||||||
| 330 | { | ||||||||||||||||||||||||||||
| 331 | 0 | my $from_dir = "$_/MKDoc/Core/Site/httpd2_conf"; | |||||||||||||||||||||||||||
| 332 | 0 | ▶ | -d $from_dir || next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | 0 | ▶ | opendir DD, $from_dir or die "Cannot read-open $from_dir. Reason: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 335 | 0 | my @files = grep /\.conf$/, readdir (DD); | |||||||||||||||||||||||||||
| 336 | 0 | close DD; | |||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | 0 | for (@files) { $self->install_httpd_conf_file ("$from_dir/$_", "$to_dir/$_") } | |||||||||||||||||||||||||||
| 339 | 0 | last; | |||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | 0 | print "OK\n"; | |||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | sub install_httpd_conf_file | ||||||||||||||||||||||||||||
| 347 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
install_httpd_conf_file: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 348 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 349 | 0 | my $source = shift; | |||||||||||||||||||||||||||
| 350 | 0 | my $target = shift; | |||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | 0 | my $MKDOC_DIR = $self->{MKDOC_DIR}; | |||||||||||||||||||||||||||
| 353 | 0 | my $SITE_DIR = $self->{SITE_DIR}; | |||||||||||||||||||||||||||
| 354 | 0 | my $LOG_DIR = $self->{LOG_DIR}; | |||||||||||||||||||||||||||
| 355 | 0 | my $SERVER_NAME = $self->{SERVER_NAME}; | |||||||||||||||||||||||||||
| 356 | 0 | my $ADMIN = $self->{ADMIN}; | |||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | 0 | ▶ | open FP, "<$source" or die "Cannot open-read $source. Reason: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 359 | 0 | my $data = join '', <FP>; | |||||||||||||||||||||||||||
| 360 | 0 | close FP; | |||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | 0 | ▶ | $data = eval "<<EOF; | ||||||||||||||||||||||||||
|
Condition0%0/2
eval "<<EOF;\n$data\nEOF\n" || ''
MC/DC0%0/1
eval "<<EOF;\n$data\nEOF\n" || ''
eval "<<EOF;\n$data\nEOF\n"
Truth table0%0/2
A
A= eval "<<EOF;\n$data\nEOF\n"
| |||||||||||||||||||||||||||||
| 363 | $data | ||||||||||||||||||||||||||||
| 364 | EOF | ||||||||||||||||||||||||||||
| 365 | " || ''; | ||||||||||||||||||||||||||||
| 366 | 0 | ▶ | warn $@ if ($@); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | 0 | ▶ | open FP, ">$target" or die "Cannot open-write $target. Reason: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 369 | 0 | print FP $data; | |||||||||||||||||||||||||||
| 370 | 0 | close FP; | |||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | 0 | chmod 0644, $target; | |||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | sub install_plugins | ||||||||||||||||||||||||||||
| 377 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
install_plugins: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 378 | 0 | print "Deploying plugins... "; | |||||||||||||||||||||||||||
| 379 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 380 | 0 | my $SITE_DIR = $self->{SITE_DIR}; | |||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | # framework initialization | ||||||||||||||||||||||||||||
| 383 | 0 | touch ("$SITE_DIR/init/10000_MKDoc::Core::Init::Petal"); | |||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | # plugins | ||||||||||||||||||||||||||||
| 386 | 0 | touch ("$SITE_DIR/plugin/20000_MKDoc::Core::Plugin::Resources"); | |||||||||||||||||||||||||||
| 387 | 0 | touch ("$SITE_DIR/plugin/85000_MKDoc::Core::Plugin::It_Worked"); | |||||||||||||||||||||||||||
| 388 | 0 | touch ("$SITE_DIR/plugin/90000_MKDoc::Core::Plugin::Not_Found"); | |||||||||||||||||||||||||||
| 389 | 0 | print "OK\n"; | |||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | sub install_register_site | ||||||||||||||||||||||||||||
| 394 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
install_register_site: not called CC=4 SCAR=27.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 395 | 0 | print "Registering site with Apache 1 config... "; | |||||||||||||||||||||||||||
| 396 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | 0 | my $MKDOC_DIR = $self->{MKDOC_DIR}; | |||||||||||||||||||||||||||
| 399 | 0 | my $SITE_DIR = $self->{SITE_DIR}; | |||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | 0 | my %pathes = (); | |||||||||||||||||||||||||||
| 402 | 0 | my $http_conf_file = File::Spec->canonpath ($MKDOC_DIR . '/conf/httpd.conf'); | |||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||
| 404 | 0 | ▶ | if (-e $http_conf_file) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 405 | { | ||||||||||||||||||||||||||||
| 406 | 0 | ▶ | open FP, "<$http_conf_file" || die "Cannot read-open $http_conf_file: Reason $@"; | ||||||||||||||||||||||||||
|
Condition0%0/2
"<$http_conf_file" || die("Cannot read-open ${http_conf_file}: Reason $@")
MC/DC0%0/1
"<$http_conf_file" || die("Cannot read-open ${http_conf_file}: Reason $@")
"<$http_conf_file"
Truth table0%0/2
A
A= "<$http_conf_file"
| |||||||||||||||||||||||||||||
| 407 | 0 | %pathes = map { chomp(); $_ => 1 } <FP>; | |||||||||||||||||||||||||||
| 408 | 0 | close FP; | |||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | 0 | $pathes{"Include $SITE_DIR/httpd.conf"} = 1; | |||||||||||||||||||||||||||
| 412 | 0 | ▶ | open FP, ">$http_conf_file" or die "Cannot write-open $http_conf_file. Reason: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 413 | { | ||||||||||||||||||||||||||||
| 414 | 0 | ▶ | no warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||
| 415 | 0 | print FP join "\n", sort keys %pathes; | |||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||
| 417 | 0 | print FP "\n"; | |||||||||||||||||||||||||||
| 418 | 0 | close FP; | |||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | 0 | print "OK\n"; | |||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | sub install_register2_site | ||||||||||||||||||||||||||||
| 425 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
install_register2_site: not called CC=4 SCAR=27.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 426 | 0 | print "Registering site with Apache 2 config... "; | |||||||||||||||||||||||||||
| 427 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | 0 | my $MKDOC_DIR = $self->{MKDOC_DIR}; | |||||||||||||||||||||||||||
| 430 | 0 | my $SITE_DIR = $self->{SITE_DIR}; | |||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||
| 432 | 0 | my %pathes = (); | |||||||||||||||||||||||||||
| 433 | 0 | my $http_conf_file = File::Spec->canonpath ($MKDOC_DIR . '/conf/httpd2.conf'); | |||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||
| 435 | 0 | ▶ | if (-e $http_conf_file) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 436 | { | ||||||||||||||||||||||||||||
| 437 | 0 | ▶ | open FP, "<$http_conf_file" || die "Cannot read-open $http_conf_file: Reason $@"; | ||||||||||||||||||||||||||
|
Condition0%0/2
"<$http_conf_file" || die("Cannot read-open ${http_conf_file}: Reason $@")
MC/DC0%0/1
"<$http_conf_file" || die("Cannot read-open ${http_conf_file}: Reason $@")
"<$http_conf_file"
Truth table0%0/2
A
A= "<$http_conf_file"
| |||||||||||||||||||||||||||||
| 438 | 0 | %pathes = map { chomp(); $_ => 1 } <FP>; | |||||||||||||||||||||||||||
| 439 | 0 | close FP; | |||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||
| 442 | 0 | $pathes{"Include $SITE_DIR/httpd2/httpd.conf"} = 1; | |||||||||||||||||||||||||||
| 443 | 0 | ▶ | open FP, ">$http_conf_file" or die "Cannot write-open $http_conf_file. Reason: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 444 | { | ||||||||||||||||||||||||||||
| 445 | 0 | ▶ | no warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||
| 446 | 0 | print FP join "\n", sort keys %pathes; | |||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||
| 448 | 0 | print FP "\n"; | |||||||||||||||||||||||||||
| 449 | 0 | close FP; | |||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||
| 451 | 0 | print "OK\n"; | |||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | 1 | 1; | |||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||
| 458 | __END__ | ||||||||||||||||||||||||||||