line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GBrowseGuessDirectories; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
464
|
use IO::Socket::INET; |
|
1
|
|
|
|
|
6324
|
|
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
345
|
use File::Spec; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
716
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
my $PREFIX; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub prefix { |
9
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
10
|
0
|
|
|
|
|
|
my $d = $PREFIX; |
11
|
0
|
0
|
|
|
|
|
$PREFIX = shift if @_; |
12
|
0
|
|
|
|
|
|
return $d; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# this package never gets installed - it's just used by Makefile.PL |
16
|
|
|
|
|
|
|
sub conf { |
17
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
18
|
0
|
0
|
|
|
|
|
return File::Spec->catfile($PREFIX,'etc','gbrowse2') if $PREFIX; |
19
|
|
|
|
|
|
|
|
20
|
0
|
0
|
|
|
|
|
if ($^O =~ /mswin/i) { # windows system |
21
|
0
|
|
|
|
|
|
return File::Spec->catfile('C:','Program Files','GBrowse2','conf'); |
22
|
|
|
|
|
|
|
} else { |
23
|
0
|
|
|
|
|
|
for ( |
24
|
|
|
|
|
|
|
'/etc', |
25
|
|
|
|
|
|
|
'/usr/etc', |
26
|
|
|
|
|
|
|
'/usr/local/etc', |
27
|
|
|
|
|
|
|
) { |
28
|
0
|
0
|
|
|
|
|
return File::Spec->catfile($_,'gbrowse2') if -d $_; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
0
|
|
0
|
|
|
|
return File::Spec->catfile($self->prefix || '/usr/local/etc','gbrowse2'); # fallback |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub etc { |
35
|
0
|
|
|
0
|
0
|
|
shift; |
36
|
0
|
0
|
|
|
|
|
return File::Spec->catfile($PREFIX,'etc') if $PREFIX; |
37
|
0
|
|
|
|
|
|
return '/etc'; # no exceptions |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub tmp { |
41
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
42
|
0
|
0
|
|
|
|
|
return File::Spec->catfile($PREFIX,'tmp','gbrowse2') if $PREFIX; |
43
|
0
|
0
|
|
|
|
|
return '/srv/gbrowse2/tmp' if $ENV{DEB_BUILD_ARCH}; # FHS system |
44
|
0
|
0
|
0
|
|
|
|
return '/var/tmp/gbrowse2' if -e '/var/tmp' && -w '/var/tmp'; |
45
|
0
|
|
|
|
|
|
return File::Spec->catfile(File::Spec->tmpdir,'gbrowse2'); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub persistent { |
49
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
50
|
0
|
0
|
|
|
|
|
return '/srv/gbrowse2' if $ENV{DEB_BUILD_ARCH}; # FHS system |
51
|
0
|
|
0
|
|
|
|
my $prefix = $self->prefix || '/var'; |
52
|
0
|
|
|
|
|
|
return File::Spec->catfile($prefix,'lib','gbrowse2'); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub databases { |
56
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
57
|
0
|
|
|
|
|
|
return File::Spec->catfile($self->persistent,'databases'); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub apache { |
61
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
62
|
0
|
0
|
|
|
|
|
return -x '/usr/sbin/httpd' ? '/usr/sbin/httpd' |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
63
|
|
|
|
|
|
|
: -x '/usr/sbin/apache2' ? '/usr/sbin/apache2' |
64
|
|
|
|
|
|
|
: -x '/usr/sbin/apache' ? '/usr/sbin/apache' |
65
|
|
|
|
|
|
|
: undef; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub apache_root { |
69
|
0
|
0
|
|
0
|
0
|
|
if ($^O =~ /mswin/i) { # windows system |
70
|
0
|
|
|
|
|
|
for ( |
71
|
|
|
|
|
|
|
'C:/Program Files/Apache Software Foundation/Apache2.5', |
72
|
|
|
|
|
|
|
'C:/Program Files/Apache Software Foundation/Apache2.4', |
73
|
|
|
|
|
|
|
'C:/Program Files/Apache Software Foundation/Apache2.3', |
74
|
|
|
|
|
|
|
'C:/Program Files/Apache Software Foundation/Apache2.2', |
75
|
|
|
|
|
|
|
'C:/Program Files/Apache Software Foundation/Apache2.1', |
76
|
|
|
|
|
|
|
'C:/Program Files/Apache Group/Apache2', |
77
|
|
|
|
|
|
|
'C:/Program Files/Apache Group/Apache', |
78
|
|
|
|
|
|
|
'C:/Apache/conf', |
79
|
|
|
|
|
|
|
'C:/Apache2/conf') { |
80
|
0
|
0
|
|
|
|
|
return $_ if -d $_; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} else { |
83
|
0
|
|
|
|
|
|
for ( |
84
|
|
|
|
|
|
|
'/etc/apache2', |
85
|
|
|
|
|
|
|
'/usr/local/apache2', # standard apache2 install |
86
|
|
|
|
|
|
|
'/usr/local/apache', # standard apache install |
87
|
|
|
|
|
|
|
'/opt/apache2', |
88
|
|
|
|
|
|
|
'/opt/apache', |
89
|
|
|
|
|
|
|
) { |
90
|
0
|
0
|
|
|
|
|
return $_ if -d $_; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} |
93
|
0
|
|
|
|
|
|
return; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub htdocs { |
97
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
98
|
0
|
|
|
|
|
|
local $^W = 0; |
99
|
0
|
0
|
|
|
|
|
return File::Spec->catfile($PREFIX,'htdocs') if $PREFIX; |
100
|
|
|
|
|
|
|
|
101
|
0
|
0
|
|
|
|
|
return '/srv/gbrowse2/htdocs' if $ENV{DEB_BUILD_ARCH}; |
102
|
0
|
|
|
|
|
|
my $root = $self->apache_root; |
103
|
0
|
|
|
|
|
|
foreach ('htdocs','html') { |
104
|
0
|
0
|
|
|
|
|
return File::Spec->catfile($root,$_) |
105
|
|
|
|
|
|
|
if -e File::Spec->catfile($root,$_); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
for ( |
109
|
|
|
|
|
|
|
'/var/www/html', # RedHat linux |
110
|
|
|
|
|
|
|
'/var/www/htdocs', # Slackware linux |
111
|
|
|
|
|
|
|
'/var/www', # Ubuntu/debian |
112
|
|
|
|
|
|
|
'/var/www', # Ubuntu |
113
|
|
|
|
|
|
|
'/Library/Webserver/Documents', # MacOSX |
114
|
|
|
|
|
|
|
) { |
115
|
0
|
0
|
|
|
|
|
return File::Spec->catfile($_,'gbrowse2') if -d $_; |
116
|
|
|
|
|
|
|
} |
117
|
0
|
|
|
|
|
|
return '/usr/local/apache/htdocs'; # fallback |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub cgibin { |
121
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
122
|
0
|
|
|
|
|
|
my $root = $self->apache_root; |
123
|
0
|
|
|
|
|
|
foreach ('cgi-bin','cgi-perl','cgi') { |
124
|
0
|
0
|
|
|
|
|
return File::Spec->catfile($root,$_) |
125
|
|
|
|
|
|
|
if -e File::Spec->catfile($root,$_); |
126
|
|
|
|
|
|
|
} |
127
|
0
|
|
|
|
|
|
for ( |
128
|
|
|
|
|
|
|
'/var/www/cgi-bin', # RedHat & Slackware linux |
129
|
|
|
|
|
|
|
'/usr/lib/cgi-bin', # Ubuntu/debian |
130
|
|
|
|
|
|
|
'/Library/Webserver/CGI-Executables', # MacOSX |
131
|
|
|
|
|
|
|
'/usr/lib/cgi-bin', # Ubuntu |
132
|
|
|
|
|
|
|
) { |
133
|
0
|
0
|
|
|
|
|
return "$_/gb2" if -d $_; |
134
|
|
|
|
|
|
|
} |
135
|
0
|
|
|
|
|
|
return '/usr/local/apache/cgi-bin/gb2'; #fallback |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# try a few ports until we find an open one |
139
|
|
|
|
|
|
|
sub portdemo { |
140
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
141
|
0
|
|
|
|
|
|
my @candidates = (80,8000,8080,8001,8008,8081,8888,8181); |
142
|
0
|
|
|
|
|
|
for my $port (@candidates) { |
143
|
0
|
|
|
|
|
|
my $h = IO::Socket::INET->new(LocalPort=>$port); |
144
|
0
|
0
|
|
|
|
|
return $port if $h; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub wwwuser { |
149
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
150
|
0
|
|
|
|
|
|
for (qw(www-data www httpd apache apache2 System nobody )) { |
151
|
0
|
0
|
|
|
|
|
return $_ if getpwnam($_); |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
# fallback -- user current real user |
154
|
0
|
|
|
|
|
|
return (getpwuid($<))[0]; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub installconf { |
158
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
159
|
0
|
|
|
|
|
|
return 'y'; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub installetc { |
163
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
164
|
0
|
|
|
|
|
|
return 'y'; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub apachemodules { |
168
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
169
|
0
|
|
|
|
|
|
my $root = $self->apache_root; |
170
|
0
|
|
|
|
|
|
foreach ('modules','libexec') { |
171
|
0
|
0
|
|
|
|
|
return File::Spec->catfile($root,$_) |
172
|
|
|
|
|
|
|
if -d File::Spec->catfile($root,$_); |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
0
|
0
|
|
|
|
|
return '/etc/httpd/modules' if -d '/etc/httpd/modules'; |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
178
|
0
|
|
|
|
|
|
for my $first ('/usr/lib','/usr/share', |
179
|
|
|
|
|
|
|
'/usr/local/lib','/usr/local/share') { |
180
|
0
|
|
|
|
|
|
for my $second ('apache','apache2') { |
181
|
0
|
|
|
|
|
|
for my $third ('modules','libexec') { |
182
|
0
|
|
|
|
|
|
my $candidate = File::Spec->catfile($first,$second,$third); |
183
|
0
|
0
|
|
|
|
|
return $candidate if -d $candidate; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
} |
187
|
0
|
|
|
|
|
|
return '/usr/lib/apache/modules'; #fallback |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
# most (all?) distributions have a way to add config file snippets |
191
|
|
|
|
|
|
|
# to httpd.conf without modifying the main file |
192
|
|
|
|
|
|
|
sub apache_includes { |
193
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
194
|
0
|
0
|
|
|
|
|
return '/etc/apache2/other' if -d '/etc/apache2/other'; # why cant macos do things like everybody else? |
195
|
0
|
0
|
|
|
|
|
return '/etc/apache2/conf.d' if -d '/etc/apache2/conf.d'; |
196
|
0
|
0
|
|
|
|
|
return '/etc/apache2/conf-enabled' if -d '/etc/apache2/conf-enabled'; |
197
|
0
|
0
|
|
|
|
|
return '/etc/apache/conf.d' if -d '/etc/apache/conf.d'; |
198
|
0
|
0
|
|
|
|
|
return '/etc/httpd/conf.d' if -d '/etc/httpd/conf.d'; |
199
|
0
|
|
|
|
|
|
return; |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
1; |