Skip to content

Commit 3b8b9e3

Browse files
author
Till Brehm
committed
- Introduced confid in $distver array to separate the config and class for a distribution in the installer.
- Cleaned up the dist detection.
1 parent 94b2848 commit 3b8b9e3

File tree

5 files changed

+316
-393
lines changed

5 files changed

+316
-393
lines changed

install/dist/lib/centos72.lib.php

Lines changed: 0 additions & 125 deletions
This file was deleted.

install/install.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
//** Include the distribution-specific installer class library and configuration
134134
if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once 'dist/lib/'.$dist['baseid'].'.lib.php';
135135
include_once 'dist/lib/'.$dist['id'].'.lib.php';
136-
include_once 'dist/conf/'.$dist['id'].'.conf.php';
136+
include_once 'dist/conf/'.$dist['confid'].'.conf.php';
137137

138138
//****************************************************************************************************
139139
//** Installer Interface

install/lib/install.lib.php

Lines changed: 54 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,6 @@
2626
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
2727
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
2828
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-
*/
30-
31-
/*
32-
This function returns a string that describes the installed
33-
Linux distribution. e.g. debian40 for Debian GNU/Linux 4.0
34-
*/
35-
36-
37-
38-
/*
39-
Comments to completion forever ;-)
40-
commandline arguments
41-
$argv[1]
42-
43-
44-
<?
45-
echo "Total argument passed are : $argc \n";
46-
for( $i = 0 ; $i <= $argc -1 ;$i++)
47-
{
48-
echo "Argument $i : $argv[$i] \n";
49-
}
50-
?>
51-
5229
*/
5330
error_reporting(E_ALL|E_STRICT);
5431

