Skip to content
install.lib.php 28.3 KiB
Newer Older
<?php

/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
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.
*/
error_reporting(E_ALL|E_STRICT);


$FILE = realpath('../install.php');

require_once realpath(dirname(__FILE__)) . '/classes/libbashcolor.inc.php';

Marius Burkard's avatar
Marius Burkard committed
function is_supported_dist($dist) {
	$name = $dist['name'];
	$version = $dist['version'];
	
	$min_version = false;
	if($name === 'Ubuntu') {
		$tmp = explode(" ", $version);
		$version = reset($tmp); // Dist name is appended on get_distname
		$min_version = '16.04';
		$add_versions = array('Testing', 'Unknown');
	} elseif($name === 'Debian') {
		$min_version = '9';
Marius Burkard's avatar
Marius Burkard committed
		$add_versions = array('Testing', 'Unknown');
	} elseif($name === 'Devuan') {
		$min_version = '1.0';
		$add_versions = array('Jessie', 'Ceres');
	} elseif($name === 'openSUSE') {
		$min_version = '11.2';
		$add_versions = false;
	} elseif($name === 'Fedora') {
		$min_version = '11';
		$add_versions = array('Unknown');
	} elseif($name === 'CentOS') {
		$min_version = '7.0';
		$add_versions = array('Unknown');
	} elseif($name === 'Gentoo') {
		$min_version = '1.0';
	}
	
	if($version && $min_version && preg_match('/^[0-9]+/', $version)) {
		if(version_compare($version, $min_version, '>=')) return true;
	} elseif($version && !preg_match('/^[0-9]+/', $version) && !empty($add_versions)) {
		if(in_array($version, $add_versions, true)) return true;
	}
	
	return false;
}

oliver's avatar
oliver committed
//** Get distribution identifier
//   This is the same code as in server/lib/classes/monitor_tools.inc.php
//   So if you change it here, you also have to change it in there!
//
//	This function returns a string that describes the installed
//	Linux distribution. e.g. debian40 for Debian GNU/Linux 4.0

tbrehm's avatar
tbrehm committed
	$distname = '';
	$distver = '';
	$distid = '';
	$distbaseid = '';
	//** Debian or Ubuntu
	if(file_exists('/etc/debian_version')) {
		
		// Check if this is Ubuntu and not Debian
		if (strstr(trim(file_get_contents('/etc/issue')), 'Ubuntu') || (is_file('/etc/os-release') && stristr(file_get_contents('/etc/os-release'), 'Ubuntu'))) {
			
			$issue = file_get_contents('/etc/issue');
			
			// Use content of /etc/issue file
			if(strstr($issue,'Ubuntu')) {
				if (strstr(trim($issue), 'LTS')) {
					$lts=" LTS";
				} else {
					$lts="";
				}

				$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);
			// Use content of /etc/os-release file
			} else {
				$os_release = file_get_contents('/etc/os-release');
				if (strstr(trim($os_release), 'LTS')) {
					$lts = " LTS";
				} else {
					$lts = "";
				}
				
				$distname = 'Ubuntu';
				$distid = 'debian40';
				$distbaseid = 'debian';

				preg_match("/.*VERSION=\"(.*)\".*/ui", $os_release, $ver);
				$ver = str_replace("LTS", "", $ver[1]);
				$ver = explode(" ", $ver, 2);
				$ver = reset($ver);
				$mainver = $ver;
				$mainver = explode('.', $ver);
				$mainver = array_filter($mainver);
				$mainver = current($mainver).'.'.next($mainver);
			}
			switch ($mainver){
			case "18.04":
				$relname = "(Bionic Beaver)";
				$distconfid = 'ubuntu1804';
				break;
			case "17.10":
				$relname = "(Artful Aardvark)";
				$distconfid = 'ubuntu1710';
				break;
			case "17.04":
				$relname = "(Zesty Zapus)";
				$distconfid = 'ubuntu1604';
				break;
			case "16.10":
				$relname = "(Yakkety Yak)";
				$distconfid = 'ubuntu1604';
				break;
Till Brehm's avatar
Till Brehm committed
			case "16.04":
				$relname = "(Xenial Xerus)";
Till Brehm's avatar
Till Brehm committed
				break;
			case "15.10":
				$relname = "(Wily Werewolf)";
				break;
			case "15.04":
				$relname = "(Vivid Vervet)";
				break;
			case "14.10":
				$relname = "(Utopic Unicorn)";
				break;
Till Brehm's avatar
Till Brehm committed
			case "14.04":
				$relname = "(Trusty Tahr)";
				break;
			case "13.10":
				$relname = "(Saucy Salamander)";
				break;
			case "13.04":
				$relname = "(Raring Ringtail)";
				break;
			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;
Loading full blame...