Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mkmotd.pl : fixes
Browse files Browse the repository at this point in the history
wwwutz authored and david committed Apr 9, 2018
1 parent 2fb5266 commit 26c27c0
Showing 1 changed file with 28 additions and 29 deletions.
57 changes: 28 additions & 29 deletions mkmotd/mkmotd.pl
Original file line number Diff line number Diff line change
@@ -3,16 +3,9 @@
use warnings;

#
# Mutter: /project/admin/linux/mkmotd.pl
# Mutter: https://github.molgen.mpg.de/mariux64/mxtools/tree/master/mkmotd
#

if ($ARGV[0] and $ARGV[0] eq 'u') {
print `cp -v /project/admin/linux/mkmotd.pl /usr/sbin`;
print "update done.\n";
exit;
}


my ($os_release)=`/bin/os-release`;chomp($os_release);

our $TEMPLATE;
@@ -72,24 +65,24 @@ sub readstr {
}

sub policy { # policy('theinternet') --> ('zeile1,'zeile2',....)
my ($hostname)=@_;

open IN,'<','/etc/mxpolicy' or return ();
while (<IN>) {
if (/^\S/ && /\b$hostname\b/) {
my @out;
while (<IN>) {
/^\S/ and last;
/\s+\*\s*(.+)/ and push @out,$1;
if (/\s+\`\s*(.+)/) {
my $x = `$1`;chomp($x);
push @out,split(/\n/,$x);
}
}
return @out;
}
my ($hostname)=@_;

open IN,'<','/etc/mxpolicy' or return ();
while (<IN>) {
if (/^\S/ && /\b$hostname\b/) {
my @out;
while (<IN>) {
/^\S/ and last;
/\s+\*\s*(.+)/ and push @out,$1;
if (/\s+\`\s*(.+)/) {
my $x = `$1`;chomp($x);
push @out,split(/\n/,$x);
}
return ();
}
return @out;
}
}
return ();
}


@@ -114,7 +107,7 @@ sub policy { # policy('theinternet') --> ('zeile1,'zeile2',....)
my @pc=`cat /proc/cpuinfo`;
my $mn='unknown CPU';
$T{NCPU} = grep {/model name/ and $mn = $_; /processor/} @pc;
$mn =~ s/\(.*?\)|xeon|Virtual|Athlon|model name\s*:|six.core|quad.core|dual.core|intel|Processor|cpu|core//ig;
$mn =~ s/\(.*?\)|\d+-Core Processor|xeon|Virtual|Athlon|model name\s*:|six.core|quad.core|dual.core|intel|Processor|cpu|core//ig;
$mn =~ s/\s(E\d\-)\s/$1/;
$mn =~ s/\s\d\s\@/ \@/;
$mn =~ s/version\s+/v/g;
@@ -133,15 +126,19 @@ sub policy { # policy('theinternet') --> ('zeile1,'zeile2',....)

my $pn = readstr('/sys/devices/virtual/dmi/id/product_name');
if ($pn =~ m/All Series|empty/) {
$pn = undef;
$pn = readstr('/sys/devices/virtual/dmi/id/board_name');
$pn =~ s/^TYAN Transport\s+//;
}
# $pn =~ s/(TYAN Transport )//i;

my $mf = readstr('/sys/devices/virtual/dmi/id/sys_vendor');
if ($mf =~ m/(empty|NVIDIA)/) {
$mf = readstr('/sys/devices/virtual/dmi/id/board_vendor');
}

($mf eq 'Supermicro') and $pn =~ s/^AS -//;
($mf =~ /^Gigabyte/) and $pn =~ s/^GA-//;


$mf =~ s/( Inc.| Computer Corporation)//;

my $vn = readstr('/sys/devices/virtual/dmi/id/product_version');
@@ -153,10 +150,12 @@ sub policy { # policy('theinternet') --> ('zeile1,'zeile2',....)
$mf = $vn;
$pn = '';
}
($mf eq 'QEMU') and $pn='';

($pn ne '') and $pn = " $pn";
$T{SYSTEM} = "$mf$pn";
$T{SYSTEM} =~ s/_/ /g;
$T{SYSTEM} =~ s{( Transport| Tower|Hewlett-Packard |/S2932-E/S2932-SI| Thunder| Computer Corp|Technology Co., Ltd. )}{}i;
$T{SYSTEM} =~ s{( WorkStation| Transport| Tower|Hewlett-Packard |/S2932-E/S2932-SI| Thunder| Computer Corp|Technology Co., Ltd. | Standard PC)}{}i;
}

my %BC = (

0 comments on commit 26c27c0

Please sign in to comment.