version 1.4, 2003/07/01 17:55:12
|
version 1.25, 2021/12/20 03:13:29
|
Line 1
|
Line 1
|
#!/usr/bin/perl |
#!/usr/bin/perl |
|
# |
# YEAR=2002 |
# The LearningOnline Network with CAPA |
|
# |
|
# $Id$ |
|
# |
|
# Copyright Michigan State University Board of Trustees |
|
# |
|
# This file is part of the LearningOnline Network with CAPA (LON-CAPA). |
|
# |
|
# LON-CAPA is free software; you can redistribute it and/or modify |
|
# it under the terms of the GNU General Public License as published by |
|
# the Free Software Foundation; either version 2 of the License, or |
|
# (at your option) any later version. |
|
# |
|
# LON-CAPA is distributed in the hope that it will be useful, |
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
# GNU General Public License for more details. |
|
# |
|
# You should have received a copy of the GNU General Public License |
|
# along with LON-CAPA; if not, write to the Free Software |
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
# |
|
# /home/httpd/html/adm/gpl.txt |
|
# |
|
# http://www.lon-capa.org/ |
|
# |
|
|
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); |
close(IN); |
close(IN); |
my $version=(split(/\s+/,$versionstring))[4]; |
if ($versionstring =~ /^Red Hat Linux release ([\d\.]+) /) { |
if ($version=~/^7\./) { |
$version = $1; |
$dist='redhat7'; |
if ($version=~/^7\./) { |
} elsif ($version=~/^8\./) { |
$dist='redhat7'; |
$dist='redhat8'; |
} elsif ($version=~/^8\./) { |
} elsif ($version=~/^9/) { |
$dist='redhat8'; |
$dist='redhat9'; |
} elsif ($version=~/^9/) { |
|
$dist='redhat9'; |
|
} |
|
} elsif ($versionstring =~ /Fedora( Core)? release ([\d\.]+) /) { |
|
my $version=$2; |
|
if ($version - int($version) > .9) { |
|
$dist = 'fedora'.(int($version)+1); |
|
} else { |
|
$dist = 'fedora'.int($version); |
|
} |
|
} elsif ($versionstring =~ /Red Hat Enterprise Linux [AE]S release ([\d\.]+) /) { |
|
$dist = 'rhes'.$1; |
|
} elsif ($versionstring =~ /Red Hat Enterprise Linux Server release (\d+)/) { |
|
$dist = 'rhes'.$1; |
|
} elsif ($versionstring =~ /Red Hat Enterprise Linux release (\d+)/) { |
|
$dist = 'rhes'.$1; |
|
} elsif ($versionstring =~ /CentOS(?:| Linux| Stream) release (\d+)/) { |
|
$dist = 'centos'.$1; |
|
} elsif ($versionstring =~ /Scientific Linux (?:SL )?release ([\d.]+) /) { |
|
my $ver = $1; |
|
$ver =~ s/\.\d+$//; |
|
$dist = 'scientific'.$ver; |
|
} elsif ($versionstring =~ /Rocky Linux release ([\d.]+)/) { |
|
my $ver = $1; |
|
$ver =~ s/\.\d+$//; |
|
$dist = 'rocky'.$ver; |
|
} elsif ($versionstring =~ /AlmaLinux release ([\d.]+)/) { |
|
my $ver = $1; |
|
$ver =~ s/\.\d+$//; |
|
$dist = 'alma'.$ver; |
|
} else { |
|
warn('Unable to interpret /etc/redhat-release '. |
|
'to determine system type'); |
|
$unknown = 1; |
} |
} |
} |
} elsif (-e '/etc/SuSE-release') { |
elsif (-e '/etc/debian_version') { |
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') { |
|
open(IN,'</etc/issue'); |
|
my $versionstring=<IN>; |
|
chomp($versionstring); |
|
close(IN); |
|
if ($versionstring =~ /^Ubuntu (\d+)\.\d+/i) { |
|
$dist = 'ubuntu'.$1; |
|
} elsif ($versionstring =~ /^Debian\s+GNU\/Linux\s+(\d+)\.\d+/i) { |
|
$dist = 'debian'.$1; |
|
} elsif (-e '/etc/debian_version') { |
|
open(IN,'</etc/debian_version'); |
|
my $version=<IN>; |
|
chomp($version); |
|
close(IN); |
|
if ($version =~ /^(\d+)\.\d+\.?\d*/) { |
|
$dist='debian'.$1; |
|
} else { |
|
warn('Unable to interpret /etc/debian_version '. |
|
'to determine system type'); |
|
$unknown = 1; |
|
} |
|
} |
|
} elsif (-e '/etc/debian_version') { |
open(IN,'</etc/debian_version'); |
open(IN,'</etc/debian_version'); |
my $version=<IN>; |
my $version=<IN>; |
chomp($version); |
chomp($version); |
close(IN); |
close(IN); |
if ($version eq '2.2') { |
if ($version =~ /^(\d+)\.\d+\.?\d*/) { |
$dist='debian2.2'; |
$dist='debian'.$1; |
|
} else { |
|
warn('Unable to interpret /etc/debian_version '. |
|
'to determine system type'); |
|
$unknown = 1; |
} |
} |
} |
} |
else { |
if (($dist eq 'default') && (!$unknown)) { |
warn('Unknown installation filesystem; expecting debian version 2.2 '. |
if (-e '/etc/os-release') { |
'or redhat 6.* or 7.*'); |
if (open(IN,'<','/etc/os-release')) { |
|
my ($id,$version); |
|
while(<IN>) { |
|
chomp(); |
|
if (/^ID="(\w+)"/) { |
|
$id=$1; |
|
} elsif (/^VERSION_ID="([\d\.]+)"/) { |
|
$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 { |
|
warn('Unknown installation: expecting a debian, ubuntu, suse, sles, redhat, fedora or scientific linux system.')."\n"; |
|
} |
} |
} |
print $dist; |
print $dist; |