From e1ceb050e19c7574bca146a8da7047ee4ff456b5 Mon Sep 17 00:00:00 2001 From: Marius Burkard <m.burkard@pixcept.de> Date: Sun, 10 Jul 2016 05:02:35 -0400 Subject: [PATCH] Merge branch 'stable-3.1' --- server/plugins-available/apps_vhost_plugin.inc.php | 53 +++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 41 insertions(+), 12 deletions(-) diff --git a/server/plugins-available/apps_vhost_plugin.inc.php b/server/plugins-available/apps_vhost_plugin.inc.php index 8251863..d5d5dc8 100644 --- a/server/plugins-available/apps_vhost_plugin.inc.php +++ b/server/plugins-available/apps_vhost_plugin.inc.php @@ -80,13 +80,12 @@ $web_config = $app->getconf->get_server_config($conf["server_id"], 'web'); if($web_config['server_type'] == 'apache'){ - // Dont just copy over the virtualhost template but add some custom settings - if(file_exists($conf["rootpath"]."/conf-custom/apache_apps.vhost.master")) { - $content = file_get_contents($conf["rootpath"]."/conf-custom/apache_apps.vhost.master"); - } else { - $content = file_get_contents($conf["rootpath"]."/conf/apache_apps.vhost.master"); - } + $app->load('tpl'); + $tpl = new tpl(); + $tpl->newTemplate('apache_apps.vhost.master'); + + $tpl->setVar('apache_version', $app->system->getapacheversion()); $vhost_conf_dir = $web_config['vhost_conf_dir']; $vhost_conf_enabled_dir = $web_config['vhost_conf_enabled_dir']; @@ -95,21 +94,41 @@ $web_config['apps_vhost_port'] = (empty($web_config['apps_vhost_port']))?8081:$web_config['apps_vhost_port']; $web_config['apps_vhost_ip'] = (empty($web_config['apps_vhost_ip']))?'_default_':$web_config['apps_vhost_ip']; + $tpl->setVar('apps_vhost_ip', $web_config['apps_vhost_ip']); + $tpl->setVar('apps_vhost_port', $web_config['apps_vhost_port']); + $tpl->setVar('apps_vhost_dir', $web_config['website_basedir'].'/apps'); + $tpl->setVar('apps_vhost_servername', $apps_vhost_servername); + $tpl->setVar('apps_vhost_basedir', $web_config['website_basedir']); + + $vhost_port_listen = ''; + // comment out the listen directive if port is 80 or 443 + if($web_config['apps_vhost_port'] == 80 or $web_config['apps_vhost_port'] == 443) { + $vhost_port_listen = '#'; + } + $tpl->setVar('vhost_port_listen', $vhost_port_listen); + + $content = $tpl->grab(); + + /* for backwards compatibility we replace the old syntax by hand now */ $content = str_replace('{apps_vhost_ip}', $web_config['apps_vhost_ip'], $content); $content = str_replace('{apps_vhost_port}', $web_config['apps_vhost_port'], $content); $content = str_replace('{apps_vhost_dir}', $web_config['website_basedir'].'/apps', $content); $content = str_replace('{apps_vhost_servername}', $apps_vhost_servername, $content); $content = str_replace('{apps_vhost_basedir}', $web_config['website_basedir'], $content); + $content = str_replace('{vhost_port_listen}', $vhost_port_listen, $content); + /* end of backwards compatibility section */ + $app->system->file_put_contents("$vhost_conf_dir/apps.vhost", $content); - // comment out the listen directive if port is 80 or 443 - if($web_config['apps_vhost_port'] == 80 or $web_config['apps_vhost_port'] == 443) { - $content = str_replace('{vhost_port_listen}', '#', $content); - } else { - $content = str_replace('{vhost_port_listen}', '', $content); + // enabled / disable apps-vhost + $vhost_symlink = escapeshellcmd($web_config['vhost_conf_enabled_dir'].'/000-apps.vhost'); + if(is_link($vhost_symlink) && $web_config['apps_vhost_enabled'] == 'n') { + $app->system->unlink($vhost_symlink); + } + if(!@is_link($vhost_conf_enabled_dir.'/000-apps.vhost') && $web_config['apps_vhost_enabled'] == 'y') { + symlink($vhost_conf_dir.'/apps.vhost', $vhost_conf_enabled_dir.'/000-apps.vhost'); } - file_put_contents("$vhost_conf_dir/apps.vhost", $content); $app->services->restartServiceDelayed('httpd', 'restart'); } @@ -176,6 +195,16 @@ file_put_contents($web_config['php_fpm_pool_dir'].'/apps.conf', $fpm_content); file_put_contents("$vhost_conf_dir/apps.vhost", $content); + + // enabled / disable apps-vhost + $vhost_symlink = escapeshellcmd($web_config['vhost_conf_enabled_dir'].'/000-apps.vhost'); + if(is_link($vhost_symlink) && $web_config['apps_vhost_enabled'] == 'n') { + $app->system->unlink($vhost_symlink); + } + if(!@is_link($vhost_conf_enabled_dir.'/000-apps.vhost') && $web_config['apps_vhost_enabled'] == 'y') { + symlink($vhost_conf_dir.'/apps.vhost', $vhost_conf_enabled_dir.'/000-apps.vhost'); + } + $app->services->restartServiceDelayed('httpd', 'reload'); } } -- Gitblit v1.9.1