cleaned up startup script
This commit is contained in:
		
							
								
								
									
										7
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,7 +1,8 @@ | |||||||
| /.settings | /.settings/ | ||||||
| /.buildpath | /.buildpath | ||||||
| /.project | /.project | ||||||
| /.idea | /.idea/ | ||||||
| /application/configs | /application/configs/ | ||||||
| /application/logs/ | /application/logs/ | ||||||
| /application/ManiaControl.log | /application/ManiaControl.log | ||||||
|  | /application/ManiaControl.pid | ||||||
|   | |||||||
| @@ -20,20 +20,26 @@ if (!ini_get('date.timezone') && function_exists('date_default_timezone_set')) { | |||||||
| 	date_default_timezone_set('UTC'); | 	date_default_timezone_set('UTC'); | ||||||
| } | } | ||||||
|  |  | ||||||
| // Build log file name | /* | ||||||
| $logFileName = ManiaControlDir . 'logs' . DIRECTORY_SEPARATOR; |  * Build log file name | ||||||
| if (!is_dir($logFileName) && !mkdir($logFileName)) { |  */ | ||||||
| 	echo "Couldn't create Logs Folder, please check the File Permissions!"; | function buildLogFileName() { | ||||||
|  | 	$logFileName = ManiaControlDir . 'logs' . DIRECTORY_SEPARATOR; | ||||||
|  | 	if (!is_dir($logFileName) && !mkdir($logFileName)) { | ||||||
|  | 		echo "Couldn't create Logs Folder, please check the File Permissions!"; | ||||||
|  | 	} | ||||||
|  | 	$logFileName .= 'ManiaControl'; | ||||||
|  | 	if (LOG_NAME_USE_DATE) { | ||||||
|  | 		$logFileName .= '_' . date('Y-m-d'); | ||||||
|  | 	} | ||||||
|  | 	if (LOG_NAME_USE_PID) { | ||||||
|  | 		$logFileName .= '_' . getmypid(); | ||||||
|  | 	} | ||||||
|  | 	$logFileName .= '.log'; | ||||||
|  | 	ini_set('error_log', $logFileName); | ||||||
| } | } | ||||||
| $logFileName .= 'ManiaControl'; |  | ||||||
| if (LOG_NAME_USE_DATE) { | buildLogFileName(); | ||||||
| 	$logFileName .= '_' . date('Y-m-d'); |  | ||||||
| } |  | ||||||
| if (LOG_NAME_USE_PID) { |  | ||||||
| 	$logFileName .= '_' . getmypid(); |  | ||||||
| } |  | ||||||
| $logFileName .= '.log'; |  | ||||||
| ini_set('error_log', $logFileName); |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Log and echo the given text |  * Log and echo the given text | ||||||
| @@ -43,46 +49,50 @@ ini_set('error_log', $logFileName); | |||||||
|  */ |  */ | ||||||
| function logMessage($message, $eol = true) { | function logMessage($message, $eol = true) { | ||||||
| 	error_log($message); | 	error_log($message); | ||||||
| 	echo $message . ($eol ? PHP_EOL : ''); | 	if ($eol) { | ||||||
|  | 		$message = '[' . date('d-M-Y H:i:s e') . '] ' . $message . PHP_EOL; | ||||||
|  | 	} | ||||||
|  | 	echo $message; | ||||||
| } | } | ||||||
|  |  | ||||||
| logMessage('Starting ManiaControl...'); | logMessage('Starting ManiaControl...'); | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Check for Min PHP version |  * Check for the requirements to run ManiaControl | ||||||
|  */ |  */ | ||||||
| define('MIN_PHP_VERSION', '5.4'); | function checkRequirements() { | ||||||
| logMessage('Checking for minimum required PHP-Version ' . MIN_PHP_VERSION . ' ... ', false); | 	// Check for min PHP version | ||||||
| if (phpversion() >= MIN_PHP_VERSION) { | 	$minPhpVersion = '5.4'; | ||||||
| 	logMessage(phpversion() . " OK!", true); | 	$phpVersion    = phpversion(); | ||||||
| } else { | 	$message       = "Checking for minimum required PHP-Version '{$minPhpVersion}'... "; | ||||||
| 	logMessage('TOO OLD VERSION!', true); | 	if ($phpVersion < $minPhpVersion) { | ||||||
| 	logMessage(' -- Make sure that you install at least PHP 5.4', true); | 		$message .= "{$minPhpVersion} TOO OLD VERSION!"; | ||||||
| 	exit(); | 		logMessage($message); | ||||||
|  | 		logMessage(" -- Make sure that you install at least PHP {$minPhpVersion}!"); | ||||||
|  | 		exit(); | ||||||
|  | 	} | ||||||
|  | 	logMessage($message . "'{$minPhpVersion}' OK!"); | ||||||
|  |  | ||||||
|  | 	// Check for MySQLi | ||||||
|  | 	$message = 'Checking for installed MySQLi... '; | ||||||
|  | 	if (!extension_loaded('mysqli')) { | ||||||
|  | 		logMessage($message . 'NOT FOUND!'); | ||||||
|  | 		logMessage(" -- You don't have MySQLi installed! Check: http://www.php.net/manual/en/mysqli.installation.php"); | ||||||
|  | 		exit(); | ||||||
|  | 	} | ||||||
|  | 	logMessage($message . 'FOUND!'); | ||||||
|  |  | ||||||
|  | 	// Check for cURL | ||||||
|  | 	$message = 'Checking for installed cURL... '; | ||||||
|  | 	if (!extension_loaded('curl')) { | ||||||
|  | 		logMessage($message . 'NOT FOUND!'); | ||||||
|  | 		logMessage(" -- You don't have cURL installed! Check: http://www.php.net/manual/en/curl.installation.php"); | ||||||
|  | 		exit(); | ||||||
|  | 	} | ||||||
|  | 	logMessage($message . 'FOUND!'); | ||||||
| } | } | ||||||
|  |  | ||||||
| /** | checkRequirements(); | ||||||
|  * Checking if all the needed libraries are installed. |  | ||||||
|  * - MySQLi |  | ||||||
|  * - cURL |  | ||||||
|  */ |  | ||||||
| logMessage('Checking for installed MySQLi ... ', false); |  | ||||||
| if (extension_loaded('mysqli')) { |  | ||||||
| 	logMessage('FOUND!', true); |  | ||||||
| } else { |  | ||||||
| 	logMessage('NOT FOUND!', true); |  | ||||||
| 	logMessage(' -- You don\'t have MySQLi installed, make sure to check: http://www.php.net/manual/en/mysqli.installation.php', true); |  | ||||||
| 	exit(); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| logMessage('Checking for installed cURL   ... ', false); |  | ||||||
| if (extension_loaded('curl')) { |  | ||||||
| 	logMessage('FOUND!', true); |  | ||||||
| } else { |  | ||||||
| 	logMessage('NOT FOUND!', true); |  | ||||||
| 	logMessage('You don\'t have cURL installed, make sure to check: http://www.php.net/manual/en/curl.installation.php', true); |  | ||||||
| 	exit(); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Make sure garbage collection is enabled | // Make sure garbage collection is enabled | ||||||
| gc_enable(); | gc_enable(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user