line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Copyright (C) 2006-2010 Andrew Speer . All rights |
4
|
|
|
|
|
|
|
# reserved. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This file is part of WebDyne::Install::Lighttpd. |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# WebDyne::Install is free software; you can redistribute it and/or modify |
9
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by |
10
|
|
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or |
11
|
|
|
|
|
|
|
# (at your option) any later version. |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
14
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
|
|
|
|
# GNU General Public License for more details. |
17
|
|
|
|
|
|
|
# |
18
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
19
|
|
|
|
|
|
|
# along with this program; if not, write to the Free Software |
20
|
|
|
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21
|
|
|
|
|
|
|
# |
22
|
|
|
|
|
|
|
# |
23
|
|
|
|
|
|
|
package WebDyne::Install::Lighttpd::Constant; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Pragma |
27
|
|
|
|
|
|
|
# |
28
|
1
|
|
|
1
|
|
5
|
use strict qw(vars); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Vars to use |
32
|
|
|
|
|
|
|
# |
33
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @ISA %EXPORT_TAGS @EXPORT_OK @EXPORT %Constant); |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
91
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# External modules |
37
|
|
|
|
|
|
|
# |
38
|
1
|
|
|
1
|
|
6
|
use File::Find; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
61
|
|
39
|
1
|
|
|
1
|
|
5
|
use File::Spec; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
26
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Other Constants |
43
|
|
|
|
|
|
|
# |
44
|
1
|
|
|
1
|
|
5
|
use WebDyne::Constant; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
514
|
|
45
|
1
|
|
|
1
|
|
6
|
use WebDyne::Install::Constant; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
893
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Version information in a format suitable for CPAN etc. Must be |
49
|
|
|
|
|
|
|
# all on one line |
50
|
|
|
|
|
|
|
# |
51
|
|
|
|
|
|
|
$VERSION='1.002'; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Name of user httpd runs under |
57
|
|
|
|
|
|
|
# |
58
|
|
|
|
|
|
|
my ($lighttpd_uname, $lighttpd_gname, $lighttpd_uid, $lighttpd_gid); |
59
|
|
|
|
|
|
|
my @lighttpd_uname=$ENV{'LIGHTTPD_UNAME'} |
60
|
|
|
|
|
|
|
|| qw(lighttpd www-data); |
61
|
|
|
|
|
|
|
foreach my $name (@lighttpd_uname) { |
62
|
|
|
|
|
|
|
unless ($lighttpd_uid || $^O=~/MSWin[32|64]/) { |
63
|
|
|
|
|
|
|
if ($lighttpd_uid=getpwnam($name)) { $lighttpd_uname=$name; last } |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
my @lighttpd_gname=$ENV{'LIGHTTPD_GNAME'} |
67
|
|
|
|
|
|
|
|| qw(lighttpd www-data); |
68
|
|
|
|
|
|
|
foreach my $name (@lighttpd_gname) { |
69
|
|
|
|
|
|
|
unless ($lighttpd_gid || $^O=~/MSWin[32|64]/) { |
70
|
|
|
|
|
|
|
if ($lighttpd_gid=getgrnam($name)) { $lighttpd_gname=$name; last } |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Check we have something fo uname etc. |
76
|
|
|
|
|
|
|
# |
77
|
|
|
|
|
|
|
unless ($lighttpd_uid || $^O=~/MSWin[32|64]/ ) { |
78
|
|
|
|
|
|
|
warn('unable to determine lighttpd user name - please supply correct name via LIGHTTPD_UNAME environment variable')}; |
79
|
|
|
|
|
|
|
unless ($lighttpd_gid || $^O=~/MSWin[32|64]/ ) { |
80
|
|
|
|
|
|
|
warn('unable to determine lighttpd group name - please supply correct name via LIGHTTPD_GNAME environment variable')}; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Get lighttpd conf file and dir |
85
|
|
|
|
|
|
|
# |
86
|
|
|
|
|
|
|
my $lighttpd_conf_fn=&file_lighttpd_conf(); |
87
|
|
|
|
|
|
|
my $lighttpd_conf_dn=(File::Spec->splitpath($lighttpd_conf_fn))[1]; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# Real deal |
91
|
|
|
|
|
|
|
# |
92
|
|
|
|
|
|
|
%Constant = ( |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# Config file templates and final names, delimiter if inserted into master httpd.conf |
96
|
|
|
|
|
|
|
# |
97
|
|
|
|
|
|
|
FILE_WEBDYNE_CONF_TEMPLATE => 'webdyne.conf.inc', |
98
|
|
|
|
|
|
|
FILE_WEBDYNE_CONF => 'webdyne.conf', |
99
|
|
|
|
|
|
|
FILE_LIGHTTPD_CONF_TEMPLATE => 'lighttpd.conf.inc', |
100
|
|
|
|
|
|
|
FILE_LIGHTTPD_CONF_DELIM => '#== WebDyne '.('=' x 68), |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# The fastcgi binary |
104
|
|
|
|
|
|
|
# |
105
|
|
|
|
|
|
|
FILE_FASTCGI_BIN => 'wdfastcgi', |
106
|
|
|
|
|
|
|
FILE_FASTCGI_SOCKET => 'wdfastcgi-webdyne.sock', |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# Get lighttpd directory name |
110
|
|
|
|
|
|
|
# |
111
|
|
|
|
|
|
|
FILE_LIGHTTPD_CONF => $lighttpd_conf_fn, |
112
|
|
|
|
|
|
|
DIR_LIGHTTPD_CONF => $lighttpd_conf_dn, |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# Need lighttpd uid and gid, as some dirs will be chowned to this |
116
|
|
|
|
|
|
|
# at install time |
117
|
|
|
|
|
|
|
# |
118
|
|
|
|
|
|
|
LIGHTTPD_UNAME => $lighttpd_uname, |
119
|
|
|
|
|
|
|
LIGHTTPD_GNAME => $lighttpd_gname, |
120
|
|
|
|
|
|
|
LIGHTTPD_UID => $lighttpd_uid, |
121
|
|
|
|
|
|
|
LIGHTTPD_GID => $lighttpd_gid, |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
); |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# Get absolute config file location |
128
|
|
|
|
|
|
|
# |
129
|
|
|
|
|
|
|
sub file_lighttpd_conf { |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# If in Win32 need to get location of Apache from reg. Not much error checking |
133
|
|
|
|
|
|
|
# because not fatal if reg key not found etc. |
134
|
|
|
|
|
|
|
# |
135
|
1
|
|
|
1
|
0
|
2
|
my $path; |
136
|
1
|
50
|
|
|
|
6
|
if ($^O=~/MSWin[32|64]/) { |
137
|
0
|
|
|
|
|
0
|
$path= |
138
|
|
|
|
|
|
|
# last resorts. blech |
139
|
|
|
|
|
|
|
'C:\Lighttpd;C:\Progra~1\Lighttpd;'. |
140
|
|
|
|
|
|
|
'D:\Lighttpd;D:\Progra~1\Lighttpd;'. |
141
|
|
|
|
|
|
|
'E:\Lighttpd;E:\Progra~1\Lighttpd;'; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
else { |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# Add some hard coded paths as last resort options. |
146
|
|
|
|
|
|
|
# |
147
|
1
|
|
|
|
|
2
|
$path='/etc/lighttpd'; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# Only one name we are looking for .. for now. Put in an arrey for the future |
152
|
|
|
|
|
|
|
# |
153
|
1
|
|
|
|
|
3
|
my @name_conf=qw(lighttpd.conf); |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
# Find the httpd conf file if not spec'd in environment var |
157
|
|
|
|
|
|
|
# |
158
|
1
|
|
|
|
|
2
|
my $httpd_conf; |
159
|
1
|
50
|
|
|
|
6
|
unless ($httpd_conf=$ENV{'FILE_LIGHTTPD_CONF'}) { |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
1
|
|
|
|
|
18
|
my @dir=grep { -d $_ } split(/:|;/, $path); |
|
1
|
|
|
|
|
19
|
|
163
|
1
|
|
|
|
|
6
|
my %dir=map { $_=> 1} @dir; |
|
0
|
|
|
|
|
0
|
|
164
|
1
|
|
|
|
|
4
|
DIR: foreach my $dir (@dir) { |
165
|
0
|
0
|
|
|
|
0
|
next unless delete $dir{$dir}; |
166
|
0
|
0
|
|
|
|
0
|
next unless -d $dir; |
167
|
0
|
|
|
|
|
0
|
foreach my $name_conf (@name_conf) { |
168
|
0
|
0
|
|
|
|
0
|
if (-f File::Spec->catfile($dir, $name_conf)) { |
169
|
0
|
|
|
|
|
0
|
$httpd_conf=File::Spec->catfile($dir, $name_conf); |
170
|
0
|
|
|
|
|
0
|
last DIR; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
# Warn if unable to find |
178
|
|
|
|
|
|
|
# |
179
|
1
|
50
|
|
|
|
8
|
unless (-f $httpd_conf) { |
180
|
1
|
|
|
|
|
214
|
warn('unable find lighttpd config file location - please supply via FILE_LIGHTTPD_CONF environment var'); |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
# Return |
185
|
|
|
|
|
|
|
# |
186
|
1
|
|
|
|
|
41
|
return File::Spec->canonpath($httpd_conf); |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
# Finalise and export vars |
192
|
|
|
|
|
|
|
# |
193
|
|
|
|
|
|
|
require Exporter; |
194
|
|
|
|
|
|
|
require WebDyne::Constant; |
195
|
|
|
|
|
|
|
@ISA=qw(Exporter WebDyne::Constant); |
196
|
|
|
|
|
|
|
# Local constants override globals |
197
|
|
|
|
|
|
|
+__PACKAGE__->local_constant_load(\%Constant); |
198
|
|
|
|
|
|
|
foreach (keys %Constant) { ${$_}=$Constant{$_} } |
199
|
|
|
|
|
|
|
@EXPORT=map { '$'.$_ } keys %Constant; |
200
|
|
|
|
|
|
|
@EXPORT_OK=@EXPORT; |
201
|
|
|
|
|
|
|
%EXPORT_TAGS=(all => [@EXPORT_OK]); |
202
|
|
|
|
|
|
|
$_=\%Constant; |