@@ -59,60 +36,65 @@
5936
//** IMPORTANT!
6037
// This is the same code as in server/lib/classes/monitor_tools.inc.php
6138
// So if you change it here, you also have to change it in there!
39+
//
40+
// This function returns a string that describes the installed
41+
// Linux distribution. e.g. debian40 for Debian GNU/Linux 4.0
42+
6243
function get_distname() {
6344

6445
$distname = '';
6546
$distver = '';
6647
$distid = '';
6748
$distbaseid = '';
6849

69-
//** Debian or Ubuntu
70-
if (is_file('/etc/os-release') && stristr(file_get_contents('/etc/os-release'), 'Ubuntu')) {
71-
$os_release = file_get_contents('/etc/os-release');
72-
if (strstr(trim($os_release), 'LTS')) {
73-
$lts = " LTS";
74-
} else {
75-
$lts = "";
76-
}
77-
78-
preg_match("/.*VERSION=\"(.*)\".*/ui", $os_release, $ver);
79-
$ver = str_replace("LTS", "", $ver[1]);
80-
$ver = explode(" ", $ver, 2);
81-
$relname = end($ver);
82-
$relname = "(" . trim(trim($relname), "()") . ")";
83-
$distname = 'Ubuntu';
84-
$ver = reset($ver);
85-
if($ver == "16.04") {
86-
$distid = 'ubuntu1604';
87-
} else {
88-
$distid = 'debian40';
89-
}
90-
$distbaseid = 'debian';
91-
$distver = $ver . $lts . " " . $relname;
92-
swriteln("Operating System: " . $distver . "\n");
93-
} //** Debian / Ubuntu
94-
elseif(file_exists('/etc/debian_version')) {
95-
if (strstr(trim(file_get_contents('/etc/issue')), 'Ubuntu')) {
96-
if (strstr(trim(file_get_contents('/etc/issue')), 'LTS')) {
97-
$lts=" LTS";
50+
//** Debian or Ubuntu
51+
if(file_exists('/etc/debian_version')) {
52+
53+
// Check if this is Ubuntu and not Debian
54+
if (strstr(trim(file_get_contents('/etc/issue')), 'Ubuntu') || (is_file('/etc/os-release') && stristr(file_get_contents('/etc/os-release'), 'Ubuntu'))) {
55+
56+
$issue = file_get_contents('/etc/issue');
57+
58+
// Use content of /etc/issue file
59+
if(strstr($issue,'Ubuntu')) {
60+
if (strstr(trim($issue), 'LTS')) {
61+
$lts=" LTS";
62+
} else {
63+
$lts="";
64+
}
65+
66+
$distname = 'Ubuntu';
67+
$distid = 'debian40';
68+
$distbaseid = 'debian';
69+
$ver = explode(' ', $issue);
70+
$ver = array_filter($ver);
71+
$ver = next($ver);
72+
$mainver = explode('.', $ver);
73+
$mainver = array_filter($mainver);
74+
$mainver = current($mainver).'.'.next($mainver);
75+
// Use content of /etc/os-release file
9876
} else {
99-
$lts="";
77+
$os_release = file_get_contents('/etc/os-release');
78+
if (strstr(trim($os_release), 'LTS')) {
79+
$lts = " LTS";
80+
} else {
81+
$lts = "";
82+
}
83+
84+
$distname = 'Ubuntu';
85+
$distid = 'debian40';
86+
$distbaseid = 'debian';
87+
88+
preg_match("/.*VERSION=\"(.*)\".*/ui", $os_release, $ver);
89+
$ver = str_replace("LTS", "", $ver[1]);
90+
$ver = explode(" ", $ver, 2);
91+
$ver = reset($ver);
92+
$mainver = $ver;
10093
}
101-
102-
$issue=file_get_contents('/etc/issue');
103-
$distname = 'Ubuntu';
104-
$distid = 'debian40';
105-
$distbaseid = 'debian';
106-
$ver = explode(' ', $issue);
107-
$ver = array_filter($ver);
108-
$ver = next($ver);
109-
$mainver = explode('.', $ver);
110-
$mainver = array_filter($mainver);
111-
$mainver = current($mainver).'.'.next($mainver);
11294
switch ($mainver){
11395
case "16.04":
11496
$relname = "(Xenial Xerus)";
115-
$distid = 'ubuntu1604';
97+
$distconfid = 'ubuntu1604';
11698
break;
11799
case "15.10":
118100
$relname = "(Wily Werewolf)";
@@ -187,7 +169,7 @@ function get_distname() {
187169
$relname = "UNKNOWN";
188170
}
189171
$distver = $ver.$lts." ".$relname;
190-
swriteln("Operating System: ".$distver."\n");
172+
swriteln("Operating System: ".$distname.' '.$distver."\n");
191173
} elseif(trim(file_get_contents('/etc/debian_version')) == '4.0') {
192174
$distname = 'Debian';
193175
$distver = '4.0';
@@ -307,7 +289,8 @@ function get_distname() {
307289
} elseif(stristr($content, 'CentOS Linux release 7.2')) {
308290
$distname = 'CentOS';
309291
$distver = 'Unknown';
310-
$distid = 'centos72';
292+
$distid = 'centos70';
293+
$distconfid = 'centos72';
311294
$distbaseid = 'fedora';
312295
swriteln("Operating System: CentOS 7.2\n");
313296
} elseif(stristr($content, 'CentOS Linux release 7')) {
@@ -340,8 +323,11 @@ function get_distname() {
340323
} else {
341324
die('Unrecognized GNU/Linux distribution');
342325
}
326+
327+
// Set $distconfid to distid, if no different id for the config is defined
328+
if(!isset($distconfid)) $distconfid = $distid;
343329

344-
return array('name' => $distname, 'version' => $distver, 'id' => $distid, 'baseid' => $distbaseid);
330+
return array('name' => $distname, 'version' => $distver, 'id' => $distid, 'confid' => $distconfid, 'baseid' => $distbaseid);
345331
}
346332

347333
function sread() {

install/update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
//** Include the distribution-specific installer class library and configuration
138138
if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once 'dist/lib/'.$dist['baseid'].'.lib.php';
139139
include_once 'dist/lib/'.$dist['id'].'.lib.php';
140-
include_once 'dist/conf/'.$dist['id'].'.conf.php';
140+
include_once 'dist/conf/'.$dist['confid'].'.conf.php';
141141

142142
//** Get hostname
143143
exec('hostname -f', $tmp_out);

0 commit comments

Comments
 (0)