Skip to content

Commit 91324a0

Browse files
committed
Updated Gentoo install library.
1 parent 1bd2693 commit 91324a0

File tree

1 file changed

+178
-69
lines changed

1 file changed

+178
-69
lines changed

install/dist/lib/gentoo.lib.php

Lines changed: 178 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ public function configure_apache()
455455
{
456456
global $conf;
457457

458+
if($conf['apache']['installed'] == false) return;
458459
//* Create the logging directory for the vhost logfiles
459460
if (!is_dir($conf['ispconfig_log_dir'].'/httpd')) {
460461
mkdir($conf['ispconfig_log_dir'].'/httpd', 0755, true);
@@ -553,60 +554,120 @@ public function configure_apps_vhost()
553554
global $conf;
554555

555556
//* Create the ispconfig apps vhost user and group
557+
if($conf['apache']['installed'] == true){
558+
$apps_vhost_user = escapeshellcmd($conf['web']['apps_vhost_user']);
559+
$apps_vhost_group = escapeshellcmd($conf['web']['apps_vhost_group']);
560+
$install_dir = escapeshellcmd($conf['web']['website_basedir'].'/apps');
561+
562+
$command = 'groupadd '.$apps_vhost_user;
563+
if ( !is_group($apps_vhost_group) ) {
564+
caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
565+
}
556566

557-
$apps_vhost_user = escapeshellcmd($conf['web']['apps_vhost_user']);
558-
$apps_vhost_group = escapeshellcmd($conf['web']['apps_vhost_group']);
559-
$install_dir = escapeshellcmd($conf['web']['website_basedir'].'/apps');
560-
561-
$command = 'groupadd '.$apps_vhost_user;
562-
if ( !is_group($apps_vhost_group) ) {
563-
caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
564-
}
565-
566-
$command = "useradd -g '$apps_vhost_group' -d $install_dir $apps_vhost_group";
567-
if ( !is_user($apps_vhost_user) ) {
568-
caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
569-
}
567+
$command = "useradd -g '$apps_vhost_group' -d $install_dir $apps_vhost_group";
568+
if ( !is_user($apps_vhost_user) ) {
569+
caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
570+
}
570571

571-
$command = 'adduser '.$conf['apache']['user'].' '.$apps_vhost_group;
572-
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
572+
$command = 'adduser '.$conf['apache']['user'].' '.$apps_vhost_group;
573+
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
573574

574-
if (!@is_dir($install_dir)) {
575-
mkdir($install_dir, 0755, true);
576-
}
577-
chown($install_dir, $apps_vhost_user);
578-
chgrp($install_dir, $apps_vhost_group);
575+
if (!@is_dir($install_dir)) {
576+
mkdir($install_dir, 0755, true);
577+
}
578+
chown($install_dir, $apps_vhost_user);
579+
chgrp($install_dir, $apps_vhost_group);
579580

580-
//* Copy the apps vhost file
581-
$vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
582-
$vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
583-
$apps_vhost_servername = ($conf['web']['apps_vhost_servername'] == '') ? '' : 'ServerName '.$conf['web']['apps_vhost_servername'];
581+
//* Copy the apps vhost file
582+
$vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
583+
$vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
584+
$apps_vhost_servername = ($conf['web']['apps_vhost_servername'] == '') ? '' : 'ServerName '.$conf['web']['apps_vhost_servername'];
584585

585-
//* Dont just copy over the virtualhost template but add some custom settings
586-
$content = $this->get_template_file('apache_apps.vhost', true);
586+
//* Dont just copy over the virtualhost template but add some custom settings
587+
$content = $this->get_template_file('apache_apps.vhost', true);
587588

588-
$content = str_replace('{apps_vhost_ip}', $conf['web']['apps_vhost_ip'], $content);
589-
$content = str_replace('{apps_vhost_port}', $conf['web']['apps_vhost_port'], $content);
590-
$content = str_replace('{apps_vhost_dir}', $conf['web']['website_basedir'].'/apps', $content);
591-
$content = str_replace('{website_basedir}', $conf['web']['website_basedir'], $content);
592-
$content = str_replace('{apps_vhost_servername}', $apps_vhost_servername, $content);
593-
594-
//* comment out the listen directive if port is 80 or 443
595-
if($conf['web']['apps_vhost_ip'] == 80 or $conf['web']['apps_vhost_ip'] == 443) {
596-
$content = str_replace('{vhost_port_listen}', '#', $content);
597-
} else {
598-
$content = str_replace('{vhost_port_listen}', '', $content);
599-
}
589+
$content = str_replace('{apps_vhost_ip}', $conf['web']['apps_vhost_ip'], $content);
590+
$content = str_replace('{apps_vhost_port}', $conf['web']['apps_vhost_port'], $content);
591+
$content = str_replace('{apps_vhost_dir}', $conf['web']['website_basedir'].'/apps', $content);
592+
$content = str_replace('{website_basedir}', $conf['web']['website_basedir'], $content);
593+
$content = str_replace('{apps_vhost_servername}', $apps_vhost_servername, $content);
594+
595+
//* comment out the listen directive if port is 80 or 443
596+
if($conf['web']['apps_vhost_ip'] == 80 or $conf['web']['apps_vhost_ip'] == 443) {
597+
$content = str_replace('{vhost_port_listen}', '#', $content);
598+
} else {
599+
$content = str_replace('{vhost_port_listen}', '', $content);
600+
}
600601

601-
$this->write_config_file("$vhost_conf_dir/apps.vhost", $content);
602+
$this->write_config_file("$vhost_conf_dir/apps.vhost", $content);
602603

603-
if ( !is_file($conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter') )
604-
{
605-
mkdir($conf['web']['website_basedir'].'/php-fcgi-scripts/apps', 0755, true);
606-
copy('tpl/apache_apps_fcgi_starter.master',$conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter');
607-
exec('chmod +x '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter');
608-
exec('chown -R ispapps:ispapps '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps');
604+
if ( !is_file($conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter') )
605+
{
606+
mkdir($conf['web']['website_basedir'].'/php-fcgi-scripts/apps', 0755, true);
607+
copy('tpl/apache_apps_fcgi_starter.master',$conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter');
608+
exec('chmod +x '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter');
609+
exec('chown -R ispapps:ispapps '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps');
610+
611+
}
612+
}
613+
if($conf['nginx']['installed'] == true){
614+
$apps_vhost_user = escapeshellcmd($conf['web']['apps_vhost_user']);
615+
$apps_vhost_group = escapeshellcmd($conf['web']['apps_vhost_group']);
616+
$install_dir = escapeshellcmd($conf['web']['website_basedir'].'/apps');
617+
618+
$command = 'groupadd '.$apps_vhost_user;
619+
if(!is_group($apps_vhost_group)) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
620+
621+
$command = 'useradd -g '.$apps_vhost_group.' -d '.$install_dir.' '.$apps_vhost_group;
622+
if(!is_user($apps_vhost_user)) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
623+
624+
625+
$command = 'adduser '.$conf['nginx']['user'].' '.$apps_vhost_group;
626+
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
627+
628+
if(!@is_dir($install_dir)) mkdir($install_dir, 0755, true);
629+
chown($install_dir, $apps_vhost_user);
630+
chgrp($install_dir, $apps_vhost_group);
631+
632+
//* Copy the apps vhost file
633+
$vhost_conf_dir = $conf['nginx']['vhost_conf_dir'];
634+
$vhost_conf_enabled_dir = $conf['nginx']['vhost_conf_enabled_dir'];
635+
$apps_vhost_servername = ($conf['web']['apps_vhost_servername'] == '')?'_':$conf['web']['apps_vhost_servername'];
636+
637+
// Dont just copy over the virtualhost template but add some custom settings
638+
$content = rf('tpl/nginx_apps.vhost.master');
609639

640+
if($conf['web']['apps_vhost_ip'] == '_default_'){
641+
$apps_vhost_ip = '';
642+
} else {
643+
$apps_vhost_ip = $conf['web']['apps_vhost_ip'].':';
644+
}
645+
646+
$content = str_replace('{apps_vhost_ip}', $apps_vhost_ip, $content);
647+
$content = str_replace('{apps_vhost_port}', $conf['web']['apps_vhost_port'], $content);
648+
$content = str_replace('{apps_vhost_dir}', $conf['web']['website_basedir'].'/apps', $content);
649+
$content = str_replace('{apps_vhost_servername}', $apps_vhost_servername, $content);
650+
$content = str_replace('{fpm_port}', ($conf['nginx']['php_fpm_start_port']+1), $content);
651+
652+
wf($vhost_conf_dir.'/apps.vhost', $content);
653+
654+
// PHP-FPM
655+
// Dont just copy over the php-fpm pool template but add some custom settings
656+
$content = rf('tpl/php_fpm_pool.conf.master');
657+
$content = str_replace('{fpm_pool}', 'apps', $content);
658+
$content = str_replace('{fpm_port}', ($conf['nginx']['php_fpm_start_port']+1), $content);
659+
$content = str_replace('{fpm_user}', $apps_vhost_user, $content);
660+
$content = str_replace('{fpm_group}', $apps_vhost_group, $content);
661+
wf($conf['nginx']['php_fpm_pool_dir'].'/apps.conf', $content);
662+
663+
//copy('tpl/nginx_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
664+
//* and create the symlink
665+
if($this->install_ispconfig_interface == true) {
666+
if(@is_link($vhost_conf_enabled_dir.'/apps.vhost')) unlink($vhost_conf_enabled_dir.'/apps.vhost');
667+
if(!@is_link($vhost_conf_enabled_dir.'/000-apps.vhost')) {
668+
symlink($vhost_conf_dir.'/apps.vhost',$vhost_conf_enabled_dir.'/000-apps.vhost');
669+
}
670+
}
610671
}
611672
}
612673

@@ -703,6 +764,8 @@ public function install_ispconfig()
703764
if (is_dir($dir)) {
704765
if ($dh = opendir($dir)) {
705766
while (($file = readdir($dh)) !== false) {
767+
if($conf['apache']['installed'] == true && $file == 'nginx_plugin.inc.php') continue;
768+
if($conf['nginx']['installed'] == true && $file == 'apache2_plugin.inc.php') continue;
706769
if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') {
707770
include_once($install_dir.'/server/plugins-available/'.$file);
708771
$plugin_name = substr($file,0,-8);
@@ -798,34 +861,80 @@ public function install_ispconfig()
798861
$command = "chmod +x $install_dir/server/scripts/*.sh";
799862
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
800863

801-
//* Copy the ISPConfig vhost for the controlpanel
802-
$content = $this->get_template_file("apache_ispconfig.vhost", true);
803-
$content = str_replace('{vhost_port}', $conf['apache']['vhost_port'], $content);
864+
if($conf['apache']['installed'] == true){
865+
//* Copy the ISPConfig vhost for the controlpanel
866+
$content = $this->get_template_file("apache_ispconfig.vhost", true);
867+
$content = str_replace('{vhost_port}', $conf['apache']['vhost_port'], $content);
804868

805-
//* comment out the listen directive if port is 80 or 443
806-
if ($conf['apache']['vhost_port'] == 80 or $conf['apache']['vhost_port'] == 443) {
807-
$content = str_replace('{vhost_port_listen}', '#', $content);
808-
} else {
809-
$content = str_replace('{vhost_port_listen}', '', $content);
810-
}
869+
//* comment out the listen directive if port is 80 or 443
870+
if ($conf['apache']['vhost_port'] == 80 or $conf['apache']['vhost_port'] == 443) {
871+
$content = str_replace('{vhost_port_listen}', '#', $content);
872+
} else {
873+
$content = str_replace('{vhost_port_listen}', '', $content);
874+
}
811875

812-
if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) {
813-
$content = str_replace('{ssl_comment}', '', $content);
814-
} else {
815-
$content = str_replace('{ssl_comment}', '#', $content);
816-
}
876+
if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) {
877+
$content = str_replace('{ssl_comment}', '', $content);
878+
} else {
879+
$content = str_replace('{ssl_comment}', '#', $content);
880+
}
817881

818-
$vhost_path = $conf['apache']['vhost_conf_dir'].'/ispconfig.vhost';
819-
$this->write_config_file($vhost_path, $content);
882+
$vhost_path = $conf['apache']['vhost_conf_dir'].'/ispconfig.vhost';
883+
$this->write_config_file($vhost_path, $content);
820884

821-
if (!is_file('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter'))
822-
{
823-
mkdir('/var/www/php-fcgi-scripts/ispconfig', 0755, true);
824-
copy('tpl/apache_ispconfig_fcgi_starter.master', '/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter');
825-
exec('chmod +x /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter');
826-
chmod('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter', 0755);
827-
symlink($install_dir.'/interface/web', '/var/www/ispconfig');
828-
exec('chown -R ispconfig:ispconfig /var/www/php-fcgi-scripts/ispconfig');
885+
if (!is_file('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter'))
886+
{
887+
mkdir('/var/www/php-fcgi-scripts/ispconfig', 0755, true);
888+
copy('tpl/apache_ispconfig_fcgi_starter.master', '/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter');
889+
exec('chmod +x /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter');
890+
chmod('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter', 0755);
891+
symlink($install_dir.'/interface/web', '/var/www/ispconfig');
892+
exec('chown -R ispconfig:ispconfig /var/www/php-fcgi-scripts/ispconfig');
893+
}
894+
}
895+
896+
if($conf['nginx']['installed'] == true){
897+
//* Copy the ISPConfig vhost for the controlpanel
898+
$vhost_conf_dir = $conf['nginx']['vhost_conf_dir'];
899+
$vhost_conf_enabled_dir = $conf['nginx']['vhost_conf_enabled_dir'];
900+
901+
// Dont just copy over the virtualhost template but add some custom settings
902+
$content = rf('tpl/nginx_ispconfig.vhost.master');
903+
$content = str_replace('{vhost_port}', $conf['nginx']['vhost_port'], $content);
904+
905+
if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) {
906+
$content = str_replace('{ssl_on}', ' ssl', $content);
907+
$content = str_replace('{ssl_comment}', '', $content);
908+
$content = str_replace('{fastcgi_ssl}', 'on', $content);
909+
} else {
910+
$content = str_replace('{ssl_on}', '', $content);
911+
$content = str_replace('{ssl_comment}', '#', $content);
912+
$content = str_replace('{fastcgi_ssl}', 'off', $content);
913+
}
914+
915+
$content = str_replace('{fpm_port}', $conf['nginx']['php_fpm_start_port'], $content);
916+
917+
wf($vhost_conf_dir.'/ispconfig.vhost', $content);
918+
919+
unset($content);
920+
921+
// PHP-FPM
922+
// Dont just copy over the php-fpm pool template but add some custom settings
923+
$content = rf('tpl/php_fpm_pool.conf.master');
924+
$content = str_replace('{fpm_pool}', 'ispconfig', $content);
925+
$content = str_replace('{fpm_port}', $conf['nginx']['php_fpm_start_port'], $content);
926+
$content = str_replace('{fpm_user}', 'ispconfig', $content);
927+
$content = str_replace('{fpm_group}', 'ispconfig', $content);
928+
wf($conf['nginx']['php_fpm_pool_dir'].'/ispconfig.conf', $content);
929+
930+
//copy('tpl/nginx_ispconfig.vhost.master', $vhost_conf_dir.'/ispconfig.vhost');
931+
//* and create the symlink
932+
if($this->install_ispconfig_interface == true && $this->is_update == false) {
933+
if(@is_link($vhost_conf_enabled_dir.'/ispconfig.vhost')) unlink($vhost_conf_enabled_dir.'/ispconfig.vhost');
934+
if(!@is_link($vhost_conf_enabled_dir.'/000-ispconfig.vhost')) {
935+
symlink($vhost_conf_dir.'/ispconfig.vhost',$vhost_conf_enabled_dir.'/000-ispconfig.vhost');
936+
}
937+
}
829938
}
830939

831940
//* Install the update script

0 commit comments

Comments
 (0)