mirror of
https://github.com/webmin/webmin.git
synced 2025-07-20 16:48:46 +00:00
Factor out code to create the site file, and add a function to force a re-gen
This commit is contained in:
@ -26,20 +26,34 @@ $last_restart_time_flag = $module_var_directory."/restart-flag";
|
||||
# if the Apache binary changes, when Webmin is upgraded, or once every five
|
||||
# minutes if automatic rebuilding is enabled.
|
||||
if ($module_name ne 'htaccess') {
|
||||
local %oldsite;
|
||||
local $httpd = &find_httpd();
|
||||
local @st = stat($httpd);
|
||||
&read_file($site_file, \%oldsite);
|
||||
local @sst = stat($site_file);
|
||||
if ($oldsite{'path'} ne $httpd ||
|
||||
&create_site_file();
|
||||
}
|
||||
&read_site_file();
|
||||
|
||||
$apache_docbase = $config{'apache_docbase'} ? $config{'apache_docbase'} :
|
||||
$httpd_modules{'core'} >= 2.0 ?
|
||||
"http://httpd.apache.org/docs-2.0/mod/" :
|
||||
"http://httpd.apache.org/docs/mod/";
|
||||
|
||||
# create_site_file()
|
||||
# If the Apache binary or Webmin version has changed, create the site
|
||||
# file containing all known Apache modules
|
||||
sub create_site_file
|
||||
{
|
||||
my %oldsite;
|
||||
my $httpd = &find_httpd();
|
||||
my @st = stat($httpd);
|
||||
&read_file($site_file, \%oldsite);
|
||||
my @sst = stat($site_file);
|
||||
if ($oldsite{'path'} ne $httpd ||
|
||||
$oldsite{'size'} != $st[7] ||
|
||||
$oldsite{'webmin'} != &get_webmin_version() ||
|
||||
$config{'auto_mods'} && $sst[9] < time()-5*60) {
|
||||
# Need to build list of supported modules
|
||||
local ($ver, $mods, $fullver) = &httpd_info($httpd);
|
||||
my ($ver, $mods, $fullver) = &httpd_info($httpd);
|
||||
if ($ver) {
|
||||
my @allmods = &available_modules();
|
||||
local @mods = map { "$_/$ver" }
|
||||
my @mods = map { "$_/$ver" }
|
||||
&configurable_modules(\@allmods);
|
||||
foreach my $m (@mods) {
|
||||
if ($m =~ /(\S+)\/(\S+)/) {
|
||||
@ -53,7 +67,7 @@ if ($module_name ne 'htaccess') {
|
||||
@allmods = &available_modules();
|
||||
@mods = map { "$_/$ver" }
|
||||
&configurable_modules(\@allmods);
|
||||
local %site = ( 'size' => $st[7],
|
||||
my %site = ( 'size' => $st[7],
|
||||
'path' => $httpd,
|
||||
'modules' => join(' ', @mods),
|
||||
'allmodules' => join(' ', @allmods),
|
||||
@ -66,41 +80,39 @@ if ($module_name ne 'htaccess') {
|
||||
&unlock_file($site_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# read_site_file()
|
||||
# Read the site-specific setup file, then require in all the module-specific
|
||||
# .pl files
|
||||
sub read_site_file
|
||||
{
|
||||
if (&read_file($site_file, \%site)) {
|
||||
local($m, $f, $d);
|
||||
$httpd_size = $site{'size'};
|
||||
foreach $m (split(/\s+/, $site{'modules'})) {
|
||||
foreach my $m (split(/\s+/, $site{'modules'})) {
|
||||
if ($m =~ /(\S+)\/(\S+)/) {
|
||||
$httpd_modules{$1} = $2;
|
||||
}
|
||||
}
|
||||
foreach $m (split(/\s+/, $site{'allmodules'})) {
|
||||
foreach my $m (split(/\s+/, $site{'allmodules'})) {
|
||||
$all_httpd_modules{$m} = $site{'version'};
|
||||
}
|
||||
foreach $m (keys %httpd_modules) {
|
||||
foreach my $m (keys %httpd_modules) {
|
||||
if (!-r "$module_root_directory/$m.pl") {
|
||||
delete($httpd_modules{$m});
|
||||
}
|
||||
}
|
||||
foreach $f (split(/\s+/, $site{'htaccess'})) {
|
||||
foreach my $f (split(/\s+/, $site{'htaccess'})) {
|
||||
if (-r $f) { push(@htaccess_files, $f); }
|
||||
}
|
||||
foreach $m (keys %httpd_modules) {
|
||||
foreach my $m (keys %httpd_modules) {
|
||||
do "$m.pl";
|
||||
}
|
||||
foreach $d (split(/\s+/, $site{'defines'})) {
|
||||
foreach my $d (split(/\s+/, $site{'defines'})) {
|
||||
$httpd_defines{$d}++;
|
||||
}
|
||||
}
|
||||
|
||||
$apache_docbase = $config{'apache_docbase'} ? $config{'apache_docbase'} :
|
||||
$httpd_modules{'core'} >= 2.0 ?
|
||||
"http://httpd.apache.org/docs-2.0/mod/" :
|
||||
"http://httpd.apache.org/docs/mod/";
|
||||
}
|
||||
|
||||
# parse_config_file(handle, lines, file, [recursive])
|
||||
# Parses lines of text from some config file into a data structure. The
|
||||
@ -2274,5 +2286,15 @@ sub format_config_allowed
|
||||
return $config{'format_config'};
|
||||
}
|
||||
|
||||
# clear_apache_modules_cache()
|
||||
# If new Apache modules were enabled, force re-gen of the site file
|
||||
# that contains the modules cache
|
||||
sub clear_apache_modules_cache
|
||||
{
|
||||
&unlink_file($site_file);
|
||||
&create_site_file();
|
||||
&read_site_file();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
@ -23,7 +23,7 @@ foreach $m (@mods) {
|
||||
}
|
||||
|
||||
# Force re-detection of modules
|
||||
unlink($site_file);
|
||||
&clear_apache_modules_cache();
|
||||
|
||||
# Force restart Apache
|
||||
if ($changed && &is_apache_running()) {
|
||||
|
Reference in New Issue
Block a user