[debian-edu-commits] r81943 - in trunk/src/debian-edu-config: debian etc/shutdown-at-night

sunweaver at alioth.debian.org sunweaver at alioth.debian.org
Tue Aug 6 07:37:22 UTC 2013


Author: sunweaver
Date: 2013-08-06 07:37:21 +0000 (Tue, 06 Aug 2013)
New Revision: 81943

Modified:
   trunk/src/debian-edu-config/debian/changelog
   trunk/src/debian-edu-config/etc/shutdown-at-night/clients-generator
Log:
Adopt from d-e-c (wheezy):
Rewrite /etc/shutdown-at-night/clients-generator to list hostname
and MAC address the way wakeupclients now expect it (Closes:
#662868). (by Petter Reinholdtsen)

Modified: trunk/src/debian-edu-config/debian/changelog
===================================================================
--- trunk/src/debian-edu-config/debian/changelog	2013-08-06 05:03:03 UTC (rev 81942)
+++ trunk/src/debian-edu-config/debian/changelog	2013-08-06 07:37:21 UTC (rev 81943)
@@ -1,3 +1,12 @@
+debian-edu-config (1.457) UNRELEASED; urgency=low
+
+  * Adopt from d-e-c (wheezy):
+    Rewrite /etc/shutdown-at-night/clients-generator to list hostname
+    and MAC address the way wakeupclients now expect it (Closes:
+    #662868). (by Petter Reinholdtsen)
+
+ -- Mike Gabriel <sunweaver at debian.org>  Tue, 06 Aug 2013 09:25:40 +0200
+
 debian-edu-config (1.456) squeeze-test; urgency=low
 
   [ Petter Reinholdtsen ]

Modified: trunk/src/debian-edu-config/etc/shutdown-at-night/clients-generator
===================================================================
--- trunk/src/debian-edu-config/etc/shutdown-at-night/clients-generator	2013-08-06 05:03:03 UTC (rev 81942)
+++ trunk/src/debian-edu-config/etc/shutdown-at-night/clients-generator	2013-08-06 07:37:21 UTC (rev 81943)
@@ -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