View source
<?php
class Provision_Service_http_https_nginx extends Provision_Service_http_https {
protected $application_name = 'nginx';
protected $has_restart_cmd = TRUE;
function default_restart_cmd() {
return Provision_Service_http_nginx::nginx_restart_cmd();
}
public $https_enabled = TRUE;
function cloaked_db_creds() {
return TRUE;
}
function init_server() {
parent::init_server();
$this->configs['server'][] = 'Provision_Config_Nginx_Https_Server';
$this->configs['server'][] = 'Provision_Config_Nginx_Inc_Server';
$this->configs['site'][] = 'Provision_Config_Nginx_Https_Site';
$this->server
->setProperty('nginx_config_mode', 'extended');
$this->server
->setProperty('nginx_is_modern', FALSE);
$this->server
->setProperty('nginx_has_http2', FALSE);
$this->server
->setProperty('nginx_has_gzip', FALSE);
$this->server
->setProperty('nginx_has_upload_progress', FALSE);
$this->server
->setProperty('provision_db_cloaking', TRUE);
$this->server
->setProperty('phpfpm_mode', 'port');
$this->server
->setProperty('satellite_mode', 'vanilla');
}
function save_server() {
if (provision_file()
->exists('/usr/local/sbin/nginx')
->status()) {
$path = "/usr/local/sbin/nginx";
}
elseif (provision_file()
->exists('/usr/sbin/nginx')
->status()) {
$path = "/usr/sbin/nginx";
}
elseif (provision_file()
->exists('/usr/local/bin/nginx')
->status()) {
$path = "/usr/local/bin/nginx";
}
else {
return;
}
$this->server
->shell_exec($path . ' -V');
$this->server->nginx_is_modern = preg_match("/nginx\\/1\\.((1\\.(8|9|(1[0-9]+)))|((2|3|4|5|6|7|8|9|[1-9][0-9]+)\\.))/", implode('', drush_shell_exec_output()), $match);
$this->server->nginx_has_http2 = preg_match("/http_v2_module/", implode('', drush_shell_exec_output()), $match);
$this->server->nginx_has_upload_progress = preg_match("/upload/", implode('', drush_shell_exec_output()), $match);
$this->server->nginx_has_gzip = preg_match("/http_gzip_static_module/", implode('', drush_shell_exec_output()), $match);
$nginx_config_mode_file = "/etc/nginx/basic_nginx.conf";
if (provision_file()
->exists($nginx_config_mode_file)
->status()) {
$this->server->nginx_config_mode = 'basic';
drush_log(dt('Basic Nginx Config Active -SAVE- YES control file found @path.', array(
'@path' => $nginx_config_mode_file,
)));
}
else {
$this->server->nginx_config_mode = 'extended';
drush_log(dt('Extended Nginx Config Active -SAVE- NO control file found @path.', array(
'@path' => $nginx_config_mode_file,
)));
}
$this->server->phpfpm_mode = Provision_Service_http_nginx::getPhpFpmMode('save');
if (provision_file()
->exists('/data/conf/global.inc')
->status()) {
$this->server->satellite_mode = 'boa';
drush_log(dt('BOA mode detected -SAVE- YES file found @path.', array(
'@path' => '/data/conf/global.inc',
)));
}
else {
$this->server->satellite_mode = 'vanilla';
drush_log(dt('Vanilla mode detected -SAVE- NO file found @path.', array(
'@path' => '/data/conf/global.inc',
)));
}
}
function verify_server_cmd() {
if (provision_file()
->exists('/usr/local/sbin/nginx')
->status()) {
$path = "/usr/local/sbin/nginx";
}
elseif (provision_file()
->exists('/usr/sbin/nginx')
->status()) {
$path = "/usr/sbin/nginx";
}
elseif (provision_file()
->exists('/usr/local/bin/nginx')
->status()) {
$path = "/usr/local/bin/nginx";
}
else {
return;
}
$this->server
->shell_exec($path . ' -V');
$this->server->nginx_is_modern = preg_match("/nginx\\/1\\.((1\\.(8|9|(1[0-9]+)))|((2|3|4|5|6|7|8|9|[1-9][0-9]+)\\.))/", implode('', drush_shell_exec_output()), $match);
$this->server->nginx_has_http2 = preg_match("/http_v2_module/", implode('', drush_shell_exec_output()), $match);
$this->server->nginx_has_upload_progress = preg_match("/upload/", implode('', drush_shell_exec_output()), $match);
$this->server->nginx_has_gzip = preg_match("/http_gzip_static_module/", implode('', drush_shell_exec_output()), $match);
$nginx_config_mode_file = "/etc/nginx/basic_nginx.conf";
if (provision_file()
->exists($nginx_config_mode_file)
->status()) {
$this->server->nginx_config_mode = 'basic';
drush_log(dt('Basic Nginx Config Active -VERIFY- YES control file found @path.', array(
'@path' => $nginx_config_mode_file,
)));
}
else {
$this->server->nginx_config_mode = 'extended';
drush_log(dt('Extended Nginx Config Active -VERIFY- NO control file found @path.', array(
'@path' => $nginx_config_mode_file,
)));
}
$this->server->phpfpm_mode = Provision_Service_http_nginx::getPhpFpmMode('verify');
if (provision_file()
->exists('/data/conf/global.inc')
->status()) {
$this->server->satellite_mode = 'boa';
drush_log(dt('BOA mode detected -VERIFY- YES file found @path.', array(
'@path' => '/data/conf/global.inc',
)));
}
else {
$this->server->satellite_mode = 'vanilla';
drush_log(dt('Vanilla mode detected -VERIFY- NO file found @path.', array(
'@path' => '/data/conf/global.inc',
)));
}
parent::verify_server_cmd();
}
function parse_configs() {
return $this
->restart();
}
}