Mail-Toaster
view release on metacpan or search on metacpan
lib/Mail/Toaster/Setup.pm view on Meta::CPAN
_OPTIONS_READ=lighttpd-1.4.32_1
_FILE_COMPLETE_OPTIONS_LIST=BZIP2 FAM GDBM IPV6 LDAP LIBEV LUA MEMCACHE MYSQL MYSQLAUTH NODELAY OPENSSL REMOTEUSER SPAWNFCGI VALGRIND WEBDAV
OPTIONS_FILE_SET+=BZIP2
OPTIONS_FILE_UNSET+=FAM
OPTIONS_FILE_UNSET+=GDBM
OPTIONS_FILE_UNSET+=IPV6
OPTIONS_FILE_UNSET+=LDAP
OPTIONS_FILE_UNSET+=LIBEV
OPTIONS_FILE_UNSET+=LUA
OPTIONS_FILE_UNSET+=MEMCACHE
OPTIONS_FILE_UNSET+=MYSQL
OPTIONS_FILE_UNSET+=MYSQLAUTH
OPTIONS_FILE_UNSET+=NODELAY
OPTIONS_FILE_SET+=OPENSSL
OPTIONS_FILE_UNSET+=REMOTEUSER
OPTIONS_FILE_SET+=SPAWNFCGI
OPTIONS_FILE_UNSET+=VALGRIND
OPTIONS_FILE_UNSET+=WEBDAV
",
);
$self->freebsd->conf_check(
check => "lighttpd_enable",
line => 'lighttpd_enable="YES"',
);
my @logs = qw/ lighttpd.error.log lighttpd.access.log /;
foreach ( @logs ) {
$self->util->file_write( "/var/log/$_", lines => [' '] )
if ! -e "/var/log/$_";
$self->util->chown("/var/log/$_", uid => 'www', gid => 'www');
};
};
sub lighttpd_config {
my $self = shift;
my $letc = '/usr/local/etc';
$letc = "$letc/lighttpd" if -d "$letc/lighttpd";
my $lconf = "$letc/lighttpd.conf";
`grep toaster $letc/lighttpd.conf`
and return $self->audit("lighttpd configuration already done");
my $cgi_bin = $self->conf->{toaster_cgi_bin} || '/usr/local/www/cgi-bin.toaster/';
my $htdocs = $self->conf->{toaster_http_docs} || '/usr/local/www/toaster';
$self->config->apply_tweaks(
file => "$letc/lighttpd.conf",
changes => [
{ search => q{# "mod_redirect",},
replace => q{ "mod_redirect",},
},
{ search => q{# "mod_alias",},
replace => q{ "mod_alias",},
},
{ search => q{# "mod_auth",},
replace => q{ "mod_auth",},
},
{ search => q{# "mod_setenv",},
replace => q{ "mod_setenv",},
},
{ search => q{# "mod_fastcgi",},
replace => q{ "mod_fastcgi",},
},
{ search => q{# "mod_cgi",},
replace => q{ "mod_cgi",},
},
{ search => q{# "mod_compress",},
replace => q{ "mod_compress",},
},
{ search => q{server.document-root = "/usr/local/www/data/"},
replace => qq{server.document-root = "$htdocs/"},
},
{ search => q{server.document-root = "/usr/local/www/data/"},
replace => qq{server.document-root = "$htdocs/"},
},
{ search => q{var.server_root = "/usr/local/www/data"},
replace => qq{var.server_root = "$htdocs"},
},
{ search => q{#include_shell "cat /usr/local/etc/lighttpd/vhosts.d/*.conf"},
replace => q{include_shell "cat /usr/local/etc/lighttpd/vhosts.d/*.conf"},
},
{ search => q'$SERVER["socket"] == "0.0.0.0:80" { }',
replace => q'#$SERVER["socket"] == "0.0.0.0:80" { }',
},
],
);
$self->config->apply_tweaks(
file => "$letc/modules.conf",
changes => [
{ search => q{# "mod_alias",},
replace => q{ "mod_alias",},
},
{ search => q{# "mod_auth",},
replace => q{ "mod_auth",},
},
{ search => q{# "mod_redirect",},
replace => q{ "mod_redirect",},
},
{ search => q{# "mod_setenv",},
replace => q{ "mod_setenv",},
},
{ search => q{#include "conf.d/cgi.conf"},
replace => q{include "conf.d/cgi.conf"},
},
{ search => q{#include "conf.d/fastcgi.conf"},
replace => q{include "conf.d/fastcgi.conf"},
},
],
);
return 1;
};
sub lighttpd_start {
my $self = shift;
if ( $OSNAME eq 'freebsd' ) {
system "/usr/local/etc/rc.d/lighttpd restart";
return 1;
}
elsif ( $OSNAME eq 'linux' ) {
system "service lighttpd start";
return 1;
};
print "not sure how to start lighttpd on $OSNAME\n";
return;
};
sub lighttpd_vhost {
my $self = shift;
my $letc = '/usr/local/etc';
$letc = "$letc/lighttpd" if -d "$letc/lighttpd";
my $www = '/usr/local/www';
my $cgi_bin = $self->conf->{toaster_cgi_bin} || "$www/cgi-bin.toaster/";
my $htdocs = $self->conf->{toaster_http_docs} || "$www/toaster";
my $vhost = '
alias.url = (
"/sqwebmail/" => "' . $htdocs . '/sqwebmail/",
"/qmailadmin/" => "/usr/local/www/data.default/qmailadmin/",
"/cgi-bin/qmailadmin/" => "/usr/local/www/cgi-bin.default/qmailadmin/"
"/cgi-bin/" => "' . $cgi_bin . '/",
"/squirrelmail/" => "' . $www . '/squirrelmail/",
"/roundcube/" => "' . $www . '/roundcube/",
"/v-webmail/" => "' . $www . '/v-webmail/htdocs/",
"/horde/" => "' . $www . '/horde/",
"/awstatsclasses" => "' . $www . '/awstats/classes/",
"/awstatscss" => "' . $www . '/awstats/css/",
"/awstatsicons" => "' . $www . '/awstats/icons/",
"/awstats/" => "' . $www . '/awstats/cgi-bin/",
"/munin/" => "' . $www . '/munin/",
"/rrdutil/" => "/usr/local/rrdutil/html/",
"/isoqlog/images/"=> "/usr/local/share/isoqlog/htmltemp/images/",
"/phpMyAdmin/" => "' . $www . '/phpMyAdmin/",
)
$HTTP["url"] =~ "^/awstats/" {
cgi.assign = ( "" => "/usr/bin/perl" )
}
$HTTP["url"] =~ "^/cgi-bin" {
cgi.assign = ( "" => "" )
}
$HTTP["url"] =~ "^/ezmlm.cgi" {
cgi.assign = ( "" => "/usr/bin/perl" )
}
# redirect users to a secure connection
$SERVER["socket"] == ":80" {
$HTTP["host"] =~ "(.*)" {
url.redirect = ( "^/(.*)" => "https://%1/$1" )
}
}
$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.pemfile = "/usr/local/openssl/certs/server.pem"
# sqwebmail needs this
setenv.add-environment = ( "HTTPS" => "on" )
}
fastcgi.server = (
".php" =>
( "localhost" =>
(
"socket" => "/tmp/php-fastcgi.socket",
"bin-path" => "/usr/local/bin/php-cgi",
"idle-timeout" => 1200,
"min-procs" => 1,
"max-procs" => 3,
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "2",
"PHP_FCGI_MAX_REQUESTS" => "100"
),
)
)
)
auth.backend = "htdigest"
auth.backend.htdigest.userfile = "/usr/local/etc/WebUsers"
auth.require = ( "/isoqlog" =>
(
"method" => "digest",
"realm" => "Admins Only",
"require" => "valid-user"
),
"/cgi-bin/vqadmin" =>
(
"method" => "digest",
"realm" => "Admins Only",
"require" => "valid-user"
),
"/ezmlm.cgi" =>
(
"method" => "digest",
"realm" => "Admins Only",
"require" => "valid-user"
)
# "/munin" =>
# (
# "method" => "digest",
# "realm" => "Admins Only",
# "require" => "valid-user"
# )
)
';
$self->util->file_write("$letc/vhosts.d/mail-toaster.conf", lines => [ $vhost ],);
return 1;
};
sub logmonster {
my $self = shift;
my $verbose = $self->verbose;
my %p = validate( @_, {
fatal => { type => BOOLEAN, optional => 1, default => 1 },
verbose => { type => BOOLEAN, optional => 1, default => $verbose },
( run in 3.523 seconds using v1.01-cache-2.11-cpan-6aa56a78535 )