Skip to content
monitor_tools.inc.php 49.4 KiB
Newer Older
	Copyright (c) 2007-2011, Till Brehm, projektfarm Gmbh and Oliver Vogel www.muv.com
	All rights reserved.
	Redistribution and use in source and binary forms, with or without modification,
	are permitted provided that the following conditions are met:

 * Redistributions of source code must retain the above copyright notice,
	this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice,
	this list of conditions and the following disclaimer in the documentation
	and/or other materials provided with the distribution.
 * Neither the name of ISPConfig nor the names of its contributors
	may be used to endorse or promote products derived from this software without
	specific prior written permission.

	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
	ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
	WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
	IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
	INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
	BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
	DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
	OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
	NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
	EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

class monitor_tools {

	//** Get distribution identifier
	//** IMPORTANT!
	//   This is the same code as in install/lib/install.lib.php
	//   So if you change it here, you also have to change it in there!
	//   Please do not forget to remove the swriteln(); - lines here at this file
	public function get_distname() {

		$distname = '';
		$distver = '';
		$distid = '';
		$distbaseid = '';

		//** Debian or Ubuntu
		if (file_exists('/etc/debian_version')) {
			if (strstr(trim(file_get_contents('/etc/issue')), 'Ubuntu')) {
				if (strstr(trim(file_get_contents('/etc/issue')), 'LTS')) {
					$lts=" LTS";
				} else {
					$lts="";
				}

				$issue=file_get_contents('/etc/issue');
				$distname = 'Ubuntu';
				$distid = 'debian40';
				$distbaseid = 'debian';
				$ver = explode(' ',$issue);
				$ver = array_filter($ver);
				$ver = next($ver);
				$mainver = explode('.',$ver);
				$mainver = array_filter($mainver);
				$mainver = current($mainver).'.'.next($mainver);
				switch ($mainver){
				case "12.10":
					$relname = "(Quantal Quetzal)";
				break;
				case "12.04":
					$relname = "(Precise Pangolin)";
				break;
				case "11.10":
					$relname = "(Oneiric Ocelot)";
				break;
				case "11.14":
					$relname = "(Natty Narwhal)";
				break;
				case "10.10":
					$relname = "(Maverick Meerkat)";
				break;
				case "10.04":
					$relname = "(Lucid Lynx)";
				break;
				case "9.10":
					$relname = "(Karmic Koala)";
				break;
				case "9.04":
					$relname = "(Jaunty Jackpole)";
				break;
				case "8.10":
				$relname = "(Intrepid Ibex)";
				break;
				case "8.04":
					$relname = "(Hardy Heron)";
				break;
				case "7.10":
					$relname = "(Gutsy Gibbon)";
				break;
				case "7.04":
					$relname = "(Feisty Fawn)";
				break;
				case "6.10":
					$relname = "(Edgy Eft)";
				break;
				case "6.06":
					$relname = "(Dapper Drake)";
				break;
				case "5.10":
					$relname = "(Breezy Badger)";
				break;
				case "5.04":
					$relname = "(Hoary Hedgehog)";
				break;
				case "4.10":
					$relname = "(Warty Warthog)";
				break;
				default:
					$relname = "UNKNOWN";
				}
				$distver = $ver.$lts." ".$relname;
			} elseif(trim(file_get_contents('/etc/debian_version')) == '4.0') {
				$distname = 'Debian';
				$distver = '4.0';
				$distid = 'debian40';
				$distbaseid = 'debian';
			} elseif (strstr(trim(file_get_contents('/etc/debian_version')), '5.0')) {
				$distname = 'Debian';
				$distver = 'Lenny';
				$distid = 'debian40';
				$distbaseid = 'debian';
			} elseif (strstr(trim(file_get_contents('/etc/debian_version')), '6.0') || trim(file_get_contents('/etc/debian_version')) == 'squeeze/sid') {
				$distname = 'Debian';
				$distver = 'Squeeze/Sid';
				$distid = 'debian60';
				$distbaseid = 'debian';
			} elseif (strstr(trim(file_get_contents('/etc/debian_version')), '7.0') || strstr(trim(file_get_contents('/etc/debian_version')), '7.1') || trim(file_get_contents('/etc/debian_version')) == 'wheezy/sid') {
				$distname = 'Debian';
				$distver = 'Wheezy/Sid';
				$distbaseid = 'debian';
			} else {
				$distname = 'Debian';
				$distver = 'Unknown';
				$distid = 'debian40';
				$distbaseid = 'debian';
			}
		}

		//** OpenSuSE
		elseif (file_exists('/etc/SuSE-release')) {
			if (stristr(file_get_contents('/etc/SuSE-release'), '11.0')) {
				$distname = 'openSUSE';
				$distver = '11.0';
				$distid = 'opensuse110';
				$distbaseid = 'opensuse';
			} elseif (stristr(file_get_contents('/etc/SuSE-release'), '11.1')) {
				$distname = 'openSUSE';
				$distver = '11.1';
				$distid = 'opensuse110';
				$distbaseid = 'opensuse';
			} elseif (stristr(file_get_contents('/etc/SuSE-release'), '11.2')) {
				$distname = 'openSUSE';
				$distver = '11.1';
				$distid = 'opensuse110';
				$distbaseid = 'opensuse';
			} else {
				$distname = 'openSUSE';
				$distver = 'Unknown';
				$distid = 'opensuse110';
				$distbaseid = 'opensuse';
			}
		}


		//** Redhat
		elseif (file_exists('/etc/redhat-release')) {

			$content = file_get_contents('/etc/redhat-release');

			if (stristr($content, 'Fedora release 9 (Sulphur)')) {
				$distname = 'Fedora';
				$distver = '9';
				$distid = 'fedora9';
				$distbaseid = 'fedora';
			} elseif (stristr($content, 'Fedora release 10 (Cambridge)')) {
				$distname = 'Fedora';
				$distver = '10';
				$distid = 'fedora9';
				$distbaseid = 'fedora';
			} elseif (stristr($content, 'Fedora release 10')) {
				$distname = 'Fedora';
				$distver = '11';
				$distid = 'fedora9';
				$distbaseid = 'fedora';
			} elseif (stristr($content, 'CentOS release 5.2 (Final)')) {
				$distname = 'CentOS';
				$distver = '5.2';
				$distid = 'centos52';
				$distbaseid = 'fedora';
			} elseif (stristr($content, 'CentOS release 5.3 (Final)')) {
				$distname = 'CentOS';
Loading full blame...