Skip to content

Commit 392450f

Browse files
committed
- Improved installer and updater for multiserver mode. Modules and plugins were only configured if the selected service is available on the server.
1 parent 164db6a commit 392450f

23 files changed

+415
-95
lines changed

install/dist/lib/fedora.lib.php

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ function configure_postfix($options = '')
7575

7676
//* Creating virtual mail user and group
7777
$command = 'groupadd -g '.$cf['vmail_groupid'].' '.$cf['vmail_groupname'];
78-
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
78+
if(!is_group($cf['vmail_groupname'])) caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
7979

8080
$command = 'useradd -g '.$cf['vmail_groupname'].' -u '.$cf['vmail_userid'].' '.$cf['vmail_username'].' -d '.$cf['vmail_mailbox_base'].' -m';
81-
caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
81+
if(!is_user($cf['vmail_username'])) caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
8282

8383
$postconf_commands = array (
8484
'myhostname = '.$conf['hostname'],
@@ -335,7 +335,7 @@ public function configure_getmail()
335335
if(!is_dir($config_dir)) exec("mkdir -p ".escapeshellcmd($config_dir));
336336

337337
$command = "useradd -d $config_dir getmail";
338-
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
338+
if(!is_user('getmail')) caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
339339

340340
$command = "chown -R getmail $config_dir";
341341
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
@@ -483,10 +483,10 @@ public function install_ispconfig()
483483

484484
//* Create a ISPConfig user and group
485485
$command = 'groupadd ispconfig';
486-
if(!is_group('vacp')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
486+
if(!is_group('ispconfig')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
487487

488488
$command = "useradd -g ispconfig -d $install_dir ispconfig";
489-
if(!is_user('vacp')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
489+
if(!is_user('ispconfig')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
490490

491491
//* copy the ISPConfig interface part
492492
$command = "cp -rf ../interface $install_dir";
@@ -547,11 +547,17 @@ public function install_ispconfig()
547547
if (is_dir($dir)) {
548548
if ($dh = opendir($dir)) {
549549
while (($file = readdir($dh)) !== false) {
550-
if($file != '.' && $file != '..') {
551-
if(!@is_link($install_dir.'/server/mods-enabled/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-enabled/'.$file);
552-
if (strpos($file, '_core_module') !== false) {
553-
if(!@is_link($install_dir.'/server/mods-core/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-core/'.$file);
550+
if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') {
551+
include_once($install_dir.'/server/mods-available/'.$file);
552+
$module_name = substr($file,0,-8);
553+
$tmp = new $module_name;
554+
if($tmp->onInstall()) {
555+
if(!@is_link($install_dir.'/server/mods-enabled/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-enabled/'.$file);
556+
if (strpos($file, '_core_module') !== false) {
557+
if(!@is_link($install_dir.'/server/mods-core/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-core/'.$file);
558+
}
554559
}
560+
unset($tmp);
555561
}
556562
}
557563
closedir($dh);
@@ -562,17 +568,38 @@ public function install_ispconfig()
562568
if (is_dir($dir)) {
563569
if ($dh = opendir($dir)) {
564570
while (($file = readdir($dh)) !== false) {
565-
if($file != '.' && $file != '..') {
566-
if(!@is_link($install_dir.'/server/plugins-enabled/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file);
567-
if (strpos($file, '_core_plugin') !== false) {
568-
if(!@is_link($install_dir.'/server/plugins-core/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-core/'.$file);
571+
if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') {
572+
include_once($install_dir.'/server/plugins-available/'.$file);
573+
$plugin_name = substr($file,0,-8);
574+
$tmp = new $plugin_name;
575+
if($tmp->onInstall()) {
576+
if(!@is_link($install_dir.'/server/plugins-enabled/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file);
577+
if (strpos($file, '_core_plugin') !== false) {
578+
if(!@is_link($install_dir.'/server/plugins-core/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-core/'.$file);
579+
}
569580
}
581+
unset($tmp);
570582
}
571583
}
572584
closedir($dh);
573585
}
574586
}
575587

588+
// Update the server config
589+
$mail_server_enabled = ($conf['services']['mail'])?1:0;
590+
$web_server_enabled = ($conf['services']['web'])?1:0;
591+
$dns_server_enabled = ($conf['services']['dns'])?1:0;
592+
$file_server_enabled = ($conf['services']['file'])?1:0;
593+
$db_server_enabled = ($conf['services']['db'])?1:0;
594+
$vserver_server_enabled = ($conf['services']['vserver'])?1:0;
595+
$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']);
596+
597+
if($conf['mysql']['master_slave_setup'] == 'y') {
598+
$this->dbmaster->query($sql);
599+
} else {
600+
$this->db->query($sql);
601+
}
602+
576603
//* Chmod the files
577604
$command = "chmod -R 750 $install_dir";
578605
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");

install/dist/lib/opensuse.lib.php

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ function configure_postfix($options = '')
7575

7676
//* Creating virtual mail user and group
7777
$command = 'groupadd -g '.$cf['vmail_groupid'].' '.$cf['vmail_groupname'];
78-
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
78+
if(!is_group($cf['vmail_groupname'])) caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
7979

8080
$command = 'useradd -g '.$cf['vmail_groupname'].' -u '.$cf['vmail_userid'].' '.$cf['vmail_username'].' -d '.$cf['vmail_mailbox_base'].' -m';
81-
caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
81+
if(!is_user($cf['vmail_username'])) caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
8282

8383
$postconf_commands = array (
8484
'myhostname = '.$conf['hostname'],
@@ -353,7 +353,7 @@ public function configure_getmail()
353353
if(!is_dir($config_dir)) exec("mkdir -p ".escapeshellcmd($config_dir));
354354

355355
$command = "useradd -d $config_dir getmail";
356-
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
356+
if(!is_user('getmail')) caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
357357

358358
$command = "chown -R getmail $config_dir";
359359
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
@@ -501,10 +501,10 @@ public function install_ispconfig()
501501

502502
//* Create a ISPConfig user and group
503503
$command = 'groupadd ispconfig';
504-
if(!is_group('vacp')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
504+
if(!is_group('ispconfig')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
505505

506506
$command = "useradd -g ispconfig -d $install_dir ispconfig";
507-
if(!is_user('vacp')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
507+
if(!is_user('ispconfig')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
508508

509509
//* copy the ISPConfig interface part
510510
$command = "cp -rf ../interface $install_dir";
@@ -565,11 +565,17 @@ public function install_ispconfig()
565565
if (is_dir($dir)) {
566566
if ($dh = opendir($dir)) {
567567
while (($file = readdir($dh)) !== false) {
568-
if($file != '.' && $file != '..') {
569-
if(!@is_link($install_dir.'/server/mods-enabled/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-enabled/'.$file);
570-
if (strpos($file, '_core_module') !== false) {
571-
if(!@is_link($install_dir.'/server/mods-core/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-core/'.$file);
568+
if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') {
569+
include_once($install_dir.'/server/mods-available/'.$file);
570+
$module_name = substr($file,0,-8);
571+
$tmp = new $module_name;
572+
if($tmp->onInstall()) {
573+
if(!@is_link($install_dir.'/server/mods-enabled/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-enabled/'.$file);
574+
if (strpos($file, '_core_module') !== false) {
575+
if(!@is_link($install_dir.'/server/mods-core/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-core/'.$file);
576+
}
572577
}
578+
unset($tmp);
573579
}
574580
}
575581
closedir($dh);
@@ -580,17 +586,38 @@ public function install_ispconfig()
580586
if (is_dir($dir)) {
581587
if ($dh = opendir($dir)) {
582588
while (($file = readdir($dh)) !== false) {
583-
if($file != '.' && $file != '..') {
584-
if(!@is_link($install_dir.'/server/plugins-enabled/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file);
585-
if (strpos($file, '_core_plugin') !== false) {
586-
if(!@is_link($install_dir.'/server/plugins-core/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-core/'.$file);
589+
if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') {
590+
include_once($install_dir.'/server/plugins-available/'.$file);
591+
$plugin_name = substr($file,0,-8);
592+
$tmp = new $plugin_name;
593+
if($tmp->onInstall()) {
594+
if(!@is_link($install_dir.'/server/plugins-enabled/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file);
595+
if (strpos($file, '_core_plugin') !== false) {
596+
if(!@is_link($install_dir.'/server/plugins-core/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-core/'.$file);
597+
}
587598
}
599+
unset($tmp);
588600
}
589601
}
590602
closedir($dh);
591603
}
592604
}
593605

606+
// Update the server config
607+
$mail_server_enabled = ($conf['services']['mail'])?1:0;
608+
$web_server_enabled = ($conf['services']['web'])?1:0;
609+
$dns_server_enabled = ($conf['services']['dns'])?1:0;
610+
$file_server_enabled = ($conf['services']['file'])?1:0;
611+
$db_server_enabled = ($conf['services']['db'])?1:0;
612+
$vserver_server_enabled = ($conf['services']['vserver'])?1:0;
613+
$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']);
614+
615+
if($conf['mysql']['master_slave_setup'] == 'y') {
616+
$this->dbmaster->query($sql);
617+
} else {
618+
$this->db->query($sql);
619+
}
620+
594621
//* Chmod the files
595622
$command = "chmod -R 750 $install_dir";
596623
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");

install/lib/installer_base.lib.php

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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");

install/uninstall.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
exec("/etc/init.d/mysql start");
6161

6262
// Deleting the symlink in /var/www
63-
unlink("/etc/apache2/sites-enabled/ispconfig.vhost");
63+
unlink("/etc/apache2/sites-enabled/000-ispconfig.vhost");
6464
unlink("/etc/apache2/sites-available/ispconfig.vhost");
6565

6666
// Delete the ispconfig files

0 commit comments

Comments
 (0)