From 37b29231e47a0c4458dc1c15d98588f16f07e1e2 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Thu, 06 Aug 2015 03:18:44 -0400
Subject: [PATCH] - don't set password via remoting if field is empty

---
 server/plugins-available/nginx_plugin.inc.php |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php
index 9ce9de8..7be49ce 100644
--- a/server/plugins-available/nginx_plugin.inc.php
+++ b/server/plugins-available/nginx_plugin.inc.php
@@ -475,6 +475,7 @@
 				}
 				
 				//* Unmount the old log directory bfore we move the log dir
+				//exec('fuser -km '.escapeshellcmd($old_dir.'/log'));
 				exec('umount '.escapeshellcmd($old_dir.'/log'));
 
 				//* Create new base directory, if it does not exist yet
@@ -557,6 +558,7 @@
 			$app->system->removeLine('/etc/fstab', $fstab_line);
 
 			//* Unmount log directory
+			//exec('fuser -km '.escapeshellarg($data['old']['document_root'].'/'.$old_log_folder));
 			exec('umount '.escapeshellarg($data['old']['document_root'].'/'.$old_log_folder));
 		}
 
@@ -950,7 +952,7 @@
 			$default_php_fpm = true;
 		}
 		*/
-		if($data['new']['php'] != 'no'){
+		if($data['new']['php'] == 'php-fpm'){
 			if(trim($data['new']['fastcgi_php_version']) != ''){
 				$default_php_fpm = false;
 				list($custom_php_fpm_name, $custom_php_fpm_init_script, $custom_php_fpm_ini_dir, $custom_php_fpm_pool_dir) = explode(':', trim($data['new']['fastcgi_php_version']));
@@ -1880,10 +1882,12 @@
 			if(is_array($log_folders) && !empty($log_folders)){
 				foreach($log_folders as $log_folder){
 					//if($app->system->is_mounted($data['old']['document_root'].'/'.$log_folder)) exec('umount '.escapeshellarg($data['old']['document_root'].'/'.$log_folder));
+					//exec('fuser -km '.escapeshellarg($data['old']['document_root'].'/'.$log_folder).' 2>/dev/null');
 					exec('umount '.escapeshellarg($data['old']['document_root'].'/'.$log_folder).' 2>/dev/null');
 				}
 			} else {
 				//if($app->system->is_mounted($data['old']['document_root'].'/'.$log_folder)) exec('umount '.escapeshellarg($data['old']['document_root'].'/'.$log_folder));
+				//exec('fuser -km '.escapeshellarg($data['old']['document_root'].'/'.$log_folder).' 2>/dev/null');
 				exec('umount '.escapeshellarg($data['old']['document_root'].'/'.$log_folder).' 2>/dev/null');
 			}
 		}
@@ -2424,9 +2428,12 @@
 			exec('/usr/sbin/update-rc.d hhvm_' . $data['new']['system_user'] . ' defaults >/dev/null 2>&1');
 			exec('/etc/init.d/hhvm_' . $data['new']['system_user'] . ' restart >/dev/null 2>&1');
 			
-			$monit_content = str_replace('{SYSTEM_USER}', $data['new']['system_user'], $monit_content);
-			file_put_contents('/etc/monit/conf.d/hhvm_' . $data['new']['system_user'], $monit_content);
-			exec('/etc/init.d/monit restart >/dev/null 2>&1');
+			if(is_dir('/etc/monit/conf.d')){
+				$monit_content = str_replace('{SYSTEM_USER}', $data['new']['system_user'], $monit_content);
+				file_put_contents('/etc/monit/conf.d/00-hhvm_' . $data['new']['system_user'], $monit_content);
+				if(is_file('/etc/monit/conf.d/hhvm_' . $data['new']['system_user'])) unlink('/etc/monit/conf.d/hhvm_' . $data['new']['system_user']);
+				exec('/etc/init.d/monit restart >/dev/null 2>&1');
+			}
 			
  		} elseif($data['new']['php'] != 'hhvm' && $data['old']['php'] == 'hhvm') {
 			exec('/etc/init.d/hhvm_' . $data['old']['system_user'] . ' stop >/dev/null 2>&1');
@@ -2434,8 +2441,13 @@
 			unlink('/etc/init.d/hhvm_' . $data['old']['system_user']);
 			if(is_file('/etc/hhvm/'.$data['old']['system_user'].'.ini')) unlink('/etc/hhvm/'.$data['old']['system_user'].'.ini');
 			
-			if(is_file('/etc/monit/conf.d/hhvm_' . $data['new']['system_user'])){
-				unlink('/etc/monit/conf.d/hhvm_' . $data['new']['system_user']);
+			if(is_file('/etc/monit/conf.d/hhvm_' . $data['new']['system_user']) || is_file('/etc/monit/conf.d/00-hhvm_' . $data['new']['system_user'])){
+				if(is_file('/etc/monit/conf.d/hhvm_' . $data['new']['system_user'])){
+					unlink('/etc/monit/conf.d/hhvm_' . $data['new']['system_user']);
+				}
+				if(is_file('/etc/monit/conf.d/00-hhvm_' . $data['new']['system_user'])){
+					unlink('/etc/monit/conf.d/00-hhvm_' . $data['new']['system_user']);
+				}
 				exec('/etc/init.d/monit restart >/dev/null 2>&1');
 			}
 		}
@@ -2454,7 +2466,7 @@
 			$default_php_fpm = true;
 		}
 		*/
-		if($data['new']['php'] != 'no'){
+		if($data['new']['php'] == 'php-fpm'){
 			if(trim($data['new']['fastcgi_php_version']) != ''){
 				$default_php_fpm = false;
 				list($custom_php_fpm_name, $custom_php_fpm_init_script, $custom_php_fpm_ini_dir, $custom_php_fpm_pool_dir) = explode(':', trim($data['new']['fastcgi_php_version']));
@@ -2475,7 +2487,7 @@
 		$app->uses("getconf");
 		$web_config = $app->getconf->get_server_config($conf["server_id"], 'web');
 
-		if($data['new']['php'] == 'no'){
+		if($data['new']['php'] != 'php-fpm'){
 			if(@is_file($pool_dir.$pool_name.'.conf')){
 				$app->system->unlink($pool_dir.$pool_name.'.conf');
 				//$reload = true;

--
Gitblit v1.9.1