/etc/shutdown-at-night/clients-generator is in debian-edu-config 1.818+deb8u2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 47 48 | #!/usr/bin/perl
use strict;
use warnings;
use Socket;
use SiteSummary;
use vars qw(%hostmap);
$ENV{PATH} .= ':/usr/sbin';
my @hostlist = `netgroup -h shutdown-at-night-hosts`;
chomp @hostlist;
map { $hostmap{$_} = 1; } @hostlist;
for_all_hosts(\&host_handler);
exit(0);
sub host_handler {
my $hostid = shift;
my $ipaddr = SiteSummary::get_primary_ip_address($hostid);
my $fqdn = scalar gethostbyaddr(inet_aton($ipaddr), AF_INET);
if ($fqdn) {
my $mac = (get_ether_hwaddr($hostid))[0];
if (exists $hostmap{$fqdn}) {
print "$fqdn $mac\n";
}
}
}
sub get_ether_hwaddr {
my $hostid = shift;
my $path = get_filepath_current($hostid, "/system/ifconfig-a");
if (open(FILE, "<", $path)) {
my $sysinfo = 0;
my @hwaddr = ();
while (<FILE>) {
chomp;
if (m/Link encap:Ethernet HWaddr (.+\S)\s*$/) {
push(@hwaddr, $1);
}
}
close(FILE);
return @hwaddr;
} else {
return undef;
}
}
|