[debian-edu-commits] r81706 - in branches/wheezy/debian-edu-config: debian etc/shutdown-at-night
pere at alioth.debian.org
pere at alioth.debian.org
Mon Jul 15 14:25:16 UTC 2013
Author: pere
Date: 2013-07-15 14:25:15 +0000 (Mon, 15 Jul 2013)
New Revision: 81706
Modified:
branches/wheezy/debian-edu-config/debian/changelog
branches/wheezy/debian-edu-config/etc/shutdown-at-night/clients-generator
Log:
Rewrite /etc/shutdown-at-night/clients-generator to list hostname
and MAC address the way wakeupclients now expect it (Closes:
#662868).
Modified: branches/wheezy/debian-edu-config/debian/changelog
===================================================================
--- branches/wheezy/debian-edu-config/debian/changelog 2013-07-15 10:41:56 UTC (rev 81705)
+++ branches/wheezy/debian-edu-config/debian/changelog 2013-07-15 14:25:15 UTC (rev 81706)
@@ -1,3 +1,12 @@
+debian-edu-config (1.710~svn) UNRELEASED; urgency=low
+
+ [ Petter Reinholdtsen ]
+ * Rewrite /etc/shutdown-at-night/clients-generator to list hostname
+ and MAC address the way wakeupclients now expect it (Closes:
+ #662868).
+
+ -- Petter Reinholdtsen <pere at debian.org> Mon, 15 Jul 2013 16:23:46 +0200
+
debian-edu-config (1.709) unstable; urgency=low
[ Petter Reinholdtsen ]
Modified: branches/wheezy/debian-edu-config/etc/shutdown-at-night/clients-generator
===================================================================
--- branches/wheezy/debian-edu-config/etc/shutdown-at-night/clients-generator 2013-07-15 10:41:56 UTC (rev 81705)
+++ branches/wheezy/debian-edu-config/etc/shutdown-at-night/clients-generator 2013-07-15 14:25:15 UTC (rev 81706)
@@ -1,4 +1,48 @@
-#!/bin/sh
-PATH=/usr/sbin:$PATH
-export PATH
-netgroup -h shutdown-at-night-hosts
+#!/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;
+ }
+}
More information about the debian-edu-commits
mailing list