Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
mkmotd: Cache host tags
Evaluate `hostconfig` only once.
  • Loading branch information
donald committed Jan 3, 2023
1 parent d606cee commit 8209fe7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mkmotd/mkmotd.pl
Expand Up @@ -9,6 +9,8 @@
my ($os_release) = `/bin/os-release`;
chomp($os_release);

my @hostconfig = split " ",`hostconfig`;

our $TEMPLATE;

if ( $os_release eq 'mariux_x86_64' || $os_release eq 'mariux_i686' ) {
Expand Down Expand Up @@ -41,7 +43,7 @@
EOF

$TEMPLATE .= " / to bee or not to bee / tags: ".`hostconfig`."\n";
$TEMPLATE .= " / to bee or not to bee / tags: ".join(" ",@hostconfig)."\n";
}
else {
die "$os_release : unknown os_release\n";
Expand All @@ -61,7 +63,6 @@ sub readstr {

sub policy { # policy('theinternet') --> ('zeile1,'zeile2',....)
my ($hostname) = @_;
my @hostconfig=split(/ |\n/, `hostconfig`);
open IN, '<', '/etc/mxpolicy' or return ();
my @out;
while (<IN>) {
Expand Down

0 comments on commit 8209fe7

Please sign in to comment.