From d9ff2568e82070c56c3b45a03689112d87a7da87 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Fri, 8 Mar 2024 17:39:54 +0200 Subject: [PATCH] Fix to use split and join when reading config values --- postinstall.pl | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/postinstall.pl b/postinstall.pl index 0a6b32d..c3a2bfa 100755 --- a/postinstall.pl +++ b/postinstall.pl @@ -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); } }