config is in dwww 1.13.4.
This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | #!/usr/bin/perl -w
# vim:ft=perl:cindent:ts=4:sts=4:et:sw
# config for dwww
use Debconf::Client::ConfModule qw(:all);
use strict;
version('2.0');
capb('backup');
my $cfgfile = '/etc/dwww/dwww.conf';
my %dwwwcfg;
# Create directories we need, see bug #188267
&mkdir_p("/usr/lib/cgi-bin");
&mkdir_p("/var/www");
if ( -r $cfgfile )
{
&ScanDwwwConfFile ( $cfgfile );
foreach my $cfgvar (('docrootdir', 'cgidir', 'cgiuser', 'serverport', 'servername'))
{
my $val = $dwwwcfg{'DWWW_' . uc($cfgvar)};
if ($val)
{
set("dwww/$cfgvar", $val);
fset("dwww/$cfgvar", 'seen', 'true');
}
}
}
if (not defined $dwwwcfg{'DWWW_SERVERNAME'})
{
my $host=`hostname --fqdn`;
chomp($host);
set('dwww/servername', $host) if $host =~ /\w/;
}
my $state = 1;
while ($state > 0 && $state < 4)
{
my @ret;
if ($state == 1)
{
beginblock();
input('medium', 'dwww/docrootdir');
input('medium', 'dwww/cgidir');
input('medium', 'dwww/cgiuser');
endblock();
@ret = go();
# error handling
my $dir = scalar get('dwww/docrootdir');
while ( ($ret[0] == 0) and
not (($dir =~ m|^/|) and (-d $dir))
)
{
subst('dwww/nosuchdir', 'dir', $dir);
fset('dwww/nosuchdir', 'seen', 'false');
fset('dwww/docrootdir', 'seen', 'false');
set('dwww/docrootdir', '/var/www');
beginblock();
input('high', 'dwww/nosuchdir');
input('high', 'dwww/docrootdir');
endblock();
@ret = go();
$dir = scalar get('dwww/docrootdir');
}
set('dwww/docrootdir', canondir($dir));
$dir = scalar get('dwww/cgidir');
while ( ($ret[0] == 0) and
not (($dir =~ m|^/|) and (-d $dir))
)
{
subst('dwww/nosuchdir', 'dir', $dir);
fset('dwww/nosuchdir', 'seen', 'false');
fset('dwww/cgidir', 'seen', 'false');
set('dwww/cgidir', '/usr/lib/cgi-bin');
beginblock();
input('high', 'dwww/nosuchdir');
input('high', 'dwww/cgidir');
endblock();
@ret = go();
$dir = scalar get('dwww/cgidir');
}
set('dwww/cgidir', canondir($dir));
my $usr = scalar get('dwww/cgiuser');
while ( ($ret[0] == 0) and
not (($usr =~ m/^\s*\d+\s*$/) or (defined getpwnam($usr)))
)
{
subst('dwww/nosuchuser', 'user', $usr);
fset('dwww/nosuchuser', 'seen', 'false');
fset('dwww/cgiuser', 'seen', 'false');
set('dwww/cgiuser', 'www-data');
beginblock();
input('high', 'dwww/nosuchuser');
input('high', 'dwww/cgiuser');
endblock();
@ret = go();
$usr = scalar get('dwww/cgiuser');
}
}
elsif ($state == 2)
{
beginblock();
input('medium', 'dwww/servername');
input('medium', 'dwww/serverport');
endblock();
@ret = go();
my $port = scalar get('dwww/serverport');
while ( ($ret[0] == 0) and ($port !~ /^\s*\d+\s*$/))
{
subst('dwww/badport', 'port', $port);
fset('dwww/badport', 'seen', 'false');
fset('dwww/serverport', 'seen', 'false');
set('dwww/serverport', '80');
beginblock();
input('high', 'dwww/badport');
input('high', 'dwww/serverport');
endblock();
@ret = go();
$port = scalar get('dwww/serverport');
}
$port =~ s/\s+//g;
set('dwww/serverport', $port);
}
elsif ($state == 3) {
if (-x '/usr/bin/index++'
and not -s '/var/cache/dwww/dwww.swish++.index') {
beginblock();
input('low', 'dwww/index_docs');
endblock();
@ret = go();
}
}
if ( @ret and $ret[0] == 30 ) {
$state--; # go back
}
else {
$state++; # go forward
}
}
# SUBROUTINES
# Subroutine to Scan Dwww configuration file
# Configfile to parse is the argument to the subroutine
sub ScanDwwwConfFile($)
{
my $filename = shift;
$dwwwcfg{'DWWW_SERVERPORT'} = 80;
if ($filename && -r $filename)
{
open DWWWCONF, "<", $filename or die "Can't open $filename: $!\n";
while (<DWWWCONF>) {
chomp();
# Note: the same regexp is used in Debian::Dwww:ConfigFile.
next if /^\s*#/;
if (m/^\s*([^=]+)\s*=\s*['"]?([^'"\s]+)['"]?\s*$/) {
$dwwwcfg{$1} = $2
}
}
close DWWWCONF or die "Can't close $filename: $!\n";
}
}
sub canondir
{
my $dir = $_[0];
$dir =~ s|/+|/|g;
$dir =~ s|/$||;
return $dir;
}
# Check if $a exists in @_
sub exists_in
{
my $a = lc (shift);
foreach $b (@_)
{
return 1 if ($a cmp (lc $b)) == 0;
}
return 0;
}
# Same as `mkdir -p'
sub mkdir_p
{
my $dir = shift;
return if (-d $dir);
my $p = "";
foreach my $f (split "/", $dir)
{
$p .= $f . "/";
(-d $p) or (mkdir $p, 0755) or die "Can't create directory $p: $!\n";
}
}
|