@@ -336,10 +336,10 @@ public function configure_postfix($options = '')
336336
337337 //* Creating virtual mail user and group
338338 $ command = 'groupadd -g ' .$ cf ['vmail_groupid ' ].' ' .$ cf ['vmail_groupname ' ];
339- caselog ($ command .' &> /dev/null ' , __FILE__ , __LINE__ , "EXECUTED: $ command " , "Failed to execute the command $ command " );
339+ if (! is_group ( $ cf [ ' vmail_groupname ' ])) caselog ($ command .' &> /dev/null ' , __FILE__ , __LINE__ , "EXECUTED: $ command " , "Failed to execute the command $ command " );
340340
341341 $ command = 'useradd -g ' .$ cf ['vmail_groupname ' ].' -u ' .$ cf ['vmail_userid ' ].' ' .$ cf ['vmail_username ' ].' -d ' .$ cf ['vmail_mailbox_base ' ].' -m ' ;
342- caselog ("$ command &> /dev/null " , __FILE__ , __LINE__ , "EXECUTED: $ command " , "Failed to execute the command $ command " );
342+ if (! is_user ( $ cf [ ' vmail_username ' ])) caselog ("$ command &> /dev/null " , __FILE__ , __LINE__ , "EXECUTED: $ command " , "Failed to execute the command $ command " );
343343
344344 $ postconf_commands = array (
345345 'myhostname = ' .$ conf ['hostname ' ],
@@ -618,7 +618,7 @@ public function configure_getmail()
618618 if (!is_dir ($ config_dir )) exec ("mkdir -p " .escapeshellcmd ($ config_dir ));
619619
620620 $ command = "useradd -d $ config_dir getmail " ;
621- caselog ($ command .' &> /dev/null ' , __FILE__ , __LINE__ , "EXECUTED: $ command " , "Failed to execute the command $ command " );
621+ if (! is_user ( ' getmail ' )) caselog ($ command .' &> /dev/null ' , __FILE__ , __LINE__ , "EXECUTED: $ command " , "Failed to execute the command $ command " );
622622
623623 $ command = "chown -R getmail $ config_dir " ;
624624 caselog ($ command .' &> /dev/null ' , __FILE__ , __LINE__ , "EXECUTED: $ command " , "Failed to execute the command $ command " );
@@ -760,10 +760,10 @@ public function install_ispconfig()
760760
761761 //* Create a ISPConfig user and group
762762 $ command = 'groupadd ispconfig ' ;
763- if (!is_group ('vacp ' )) caselog ($ command .' &> /dev/null 2> /dev/null ' , __FILE__ , __LINE__ , "EXECUTED: $ command " , "Failed to execute the command $ command " );
763+ if (!is_group ('ispconfig ' )) caselog ($ command .' &> /dev/null 2> /dev/null ' , __FILE__ , __LINE__ , "EXECUTED: $ command " , "Failed to execute the command $ command " );
764764
765765 $ command = "useradd -g ispconfig -d $ install_dir ispconfig " ;
766- if (!is_user ('vacp ' )) caselog ($ command .' &> /dev/null 2> /dev/null ' , __FILE__ , __LINE__ , "EXECUTED: $ command " , "Failed to execute the command $ command " );
766+ if (!is_user ('ispconfig ' )) caselog ($ command .' &> /dev/null 2> /dev/null ' , __FILE__ , __LINE__ , "EXECUTED: $ command " , "Failed to execute the command $ command " );
767767
768768 //* copy the ISPConfig interface part
769769 $ command = "cp -rf ../interface $ install_dir " ;
@@ -824,11 +824,17 @@ public function install_ispconfig()
824824 if (is_dir ($ dir )) {
825825 if ($ dh = opendir ($ dir )) {
826826 while (($ file = readdir ($ dh )) !== false ) {
827- if ($ file != '. ' && $ file != '.. ' ) {
828- if (!@is_link ($ install_dir .'/server/mods-enabled/ ' .$ file )) @symlink ($ install_dir .'/server/mods-available/ ' .$ file , $ install_dir .'/server/mods-enabled/ ' .$ file );
829- if (strpos ($ file , '_core_module ' ) !== false ) {
830- if (!@is_link ($ install_dir .'/server/mods-core/ ' .$ file )) @symlink ($ install_dir .'/server/mods-available/ ' .$ file , $ install_dir .'/server/mods-core/ ' .$ file );
827+ if ($ file != '. ' && $ file != '.. ' && substr ($ file ,-8 ,8 ) == '.inc.php ' ) {
828+ include_once ($ install_dir .'/server/mods-available/ ' .$ file );
829+ $ module_name = substr ($ file ,0 ,-8 );
830+ $ tmp = new $ module_name ;
831+ if ($ tmp ->onInstall ()) {
832+ if (!@is_link ($ install_dir .'/server/mods-enabled/ ' .$ file )) @symlink ($ install_dir .'/server/mods-available/ ' .$ file , $ install_dir .'/server/mods-enabled/ ' .$ file );
833+ if (strpos ($ file , '_core_module ' ) !== false ) {
834+ if (!@is_link ($ install_dir .'/server/mods-core/ ' .$ file )) @symlink ($ install_dir .'/server/mods-available/ ' .$ file , $ install_dir .'/server/mods-core/ ' .$ file );
835+ }
831836 }
837+ unset($ tmp );
832838 }
833839 }
834840 closedir ($ dh );
@@ -839,17 +845,39 @@ public function install_ispconfig()
839845 if (is_dir ($ dir )) {
840846 if ($ dh = opendir ($ dir )) {
841847 while (($ file = readdir ($ dh )) !== false ) {
842- if ($ file != '. ' && $ file != '.. ' ) {
843- if (!@is_link ($ install_dir .'/server/plugins-enabled/ ' .$ file )) @symlink ($ install_dir .'/server/plugins-available/ ' .$ file , $ install_dir .'/server/plugins-enabled/ ' .$ file );
844- if (strpos ($ file , '_core_plugin ' ) !== false ) {
845- if (!@is_link ($ install_dir .'/server/plugins-core/ ' .$ file )) @symlink ($ install_dir .'/server/plugins-available/ ' .$ file , $ install_dir .'/server/plugins-core/ ' .$ file );
848+ if ($ file != '. ' && $ file != '.. ' && substr ($ file ,-8 ,8 ) == '.inc.php ' ) {
849+ include_once ($ install_dir .'/server/plugins-available/ ' .$ file );
850+ $ plugin_name = substr ($ file ,0 ,-8 );
851+ $ tmp = new $ plugin_name ;
852+ if ($ tmp ->onInstall ()) {
853+ if (!@is_link ($ install_dir .'/server/plugins-enabled/ ' .$ file )) @symlink ($ install_dir .'/server/plugins-available/ ' .$ file , $ install_dir .'/server/plugins-enabled/ ' .$ file );
854+ if (strpos ($ file , '_core_plugin ' ) !== false ) {
855+ if (!@is_link ($ install_dir .'/server/plugins-core/ ' .$ file )) @symlink ($ install_dir .'/server/plugins-available/ ' .$ file , $ install_dir .'/server/plugins-core/ ' .$ file );
856+ }
846857 }
858+ unset($ tmp );
847859 }
848860 }
849861 closedir ($ dh );
850862 }
851863 }
852864
865+ // Update the server config
866+ $ mail_server_enabled = ($ conf ['services ' ]['mail ' ])?1 :0 ;
867+ $ web_server_enabled = ($ conf ['services ' ]['web ' ])?1 :0 ;
868+ $ dns_server_enabled = ($ conf ['services ' ]['dns ' ])?1 :0 ;
869+ $ file_server_enabled = ($ conf ['services ' ]['file ' ])?1 :0 ;
870+ $ db_server_enabled = ($ conf ['services ' ]['db ' ])?1 :0 ;
871+ $ vserver_server_enabled = ($ conf ['services ' ]['vserver ' ])?1 :0 ;
872+ $ sql = "UPDATE `server` SET mail_server = ' $ mail_server_enabled', web_server = ' $ web_server_enabled', dns_server = ' $ dns_server_enabled', file_server = ' $ file_server_enabled', db_server = ' $ db_server_enabled', vserver_server = ' $ vserver_server_enabled' WHERE server_id = " .intval ($ conf ['server_id ' ]);
873+
874+ if ($ conf ['mysql ' ]['master_slave_setup ' ] == 'y ' ) {
875+ $ this ->dbmaster ->query ($ sql );
876+ } else {
877+ $ this ->db ->query ($ sql );
878+ }
879+
880+
853881 //* Chmod the files
854882 $ command = "chmod -R 750 $ install_dir " ;
855883 caselog ($ command .' &> /dev/null ' , __FILE__ , __LINE__ , "EXECUTED: $ command " , "Failed to execute the command $ command " );
0 commit comments