diff --git a/install/dist/lib/centos72.lib.php b/install/dist/lib/centos72.lib.php deleted file mode 100644 index 407a61bf8b66bcb945b5d408e747b8f118185494..0000000000000000000000000000000000000000 --- a/install/dist/lib/centos72.lib.php +++ /dev/null @@ -1,125 +0,0 @@ -<?php - -/* -Copyright (c) 2014, Till Brehm, ISPConfig UG -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. -*/ - -require_once realpath(dirname(__FILE__)) . '/centos_base.lib.php'; - -class installer extends installer_centos { - - protected $clamav_socket = '/var/run/clamd.amavisd/clamd.sock'; - - public function configure_amavis() { - global $conf; - - // amavisd user config file - $configfile = 'fedora_amavisd_conf'; - if(!is_dir($conf["amavis"]["config_dir"])) mkdir($conf["amavis"]["config_dir"]); - if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf')) copy($conf["amavis"]["config_dir"].'/amavisd.conf', $conf["amavis"]["config_dir"].'/amavisd.conf~'); - if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf~')) exec('chmod 400 '.$conf["amavis"]["config_dir"].'/amavisd.conf~'); - $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "tpl/".$configfile.".master"); - $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content); - $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content); - $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content); - $content = str_replace('{mysql_server_port}', $conf["mysql"]["port"], $content); - $content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content); - $content = str_replace('{hostname}', $conf['hostname'], $content); - $content = str_replace('/var/spool/amavisd/clamd.sock', $this->clamav_socket, $content); - wf($conf["amavis"]["config_dir"].'/amavisd.conf', $content); - chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0640); - exec('chgrp amavis '.$conf['amavis']['config_dir'].'/amavisd.conf'); - - // Adding the amavisd commands to the postfix configuration - $postconf_commands = array ( - 'content_filter = amavis:[127.0.0.1]:10024', - 'receive_override_options = no_address_mappings' - ); - - // Make a backup copy of the main.cf file - copy($conf["postfix"]["config_dir"].'/main.cf', $conf["postfix"]["config_dir"].'/main.cf~2'); - - // Executing the postconf commands - foreach($postconf_commands as $cmd) { - $command = "postconf -e '$cmd'"; - caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); - } - - $config_dir = $conf['postfix']['config_dir']; - - // Adding amavis-services to the master.cf file if the service does not already exists - $add_amavis = !$this->get_postfix_service('amavis','unix'); - $add_amavis_10025 = !$this->get_postfix_service('127.0.0.1:10025','inet'); - $add_amavis_10027 = !$this->get_postfix_service('127.0.0.1:10027','inet'); - - if ($add_amavis || $add_amavis_10025 || $add_amavis_10027) { - //* backup master.cf - if(is_file($config_dir.'/master.cf')) copy($config_dir.'/master.cf', $config_dir.'/master.cf~'); - // adjust amavis-config - if($add_amavis) { - $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master'); - af($config_dir.'/master.cf', $content); - unset($content); - } - if ($add_amavis_10025) { - $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10025.master', 'tpl/master_cf_amavis10025.master'); - af($config_dir.'/master.cf', $content); - unset($content); - } - if ($add_amavis_10027) { - $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10027.master', 'tpl/master_cf_amavis10027.master'); - af($config_dir.'/master.cf', $content); - unset($content); - } - } - - // Create the director for DKIM-Keys - if(!is_dir('/var/lib/amavis/dkim')) mkdir('/var/lib/amavis/dkim', 0750, true); - // get shell-user for amavis - $amavis_user=exec('grep -o "^amavis:\|^vscan:" /etc/passwd'); - if(!empty($amavis_user)) { - $amavis_user=rtrim($amavis_user, ":"); - exec('chown '.$amavis_user.' /var/lib/amavis/dkim'); - } - // get shell-group for amavis - $amavis_group=exec('grep -o "^amavis:\|^vscan:" /etc/group'); - if(!empty($amavis_group)) { - $amavis_group=rtrim($amavis_group, ":"); - exec('chgrp '.$amavis_group.' /var/lib/amavis/dkim'); - } - - removeLine('/etc/sysconfig/freshclam', 'FRESHCLAM_DELAY=disabled-warn # REMOVE ME', 1); - replaceLine('/etc/freshclam.conf', 'Example', '# Example', 1); - replaceLine('/etc/clamd.d/scan.conf', 'Example', '# Example', 1); - - } - - // everything else is inherited from installer_centos class - -} - -?> diff --git a/install/install.php b/install/install.php index cff2265cebb7eccdef0c76ed34dfbfa8110d84f8..14c981522672224b3b80125333f6dbd42b9508b0 100644 --- a/install/install.php +++ b/install/install.php @@ -133,7 +133,7 @@ if(isset($cmd_opt['autoinstall']) && is_file($cmd_opt['autoinstall'])) { //** Include the distribution-specific installer class library and configuration if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once 'dist/lib/'.$dist['baseid'].'.lib.php'; include_once 'dist/lib/'.$dist['id'].'.lib.php'; -include_once 'dist/conf/'.$dist['id'].'.conf.php'; +include_once 'dist/conf/'.$dist['confid'].'.conf.php'; //**************************************************************************************************** //** Installer Interface diff --git a/install/lib/install.lib.php b/install/lib/install.lib.php index faee067e3688fd4219579c5568fdb2cf587c307d..93e5470ba95f6bac2ca0efb9f99a075fb202337a 100644 --- a/install/lib/install.lib.php +++ b/install/lib/install.lib.php @@ -26,29 +26,6 @@ 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. -*/ - -/* - This function returns a string that describes the installed - Linux distribution. e.g. debian40 for Debian GNU/Linux 4.0 -*/ - - - -/* -Comments to completion forever ;-) -commandline arguments -$argv[1] - - -<? -echo "Total argument passed are : $argc \n"; -for( $i = 0 ; $i <= $argc -1 ;$i++) -{ -echo "Argument $i : $argv[$i] \n"; -} -?> - */ error_reporting(E_ALL|E_STRICT); @@ -59,6 +36,10 @@ $FILE = realpath('../install.php'); //** IMPORTANT! // 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 + function get_distname() { $distname = ''; @@ -66,53 +47,54 @@ function get_distname() { $distid = ''; $distbaseid = ''; - //** Debian or Ubuntu - if (is_file('/etc/os-release') && stristr(file_get_contents('/etc/os-release'), 'Ubuntu')) { - $os_release = file_get_contents('/etc/os-release'); - if (strstr(trim($os_release), 'LTS')) { - $lts = " LTS"; - } else { - $lts = ""; - } - - preg_match("/.*VERSION=\"(.*)\".*/ui", $os_release, $ver); - $ver = str_replace("LTS", "", $ver[1]); - $ver = explode(" ", $ver, 2); - $relname = end($ver); - $relname = "(" . trim(trim($relname), "()") . ")"; - $distname = 'Ubuntu'; - $ver = reset($ver); - if($ver == "16.04") { - $distid = 'ubuntu1604'; - } else { - $distid = 'debian40'; - } - $distbaseid = 'debian'; - $distver = $ver . $lts . " " . $relname; - swriteln("Operating System: " . $distver . "\n"); - } //** Debian / Ubuntu - elseif(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"; + //** 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 { - $lts=""; + $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; } - - $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 "16.04": $relname = "(Xenial Xerus)"; - $distid = 'ubuntu1604'; + $distconfid = 'ubuntu1604'; break; case "15.10": $relname = "(Wily Werewolf)"; @@ -187,7 +169,7 @@ function get_distname() { $relname = "UNKNOWN"; } $distver = $ver.$lts." ".$relname; - swriteln("Operating System: ".$distver."\n"); + swriteln("Operating System: ".$distname.' '.$distver."\n"); } elseif(trim(file_get_contents('/etc/debian_version')) == '4.0') { $distname = 'Debian'; $distver = '4.0'; @@ -307,7 +289,8 @@ function get_distname() { } elseif(stristr($content, 'CentOS Linux release 7.2')) { $distname = 'CentOS'; $distver = 'Unknown'; - $distid = 'centos72'; + $distid = 'centos70'; + $distconfid = 'centos72'; $distbaseid = 'fedora'; swriteln("Operating System: CentOS 7.2\n"); } elseif(stristr($content, 'CentOS Linux release 7')) { @@ -340,8 +323,11 @@ function get_distname() { } else { die('Unrecognized GNU/Linux distribution'); } + + // Set $distconfid to distid, if no different id for the config is defined + if(!isset($distconfid)) $distconfid = $distid; - return array('name' => $distname, 'version' => $distver, 'id' => $distid, 'baseid' => $distbaseid); + return array('name' => $distname, 'version' => $distver, 'id' => $distid, 'confid' => $distconfid, 'baseid' => $distbaseid); } function sread() { diff --git a/install/update.php b/install/update.php index 94de94574e6ecb1f5ab995a04e7cd32af036e98d..4626b5044e91147c954410eb32ef8100d5d33821 100644 --- a/install/update.php +++ b/install/update.php @@ -137,7 +137,7 @@ if(isset($cmd_opt['autoinstall']) && is_file($cmd_opt['autoinstall'])) { //** Include the distribution-specific installer class library and configuration if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once 'dist/lib/'.$dist['baseid'].'.lib.php'; include_once 'dist/lib/'.$dist['id'].'.lib.php'; -include_once 'dist/conf/'.$dist['id'].'.conf.php'; +include_once 'dist/conf/'.$dist['confid'].'.conf.php'; //** Get hostname exec('hostname -f', $tmp_out); diff --git a/server/lib/classes/monitor_tools.inc.php b/server/lib/classes/monitor_tools.inc.php index 8d71d9b3a1dfd99cdde43474622820d790eb8f61..f2b7467b629aca3d8838b71352fc0ff3ceac662d 100644 --- a/server/lib/classes/monitor_tools.inc.php +++ b/server/lib/classes/monitor_tools.inc.php @@ -35,23 +35,29 @@ class monitor_tools { // 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')) { + function get_distname() { + + $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=""; } - $issue=file_get_contents('/etc/issue'); $distname = 'Ubuntu'; $distid = 'debian40'; $distbaseid = 'debian'; @@ -61,206 +67,262 @@ class monitor_tools { $mainver = explode('.', $ver); $mainver = array_filter($mainver); $mainver = current($mainver).'.'.next($mainver); - switch ($mainver){ - case "16.04": - $relname = "(Xenial Xerus)"; - $distid = 'ubuntu1604'; - break; - case "15.10": - $relname = "(Wily Werewolf)"; - break; - case "15.04": - $relname = "(Vivid Vervet)"; - break; - case "14.10": - $relname = "(Utopic Unicorn)"; - break; - 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; - 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') || substr(trim(file_get_contents('/etc/debian_version')),0,2) == '7.' || trim(file_get_contents('/etc/debian_version')) == 'wheezy/sid') { - $distname = 'Debian'; - $distver = 'Wheezy/Sid'; - $distid = 'debian60'; - $distbaseid = 'debian'; - } elseif(strstr(trim(file_get_contents('/etc/debian_version')), '8') || substr(trim(file_get_contents('/etc/debian_version')),0,1) == '8') { - $distname = 'Debian'; - $distver = 'Jessie'; - $distid = 'debian60'; - $distbaseid = 'debian'; + // Use content of /etc/os-release file } else { - $distname = 'Debian'; - $distver = 'Unknown'; + $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; } + switch ($mainver){ + case "16.04": + $relname = "(Xenial Xerus)"; + $distconfid = 'ubuntu1604'; + break; + case "15.10": + $relname = "(Wily Werewolf)"; + break; + case "15.04": + $relname = "(Vivid Vervet)"; + break; + case "14.10": + $relname = "(Utopic Unicorn)"; + break; + 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; + 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; + swriteln("Operating System: ".$distname.' '.$distver."\n"); + } elseif(trim(file_get_contents('/etc/debian_version')) == '4.0') { + $distname = 'Debian'; + $distver = '4.0'; + $distid = 'debian40'; + $distbaseid = 'debian'; + swriteln("Operating System: Debian 4.0 or compatible\n"); + } elseif(strstr(trim(file_get_contents('/etc/debian_version')), '5.0')) { + $distname = 'Debian'; + $distver = 'Lenny'; + $distid = 'debian40'; + $distbaseid = 'debian'; + swriteln("Operating System: Debian Lenny or compatible\n"); + } 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'; + swriteln("Operating System: Debian 6.0 (Squeeze/Sid) or compatible\n"); + } elseif(strstr(trim(file_get_contents('/etc/debian_version')), '7.0') || substr(trim(file_get_contents('/etc/debian_version')),0,2) == '7.' || trim(file_get_contents('/etc/debian_version')) == 'wheezy/sid') { + $distname = 'Debian'; + $distver = 'Wheezy/Sid'; + $distid = 'debian60'; + $distbaseid = 'debian'; + swriteln("Operating System: Debian 7.0 (Wheezy/Sid) or compatible\n"); + } elseif(strstr(trim(file_get_contents('/etc/debian_version')), '8') || substr(trim(file_get_contents('/etc/debian_version')),0,1) == '8') { + $distname = 'Debian'; + $distver = 'Jessie'; + $distid = 'debian60'; + $distbaseid = 'debian'; + swriteln("Operating System: Debian 8.0 (Jessie) or compatible\n"); + } else { + $distname = 'Debian'; + $distver = 'Unknown'; + $distid = 'debian40'; + $distbaseid = 'debian'; + swriteln("Operating System: Debian or compatible, unknown version.\n"); } + } - //** 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'; - } + //** 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'; + swriteln("Operating System: openSUSE 11.0 or compatible\n"); + } elseif(stristr(file_get_contents('/etc/SuSE-release'), '11.1')) { + $distname = 'openSUSE'; + $distver = '11.1'; + $distid = 'opensuse110'; + $distbaseid = 'opensuse'; + swriteln("Operating System: openSUSE 11.1 or compatible\n"); + } elseif(stristr(file_get_contents('/etc/SuSE-release'), '11.2')) { + $distname = 'openSUSE'; + $distver = '11.2'; + $distid = 'opensuse112'; + $distbaseid = 'opensuse'; + swriteln("Operating System: openSUSE 11.2 or compatible\n"); + } else { + $distname = 'openSUSE'; + $distver = 'Unknown'; + $distid = 'opensuse112'; + $distbaseid = 'opensuse'; + swriteln("Operating System: openSUSE or compatible, unknown version.\n"); } + } - //** 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'; - $distver = '5.3'; - $distid = 'centos53'; - $distbaseid = 'fedora'; - } elseif(stristr($content, 'CentOS Linux release 6')) { - $distname = 'CentOS'; - $distver = 'Unknown'; - $distid = 'centos53'; - $distbaseid = 'fedora'; - } elseif(stristr($content, 'CentOS Linux release 7')) { - $distname = 'CentOS'; - $distver = 'Unknown'; - $distid = 'centos53'; - $distbaseid = 'fedora'; - } else { - $distname = 'Redhat'; - $distver = 'Unknown'; - $distid = 'fedora9'; - $distbaseid = 'fedora'; - } + //** 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'; + swriteln("Operating System: Fedora 9 or compatible\n"); + } elseif(stristr($content, 'Fedora release 10 (Cambridge)')) { + $distname = 'Fedora'; + $distver = '10'; + $distid = 'fedora9'; + $distbaseid = 'fedora'; + swriteln("Operating System: Fedora 10 or compatible\n"); + } elseif(stristr($content, 'Fedora release 10')) { + $distname = 'Fedora'; + $distver = '11'; + $distid = 'fedora9'; + $distbaseid = 'fedora'; + swriteln("Operating System: Fedora 11 or compatible\n"); + } elseif(stristr($content, 'CentOS release 5.2 (Final)')) { + $distname = 'CentOS'; + $distver = '5.2'; + $distid = 'centos52'; + $distbaseid = 'fedora'; + swriteln("Operating System: CentOS 5.2 or compatible\n"); + } elseif(stristr($content, 'CentOS release 5.3 (Final)')) { + $distname = 'CentOS'; + $distver = '5.3'; + $distid = 'centos53'; + $distbaseid = 'fedora'; + swriteln("Operating System: CentOS 5.3 or compatible\n"); + } elseif(stristr($content, 'CentOS release 5')) { + $distname = 'CentOS'; + $distver = 'Unknown'; + $distid = 'centos53'; + $distbaseid = 'fedora'; + swriteln("Operating System: CentOS 5 or compatible\n"); + } elseif(stristr($content, 'CentOS Linux release 6')) { + $distname = 'CentOS'; + $distver = 'Unknown'; + $distid = 'centos53'; + $distbaseid = 'fedora'; + swriteln("Operating System: CentOS 6 or compatible\n"); + } elseif(stristr($content, 'CentOS Linux release 7.2')) { + $distname = 'CentOS'; + $distver = 'Unknown'; + $distid = 'centos70'; + $distconfid = 'centos72'; + $distbaseid = 'fedora'; + swriteln("Operating System: CentOS 7.2\n"); + } elseif(stristr($content, 'CentOS Linux release 7')) { + $distname = 'CentOS'; + $distver = 'Unknown'; + $distid = 'centos70'; + $distbaseid = 'fedora'; + swriteln("Operating System: CentOS 7 or compatible\n"); + } else { + $distname = 'Redhat'; + $distver = 'Unknown'; + $distid = 'fedora9'; + $distbaseid = 'fedora'; + swriteln("Operating System: Redhat or compatible, unknown version.\n"); } + } - //** Gentoo - elseif (file_exists('/etc/gentoo-release')) { + //** Gentoo + elseif(file_exists('/etc/gentoo-release')) { - $content = file_get_contents('/etc/gentoo-release'); + $content = file_get_contents('/etc/gentoo-release'); - preg_match_all('/([0-9]{1,2})/', $content, $version); - $distname = 'Gentoo'; - $distver = $version[0][0] . $version[0][1]; - $distid = 'gentoo'; - $distbaseid = 'gentoo'; - } else { - die('Unrecognized GNU/Linux distribution'); - } + preg_match_all('/([0-9]{1,2})/', $content, $version); + $distname = 'Gentoo'; + $distver = $version[0][0].$version[0][1]; + $distid = 'gentoo'; + $distbaseid = 'gentoo'; + swriteln("Operating System: Gentoo $distver or compatible\n"); + + } else { + die('Unrecognized GNU/Linux distribution'); + } + + // Set $distconfid to distid, if no different id for the config is defined + if(!isset($distconfid)) $distconfid = $distid; - return array('name' => $distname, 'version' => $distver, 'id' => $distid, 'baseid' => $distbaseid); + return array('name' => $distname, 'version' => $distver, 'id' => $distid, 'confid' => $distconfid, 'baseid' => $distbaseid); } // this function remains in the tools class, because it is used by cron AND rescue