From 6d6643de2b6fc47b15e27c46266f22866c1cd1a8 Mon Sep 17 00:00:00 2001
From: Till Brehm <tbrehm@ispconfig.org>
Date: Wed, 24 Sep 2014 09:47:20 -0400
Subject: [PATCH] Fixed service restart problems on CentOS 7.

---
 server/mods-available/web_module.inc.php |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/server/mods-available/web_module.inc.php b/server/mods-available/web_module.inc.php
index f84d87f..42eaab6 100644
--- a/server/mods-available/web_module.inc.php
+++ b/server/mods-available/web_module.inc.php
@@ -212,11 +212,12 @@
 
 		$retval = array('output' => '', 'retval' => 0);
 		if($action == 'restart') {
-			exec($app->system->getinitcommand($daemon, 'restart').' 2>&1', $retval['output'], $retval['retval']);
-
+			$cmd = $app->system->getinitcommand($daemon, 'restart');
 		} else {
-			exec($app->system->getinitcommand($daemon, 'reload').' 2>&1', $retval['output'], $retval['retval']);
+			$cmd = $app->system->getinitcommand($daemon, 'reload');
 		}
+		exec($cmd.' 2>&1', $retval['output'], $retval['retval']);
+		$app->log("Restarting httpd: $cmd", LOGLEVEL_DEBUG);
 		
 		// nginx: do a syntax check because on some distributions, the init script always returns 0 - even if the syntax is not ok (how stupid is that?)
 		if($web_config['server_type'] == 'nginx' && $retval['retval'] == 0){
@@ -249,6 +250,22 @@
 					if(preg_match('/^ID=ubuntu/m', $tmp) && preg_match('/^VERSION_ID="14\.04"/m', $tmp)) {
 						$initcommand = '/sbin/start-stop-daemon --stop --signal USR2 --quiet --pidfile /var/run/php5-fpm.pid --name php5-fpm';
 					}
+					// And the next workaround, php-fpm reloads in centos 7 downt work as well.
+					if(preg_match('/^ID=centos/m', $tmp) && preg_match('/^VERSION_ID="7"/m', $tmp)) {
+						$initcommand = 'systemctl restart php-fpm.service';
+					}
+					unset($tmp);
+				}	
+			}
+			
+			if($action == 'reload') {
+				// And the next workaround, php-fpm reloads in centos 7 downt work as well.
+				if(file_exists('/etc/os-release')) {
+					$tmp = file_get_contents('/etc/os-release');
+					// And the next workaround, php-fpm reloads in centos 7 downt work as well.
+					if(preg_match('/^ID="centos"/m', $tmp) && preg_match('/^VERSION_ID="7"/m', $tmp)) {
+						$initcommand = 'systemctl restart php-fpm.service';
+					}
 					unset($tmp);
 				}
 			}
@@ -256,6 +273,7 @@
 
 		$retval = array('output' => '', 'retval' => 0);
 		exec($initcommand.' 2>&1', $retval['output'], $retval['retval']);
+		$app->log("Restarting php-fpm: $initcommand", LOGLEVEL_DEBUG);
 		return $retval;
 	}
 

--
Gitblit v1.9.1