version 1.15, 2009/06/28 14:22:04
|
version 1.24, 2021/03/18 21:40:03
|
Line 28
|
Line 28
|
# |
# |
|
|
my $dist='default'; |
my $dist='default'; |
if (-e '/etc/redhat-release') { |
my $unknown; |
|
if (-e '/etc/oracle-release') { |
|
open(IN,'</etc/oracle-release'); |
|
my $versionstring=<IN>; |
|
chomp($versionstring); |
|
close(IN); |
|
if ($versionstring =~ /^Oracle Linux Server release (\d+)/) { |
|
$dist = 'oracle'.$1; |
|
} |
|
} elsif (-e '/etc/redhat-release') { |
open(IN,'</etc/redhat-release'); |
open(IN,'</etc/redhat-release'); |
my $versionstring=<IN>; |
my $versionstring=<IN>; |
chomp($versionstring); |
chomp($versionstring); |
Line 53 if (-e '/etc/redhat-release') {
|
Line 62 if (-e '/etc/redhat-release') {
|
$dist = 'rhes'.$1; |
$dist = 'rhes'.$1; |
} elsif ($versionstring =~ /Red Hat Enterprise Linux Server release (\d+)/) { |
} elsif ($versionstring =~ /Red Hat Enterprise Linux Server release (\d+)/) { |
$dist = 'rhes'.$1; |
$dist = 'rhes'.$1; |
} elsif ($versionstring =~ /CentOS release (\d+)/) { |
} elsif ($versionstring =~ /Red Hat Enterprise Linux release (\d+)/) { |
|
$dist = 'rhes'.$1; |
|
} elsif ($versionstring =~ /CentOS(?:| Linux| Stream) release (\d+)/) { |
$dist = 'centos'.$1; |
$dist = 'centos'.$1; |
} elsif ($versionstring =~ /Scientific Linux SL release ([\d\.]+) /) { |
} elsif ($versionstring =~ /Scientific Linux (?:SL )?release ([\d.]+) /) { |
$dist = 'scientific'.$1; |
my $ver = $1; |
|
$ver =~ s/\.\d+$//; |
|
$dist = 'scientific'.$ver; |
} else { |
} else { |
warn('Unable to interpret /etc/redhat-release '. |
warn('Unable to interpret /etc/redhat-release '. |
'to determine system type'); |
'to determine system type'); |
|
$unknown = 1; |
|
} |
|
} elsif (-e '/etc/SuSE-release') { |
|
open(IN,'</etc/SuSE-release'); |
|
my $versionstring=<IN>; |
|
chomp($versionstring); |
|
close(IN); |
|
if ($versionstring =~ /^SUSE LINUX Enterprise Server ([\d\.]+) /i) { |
|
$dist='sles'.$1; |
|
} elsif ($versionstring =~ /^SuSE Linux ([\d\.]+) /i) { |
|
$dist = 'suse'.$1; |
|
} elsif ($versionstring =~ /^openSUSE ([\d\.]+) /i) { |
|
$dist = 'suse'.$1; |
|
} else { |
|
warn('Unable to interpret /etc/SuSE-release '. |
|
'to determine system type'); |
|
$unknown = 1; |
} |
} |
} elsif (-e '/etc/issue') { |
} elsif (-e '/etc/issue') { |
open(IN,'</etc/issue'); |
open(IN,'</etc/issue'); |
Line 80 if (-e '/etc/redhat-release') {
|
Line 110 if (-e '/etc/redhat-release') {
|
} else { |
} else { |
warn('Unable to interpret /etc/debian_version '. |
warn('Unable to interpret /etc/debian_version '. |
'to determine system type'); |
'to determine system type'); |
|
$unknown = 1; |
} |
} |
} else { |
|
warn('Unable to interpret /etc/issue '. |
|
'to determine system type'); |
|
} |
} |
} elsif (-e '/etc/debian_version') { |
} elsif (-e '/etc/debian_version') { |
open(IN,'</etc/debian_version'); |
open(IN,'</etc/debian_version'); |
Line 95 if (-e '/etc/redhat-release') {
|
Line 123 if (-e '/etc/redhat-release') {
|
} else { |
} else { |
warn('Unable to interpret /etc/debian_version '. |
warn('Unable to interpret /etc/debian_version '. |
'to determine system type'); |
'to determine system type'); |
|
$unknown = 1; |
} |
} |
} elsif (-e '/etc/SuSE-release') { |
} |
open(IN,'</etc/SuSE-release'); |
if (($dist eq 'default') && (!$unknown)) { |
my $versionstring=<IN>; |
if (-e '/etc/os-release') { |
chomp($versionstring); |
if (open(IN,'<','/etc/os-release')) { |
close(IN); |
my ($id,$version); |
if ($versionstring =~ /^SUSE LINUX Enterprise Server ([\d\.]+) /i) { |
while(<IN>) { |
$dist='sles'.$1; |
chomp(); |
} elsif ($versionstring =~ /^SuSE Linux ([\d\.]+) /i) { |
if (/^ID="(\w+)"/) { |
$dist = 'suse'.$1; |
$id=$1; |
} elsif ($versionstring =~ /^openSUSE ([\d\.]+) /i) { |
} elsif (/^VERSION_ID="([\d\.]+)"/) { |
$dist = 'suse'.$1; |
$version=$1; |
|
} |
|
} |
|
close(IN); |
|
if ($id eq 'sles') { |
|
my ($major,$minor) = split(/\./,$version); |
|
if ($major =~ /^\d+$/) { |
|
$dist = $id.$major; |
|
} |
|
} |
|
} |
|
if ($dist eq 'default') { |
|
warn('Unable to interpret /etc/os-release '. |
|
'to determine system type.'); |
|
$unknown = 1; |
|
} |
} else { |
} else { |
warn('Unable to interpret /etc/SuSE-release '. |
warn('Unknown installation: expecting a debian, ubuntu, suse, sles, redhat, fedora or scientific linux system.')."\n"; |
'to determine system type'); |
|
} |
} |
} else { |
|
warn('Unknown installation: expecting a debian, suse, or redhat system'); |
|
} |
} |
print $dist; |
print $dist; |