Skip to content

Commit

Permalink
Fix to use split and join when reading config values
Browse files Browse the repository at this point in the history
  • Loading branch information
iliajie committed Mar 8, 2024
1 parent 16c5b02 commit d9ff256
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions postinstall.pl
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
sub module_install
{
# Enable virtualmin-htpasswd module once
if (&indexof('virtualmin-nginx', @virtual_server::plugins) >= 0) {
if ($virtual_server::config{'plugins'} !~ /$module_name/ &&
$virtual_server::config{'plugins_postinstall_enabled'} !~ /$module_name/) {
&virtual_server::lock_file($virtual_server::module_config_file);
$virtual_server::config{'plugins'} .= " $module_name";
$virtual_server::config{'plugins'} =~ s/^\s+|\s+$//g;
$virtual_server::config{'plugins_postinstall_enabled'} .= " $module_name";
$virtual_server::config{'plugins_postinstall_enabled'} =~ s/^\s+|\s+$//g;
&virtual_server::save_module_config(\%virtual_server::config, 'virtual-server');
&virtual_server::unlock_file($virtual_server::module_config_file);
}
my @p = split(/\s+/, $virtual_server::config{'plugins'});
my @ppe = split(/\s+/, $virtual_server::config{'plugins_postinstall_enabled'});
if (&indexof('virtualmin-nginx', @virtual_server::plugins) > -1 &&
&indexof($module_name, @p) == -1 &&
&indexof($module_name, @ppe) == -1) {
&virtual_server::lock_file($virtual_server::module_config_file);
push(@p, $module_name);
push(@ppe, $module_name);
$virtual_server::config{'plugins'} = join(" ", @p);
$virtual_server::config{'plugins_postinstall_enabled'} = join(" ", @ppe);
&virtual_server::save_module_config(\%virtual_server::config, 'virtual-server');
&virtual_server::unlock_file($virtual_server::module_config_file);
}
}

0 comments on commit d9ff256

Please sign in to comment.