Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/*
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)";
case "12.04":
$relname = "(Precise Pangolin)";
case "11.10":
$relname = "(Oneiric Ocelot)";
case "11.14":
$relname = "(Natty Narwhal)";
case "10.10":
$relname = "(Maverick Meerkat)";
case "10.04":
$relname = "(Lucid Lynx)";
case "9.10":
$relname = "(Karmic Koala)";
case "9.04":
$relname = "(Jaunty Jackpole)";
case "8.04":
$relname = "(Hardy Heron)";
case "7.10":
$relname = "(Gutsy Gibbon)";
case "7.04":
$relname = "(Feisty Fawn)";
case "6.10":
$relname = "(Edgy Eft)";
case "6.06":
$relname = "(Dapper Drake)";
case "5.10":
$relname = "(Breezy Badger)";
case "5.04":
$relname = "(Hoary Hedgehog)";
case "4.10":
$relname = "(Warty Warthog)";
default:
$relname = "UNKNOWN";
}
$distver = $ver.$lts." ".$relname;
swriteln("Operating System: ".$distver."\n");
} elseif(trim(file_get_contents('/etc/debian_version')) == '4.0') {
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
$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';
} 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';
$distver = '5.3';
$distid = 'centos53';
$distbaseid = 'fedora';
} else {
Loading full blame...