Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for updating FPM config on domain rename #344

Merged
merged 3 commits into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions feature-web.pl
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,7 @@ sub modify_web
[ "upload_tmp_dir", $oldd->{'home'}, $d->{'home'}, 1 ],
);
&fix_php_ini_files($d, \@fixes);
&fix_php_fpm_pool_file($d, \@fixes);
}
&release_lock_web($d);
&create_framefwd_file($d);
Expand Down
1 change: 1 addition & 0 deletions lang/en
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,7 @@ save_apache8=Updating frame forwarding ..
save_apache9=Updating website proxying ..
save_apache10=Updating home directory in PHP configuration ..
save_apache11=Updating document directory in website configuration ..
save_apache12=Updating PHP FPM configuration ..
save_dns=Changing IP address in DNS domain ..
save_dns2=Changing DNS domain name ..
save_dns2_provision=Changing DNS domain name on services host ..
Expand Down
53 changes: 53 additions & 0 deletions php-lib.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,59 @@ sub fix_php_ini_files
return $rv;
}

# fix_php_fpm_pool_file(&domain, &fixes)
# Updates values in PHP FPM config file
sub fix_php_fpm_pool_file
{
my ($d, $fixes) = @_;
my ($mode, $rv, $conf, $file);
if (defined(&get_domain_php_mode) &&
($mode = &get_domain_php_mode($d)) &&
$mode eq "fpm" &&
&foreign_check("phpini")) {
&foreign_require("phpini");
$conf = &get_php_fpm_config($d);
if ($conf) {
$file = $conf->{'dir'}."/".$d->{'id'}.".conf";
}
if (-r $file) {
&$first_print($text{'save_apache12'});
&unflush_file_lines($file); # In case cached
undef($phpini::get_config_cache{$file});
my $fpmconf = &phpini::get_config($file);
foreach my $f (@{$fixes}) {
my $ov = &phpini::find_value($f->[0], $fpmconf);
my $nv = $ov;
if (!defined($f->[1])) {
# Always change
$nv = $f->[2];
}
elsif ($f->[3] && $ov =~ /\Q$f->[1]\E/) {
# Regexp change
$nv =~ s/\Q$f->[1]\E/$f->[2]/;
}
elsif (!$f->[3] && $ov eq $f->[1]) {
# Exact match change
$nv = $f->[2];
}
if ($nv ne $ov) {
# Update in file
&phpini::save_directive($fpmconf, $f->[0], $nv);
&flush_file_lines($file);
$rv++;
}
}
if ($rv) {
&$second_print($text{'setup_done'});
}
else {
&$second_print($text{'setup_failed'});
}
}
}
return $rv;
}

# fix_php_extension_dir(&domain)
# If the extension_dir in a domain's php.ini file is invalid, try to fix it
sub fix_php_extension_dir
Expand Down